diff --git a/.forgejo/workflows/build-command_backup.yml b/.forgejo/workflows/build-command_backup.yml deleted file mode 100644 index 0884c70b..00000000 --- a/.forgejo/workflows/build-command_backup.yml +++ /dev/null @@ -1,61 +0,0 @@ -# name: Build - -# on: -# push: -# tags: -# - "command-dev[0-9]+.[0-9]+.[0-9]+" -# - "command-dev[0-9]+.[0-9]+.[0-9]+*" -# workflow_dispatch: - -# env: -# REGISTRY: ${{ vars.CONTAINER_REGISTRY }} -# REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} -# REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} -# CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} -# IMAGE_VERSION: build -# DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} - -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v4 -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v2 -# with: -# config-inline: | -# [registry."${{ env.REGISTRY }}"] -# ca=["/etc/ssl/certs/ca-certificates.crt"] -# - name: Tag Version -# run: | -# if [[ "${{ github.event_name }}" == "push" ]]; then -# echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/command-dev//g' >> $GITHUB_ENV -# else -# echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV -# fi -# - name: Login in to registry -# uses: docker/login-action@v2 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ env.REGISTRY_USERNAME }} -# password: ${{ env.REGISTRY_PASSWORD }} -# - name: Build and push docker image -# uses: docker/build-push-action@v3 -# with: -# platforms: linux/amd64 -# context: . -# file: ./BMA.EHR.Command.Service/Dockerfile -# tags: ${{ env.CONTAINER_IMAGE_NAME }}/hrms-api-command:latest,${{ env.CONTAINER_IMAGE_NAME }}/hrms-api-command:${{ env.IMAGE_VERSION }} -# push: true -# - name: Remote Deploy -# uses: appleboy/ssh-action@v1.2.1 -# with: -# host: ${{ vars.SSH_DEPLOY_HOST }} -# port: ${{ vars.SSH_DEPLOY_PORT }} -# username: ${{ secrets.SSH_DEPLOY_USER }} -# password: ${{ secrets.SSH_DEPLOY_PASSWORD }} -# script: | -# cd ~/repo -# ./replace-env.sh API_COMMAND "${{ env.IMAGE_VERSION }}" -# ./deploy.sh hrms-api-command diff --git a/.forgejo/workflows/build-report_backup.yml b/.forgejo/workflows/build-report_backup.yml deleted file mode 100644 index 664de47b..00000000 --- a/.forgejo/workflows/build-report_backup.yml +++ /dev/null @@ -1,84 +0,0 @@ -# name: Build - -# on: -# push: -# tags: -# - "report-dev[0-9]+.[0-9]+.[0-9]+" -# - "report-dev[0-9]+.[0-9]+.[0-9]+*" -# workflow_dispatch: - -# env: -# REGISTRY: ${{ vars.CONTAINER_REGISTRY }} -# REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} -# REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} -# CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} -# SERVICE_NAME: hrms-api-report -# IMAGE_VERSION: build -# DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} - -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v4 -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v2 -# with: -# config-inline: | -# [registry."${{ env.REGISTRY }}"] -# ca=["/etc/ssl/certs/ca-certificates.crt"] -# - name: Tag Version -# run: | -# if [[ "${{ github.event_name }}" == "push" ]]; then -# echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/report-dev//g' >> $GITHUB_ENV -# else -# echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV -# fi -# - name: Login in to registry -# uses: docker/login-action@v2 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ env.REGISTRY_USERNAME }} -# password: ${{ env.REGISTRY_PASSWORD }} -# - name: Build and push docker image -# uses: docker/build-push-action@v3 -# with: -# platforms: linux/amd64 -# context: . -# file: ./BMA.EHR.Report.Service/Dockerfile -# tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} -# push: true -# - name: Remote Deploy -# uses: appleboy/ssh-action@v1.2.1 -# with: -# host: ${{ vars.SSH_DEPLOY_HOST }} -# port: ${{ vars.SSH_DEPLOY_PORT }} -# username: ${{ secrets.SSH_DEPLOY_USER }} -# password: ${{ secrets.SSH_DEPLOY_PASSWORD }} -# script: | -# cd ~/repo -# ./replace-env.sh API_REPORT "${{ env.IMAGE_VERSION }}" -# ./deploy.sh ${{ env.SERVICE_NAME }} - -# - name: Discord Notification -# if: always() -# run: | -# STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" -# COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" -# TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) -# curl -H "Content-Type: application/json" \ -# -X POST \ -# -d "{ -# \"embeds\": [{ -# \"title\": \"$STATUS\", -# \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ github.actor }}\`\", -# \"color\": $COLOR, -# \"footer\": { -# \"text\": \"Release Notification\", -# \"icon_url\": \"https://example.com/success-icon.png\" -# }, -# \"timestamp\": \"$TIMESTAMP\" -# }] -# }" \ -# ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml deleted file mode 100644 index a4f2d2e5..00000000 --- a/.forgejo/workflows/build.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build - -on: - push: - tags: - - "leave[0-9]+.[0-9]+.[0-9]+" - - "leave[0-9]+.[0-9]+.[0-9]+*" - workflow_dispatch: - -env: - REGISTRY: ${{ vars.CONTAINER_REGISTRY }} - REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} - REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} - CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} - IMAGE_VERSION: build - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - with: - config-inline: | - [registry."${{ env.REGISTRY }}"] - ca=["/etc/ssl/certs/ca-certificates.crt"] - - name: Tag Version - run: | - if [[ "${{ github.event_name }}" == "push" ]]; then - echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/leave//g' >> $GITHUB_ENV - else - echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV - fi - - name: Login in to registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ env.REGISTRY_USERNAME }} - password: ${{ env.REGISTRY_PASSWORD }} - - name: Build and push docker image - uses: docker/build-push-action@v3 - with: - platforms: linux/amd64 - context: . - file: ./BMA.EHR.Leave/Dockerfile - tags: ${{ env.CONTAINER_IMAGE_NAME }}/hrms-leave:latest,${{ env.CONTAINER_IMAGE_NAME }}/hrms-leave:${{ env.IMAGE_VERSION }} - push: true diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml deleted file mode 100644 index 7a18d4cc..00000000 --- a/.forgejo/workflows/deploy.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build - -on: - workflow_dispatch: - inputs: - version: - description: "Version to deploy" - type: string - required: false - default: "latest" - -env: - IMAGE_VERSION: build - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Remote Deploy - uses: appleboy/ssh-action@v1.2.1 - with: - host: ${{ vars.SSH_DEPLOY_HOST }} - port: ${{ vars.SSH_DEPLOY_PORT }} - username: ${{ secrets.SSH_DEPLOY_USER }} - password: ${{ secrets.SSH_DEPLOY_PASSWORD }} - script: | - cd ~/repo - ./replace-env.sh API_LEAVE "${{ inputs.version }}" - ./deploy.sh hrms-api-leave diff --git a/.github/workflows/dockerhub-release-checkin.yaml b/.github/workflows/dockerhub-release-checkin.yaml new file mode 100644 index 00000000..b80c44f7 --- /dev/null +++ b/.github/workflows/dockerhub-release-checkin.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - CheckIn Consumer +run-name: DockerHub Release - CheckIn Consumer by ${{ github.actor }} +on: + push: + tags: + - "checkin-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-checkin + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.CheckInConsumer/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR CheckIn Consumer + org.opencontainers.image.description=HRMS CheckIn Consumer Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-command.yaml b/.github/workflows/dockerhub-release-command.yaml new file mode 100644 index 00000000..571fd6c9 --- /dev/null +++ b/.github/workflows/dockerhub-release-command.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Command Service +run-name: DockerHub Release - Command Service by ${{ github.actor }} +on: + push: + tags: + - "command-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-command + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Command.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Command Service + org.opencontainers.image.description=HRMS Command API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-discipline.yaml b/.github/workflows/dockerhub-release-discipline.yaml new file mode 100644 index 00000000..f4642bd8 --- /dev/null +++ b/.github/workflows/dockerhub-release-discipline.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Discipline Service +run-name: DockerHub Release - Discipline Service by ${{ github.actor }} +on: + push: + tags: + - "discipline-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-discipline + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Discipline.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Discipline Service + org.opencontainers.image.description=HRMS Discipline API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-insignia.yaml b/.github/workflows/dockerhub-release-insignia.yaml new file mode 100644 index 00000000..79d89963 --- /dev/null +++ b/.github/workflows/dockerhub-release-insignia.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Insignia Service +run-name: DockerHub Release - Insignia Service by ${{ github.actor }} +on: + push: + tags: + - "insignia-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-insignia + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Insignia/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Insignia Service + org.opencontainers.image.description=HRMS Insignia API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-leave.yaml b/.github/workflows/dockerhub-release-leave.yaml new file mode 100644 index 00000000..f9c2e0ba --- /dev/null +++ b/.github/workflows/dockerhub-release-leave.yaml @@ -0,0 +1,119 @@ +name: DockerHub Release - Leave Service +run-name: DockerHub Release - Leave Service by ${{ github.actor }} +on: + push: + tags: + - "leave-[0-9]+.[0-9]+.[0-9]+" + # branches: + # - main + # - develop + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-leave + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + elif [[ $GITHUB_REF == 'refs/heads/'* ]]; then + BRANCH_NAME=${GITHUB_REF#refs/heads/} + IMAGE_VER="${BRANCH_NAME}-latest" + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + type=ref,event=branch + type=raw,value=${{ steps.gen_ver.outputs.image_ver }} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Leave/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Image digest + run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}" + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-placement.yaml b/.github/workflows/dockerhub-release-placement.yaml new file mode 100644 index 00000000..d4e3dade --- /dev/null +++ b/.github/workflows/dockerhub-release-placement.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Placement Service +run-name: DockerHub Release - Placement Service by ${{ github.actor }} +on: + push: + tags: + - "placement-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-placement + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Placement.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Placement Service + org.opencontainers.image.description=HRMS Placement API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-reportv2.yaml b/.github/workflows/dockerhub-release-reportv2.yaml new file mode 100644 index 00000000..4dc73f3f --- /dev/null +++ b/.github/workflows/dockerhub-release-reportv2.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Report Service +run-name: DockerHub Release - Report Service by ${{ github.actor }} +on: + push: + tags: + - "reportv2-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-reportv2 + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Report.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Report Service + org.opencontainers.image.description=HRMS Report API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/dockerhub-release-retirement.yaml b/.github/workflows/dockerhub-release-retirement.yaml new file mode 100644 index 00000000..50ace5cd --- /dev/null +++ b/.github/workflows/dockerhub-release-retirement.yaml @@ -0,0 +1,101 @@ +name: DockerHub Release - Retirement Service +run-name: DockerHub Release - Retirement Service by ${{ github.actor }} +on: + push: + tags: + - "retirement-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-retirement + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate 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 "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Retirement.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Retirement Service + org.opencontainers.image.description=HRMS Retirement API Service + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Discord on success + if: success() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="✅ DockerHub release succeeded\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" + + - name: Notify Discord on failure + if: failure() + env: + IMAGE_VER: ${{ steps.gen_ver.outputs.image_ver }} + run: | + TAG_INFO="Tag: ${IMAGE_VER:-unknown}" + REF_INFO="Ref: ${GITHUB_REF}" + ACTOR_INFO="Actor: ${GITHUB_ACTOR}" + MSG="❌ DockerHub release failed\n${TAG_INFO}\n${REF_INFO}\n${ACTOR_INFO}" + curl -s -H "Content-Type: application/json" \ + -X POST \ + -d "{\"content\":\"${MSG}\"}" \ + "$DISCORD_WEBHOOK" diff --git a/.github/workflows/release_Retirement.yaml b/.github/workflows/release_Retirement.yaml index 6cdceae0..3fd5bedf 100644 --- a/.github/workflows/release_Retirement.yaml +++ b/.github/workflows/release_Retirement.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "retirement-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "retirement-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_checkin_consumer.yaml b/.github/workflows/release_checkin_consumer.yaml index 31b015e6..f9081264 100644 --- a/.github/workflows/release_checkin_consumer.yaml +++ b/.github/workflows/release_checkin_consumer.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "consumer-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "consumer-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_command.yaml b/.github/workflows/release_command.yaml index 462ed688..dba3012e 100644 --- a/.github/workflows/release_command.yaml +++ b/.github/workflows/release_command.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "command-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "command-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_discipline.yaml b/.github/workflows/release_discipline.yaml index 0e8737f4..f4cb42da 100644 --- a/.github/workflows/release_discipline.yaml +++ b/.github/workflows/release_discipline.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "discipline-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "discipline-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml index 124d1e9c..af497b37 100644 --- a/.github/workflows/release_insignia.yaml +++ b/.github/workflows/release_insignia.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "insignia-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "insignia-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_leave.yaml b/.github/workflows/release_leave.yaml index 4b361f5f..9b5e0014 100644 --- a/.github/workflows/release_leave.yaml +++ b/.github/workflows/release_leave.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "leave-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "leave-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_placement.yaml b/.github/workflows/release_placement.yaml index d9c2f266..377cbaf4 100644 --- a/.github/workflows/release_placement.yaml +++ b/.github/workflows/release_placement.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "placement-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "placement-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_report.yaml b/.github/workflows/release_report.yaml index 9ba5a7c4..e529729b 100644 --- a/.github/workflows/release_report.yaml +++ b/.github/workflows/release_report.yaml @@ -1,107 +1,107 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "reportv2-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "reportv2-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: - REGISTRY: docker.frappet.com - IMAGE_NAME: ehr/bma-ehr-report-v2-service - DEPLOY_HOST: frappet.com - DEPLOY_PORT: 10102 - # COMPOSE_PATH: /home/frappet/docker/bma-ehr - COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2 - TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 + REGISTRY: docker.frappet.com + IMAGE_NAME: ehr/bma-ehr-report-v2-service + DEPLOY_HOST: frappet.com + DEPLOY_PORT: 10102 + # COMPOSE_PATH: /home/frappet/docker/bma-ehr + COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2 + TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 jobs: - # act workflow_dispatch -W .github/workflows/release_report.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.Report.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_report.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.Report.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 }} diff --git a/.vscode/launch.json b/.vscode/launch.json index fd9cf53a..6be3e592 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,35 +1,60 @@ { - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. - "name": ".NET Core Launch (web)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/BMA.EHR.Leave.Service/bin/Debug/net7.0/BMA.EHR.Leave.Service.dll", - "args": [], - "cwd": "${workspaceFolder}/BMA.EHR.Leave.Service", - "stopAtEntry": false, - // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser - "serverReadyAction": { - "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceFolder}/Views" - } - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach" - } - ] -} \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/BMA.EHR.Leave/bin/Debug/net7.0/BMA.EHR.Leave.dll", + "args": [], + "cwd": "${workspaceFolder}/BMA.EHR.Leave", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. + "name": ".NET Core Launch (web) - Insignia", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/BMA.EHR.Insignia/bin/Debug/net7.0/BMA.EHR.Insignia.dll", + "args": [], + "cwd": "${workspaceFolder}/BMA.EHR.Insignia", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/BMA.EHR.Application/ApplicationServicesRegistration.cs b/BMA.EHR.Application/ApplicationServicesRegistration.cs index 350b7a75..0b99a7b6 100644 --- a/BMA.EHR.Application/ApplicationServicesRegistration.cs +++ b/BMA.EHR.Application/ApplicationServicesRegistration.cs @@ -53,6 +53,7 @@ namespace BMA.EHR.Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -60,6 +61,8 @@ namespace BMA.EHR.Application services.AddTransient(); + services.AddTransient(); + return services; } diff --git a/BMA.EHR.Application/Repositories/GenericRepository.cs b/BMA.EHR.Application/Repositories/GenericRepository.cs index fcc2aef0..d825ccaf 100644 --- a/BMA.EHR.Application/Repositories/GenericRepository.cs +++ b/BMA.EHR.Application/Repositories/GenericRepository.cs @@ -53,15 +53,18 @@ namespace BMA.EHR.Application.Repositories #region " For Call External API " - protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey) + protected async Task GetExternalAPIAsync(string apiPath, string accessToken, string apiKey, CancellationToken cancellationToken = default) { try { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api-key", apiKey); - var _res = await client.GetAsync(apiPath); + var _res = await client.GetAsync(apiPath,cancellationToken: combinedCts.Token); if (_res.IsSuccessStatusCode) { var _result = await _res.Content.ReadAsStringAsync(); @@ -77,10 +80,13 @@ namespace BMA.EHR.Application.Repositories } } - protected async Task SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey) + protected async Task SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default) { try { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); // สร้าง request message var request = new HttpRequestMessage(method, apiPath); @@ -92,7 +98,7 @@ namespace BMA.EHR.Application.Repositories { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api-key", apiKey); - var _res = await client.SendAsync(request); + var _res = await client.SendAsync(request, combinedCts.Token); if (_res.IsSuccessStatusCode) { var _result = await _res.Content.ReadAsStringAsync(); @@ -109,11 +115,13 @@ namespace BMA.EHR.Application.Repositories } - protected async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey) + public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default) { try { - + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); var json = JsonConvert.SerializeObject(body); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); @@ -122,7 +130,7 @@ namespace BMA.EHR.Application.Repositories { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api-key", apiKey); - var _res = await client.PostAsync(apiPath, stringContent); + var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token); if (_res.IsSuccessStatusCode) { var _result = await _res.Content.ReadAsStringAsync(); @@ -138,10 +146,13 @@ namespace BMA.EHR.Application.Repositories } } - protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey) + protected async Task PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default) { try { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); var json = JsonConvert.SerializeObject(body); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); @@ -150,7 +161,7 @@ namespace BMA.EHR.Application.Repositories { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api-key", apiKey); - var _res = await client.PostAsync(apiPath, stringContent); + var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token); return _res.IsSuccessStatusCode; } } diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index a520f502..1c0741cb 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -280,8 +280,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -297,10 +297,10 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PositionSalaryAmount = p.PositionSalaryAmount ?? 0, ProfileInsignia = p.ProfileInsignia, @@ -409,7 +409,7 @@ namespace BMA.EHR.Application.Repositories var s2_a = (from p in allProfilesByRoot where p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 - && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id && x.InsigniaId.Value == bcpRoyal.Id) .ToList() .Count() == 0) @@ -425,8 +425,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -459,22 +459,22 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() - .Where(x => x.InsigniaId.Value != coinInsignia.Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "เบญจมาภรณ์ช้างเผือก"), FirstRecvInsigniaYear = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault()?.Year, ProfileType = p.ProfileType, MarkDiscipline = p.MarkDiscipline, @@ -555,7 +555,7 @@ namespace BMA.EHR.Application.Repositories var s3 = (from p in allProfilesByRoot where p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 - && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id && x.InsigniaId.Value == jtmRoyal.Id) .ToList() .Count() == 0) @@ -571,8 +571,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") @@ -590,21 +590,21 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() - .Where(x => x.InsigniaId.Value != coinInsignia.Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcmRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount ?? 0, Amount = p.Amount ?? 0, RootId = p.RootId, @@ -794,8 +794,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -811,10 +811,10 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PositionSalaryAmount = p.PositionSalaryAmount ?? 0, ProfileInsignia = p.ProfileInsignia, @@ -923,7 +923,7 @@ namespace BMA.EHR.Application.Repositories var s2 = (from p in allProfilesByRoot where p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 - && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id && x.InsigniaId.Value == jtmRoyal.Id) .ToList() .Count() == 0) @@ -939,8 +939,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -956,21 +956,21 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() - .Where(x => x.InsigniaId.Value != coinInsignia.Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == bcpRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount ?? 0, Amount = p.Amount ?? 0, RootId = p.RootId, @@ -1065,7 +1065,7 @@ namespace BMA.EHR.Application.Repositories var s3 = (from p in allProfilesByRoot where p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 - && (p.ProfileInsignia.Where(x => x.InsigniaId.Value != coinInsignia.Id && + && (p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id && x.InsigniaId.Value == jtcRoyal.Id) .ToList() .Count() == 0) @@ -1081,8 +1081,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -1098,21 +1098,21 @@ namespace BMA.EHR.Application.Repositories : p.ProfileInsignia!.OrderByDescending(x => x.Year).FirstOrDefault()!.InsigniaId.Value, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, IsHigherLevel = IsHigherLevel(p.ProfileInsignia.ToList() - .Where(x => x.InsigniaId.Value != coinInsignia.Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != coinInsignia.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "จัตุรถาภรณ์ช้างเผือก"), FirstRecvInsigniaYear = p.ProfileInsignia == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year) .FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year) - .FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == jtmRoyal.Id).OrderBy(x => x.Year) + .FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -1301,8 +1301,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo ?? "", PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -1311,24 +1311,24 @@ namespace BMA.EHR.Application.Repositories Gender = p.Gender ?? "", LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, ProfileInsignia = p.ProfileInsignia, PositionSalaryAmount = p.PositionSalaryAmount, @@ -1426,8 +1426,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("เบญจมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -1442,28 +1443,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo ?? "", Gender = p.Gender == null ? "" : p.Gender, @@ -1472,7 +1473,7 @@ namespace BMA.EHR.Application.Repositories PositionTypeId = p.PosTypeId, PositionTypeName = p.PosType, IsHigherLevel = IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "เบญจมาภรณ์ช้างเผือก"), @@ -1573,8 +1574,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -1589,28 +1591,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo ?? "", Gender = p.Gender == null ? "" : p.Gender, @@ -1620,12 +1622,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "จัตุรถาภรณ์มงกุฎไทย"), @@ -1719,8 +1721,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("จัตุรถาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -1735,28 +1738,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo ?? "", Gender = p.Gender == null ? "" : p.Gender, @@ -1766,12 +1769,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "จัตุรถาภรณ์ช้างเผือก"), @@ -1972,8 +1975,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -1988,28 +1992,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2019,12 +2023,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ตริตาภรณ์มงกุฎไทย"), @@ -2118,8 +2122,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -2134,28 +2139,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2165,12 +2170,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ตริตาภรณ์ช้างเผือก"), @@ -2180,7 +2185,7 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญงาน").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -2336,8 +2341,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -2352,28 +2358,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2383,12 +2389,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์มงกุฎไทย"), @@ -2398,7 +2404,7 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -2487,8 +2493,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -2503,28 +2510,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2534,12 +2541,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -2549,7 +2556,7 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -2706,8 +2713,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -2722,28 +2730,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2753,12 +2761,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -2768,7 +2776,7 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -2858,8 +2866,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -2874,28 +2883,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -2905,12 +2914,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -2920,14 +2929,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -3019,8 +3028,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -3035,28 +3045,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -3066,12 +3076,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -3081,14 +3091,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -3265,8 +3275,9 @@ namespace BMA.EHR.Application.Repositories where p.PosType == "วิชาการ" && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -3281,28 +3292,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -3312,12 +3323,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ตริตาภรณ์มงกุฎไทย"), @@ -3327,14 +3338,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -3470,8 +3481,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ตริตาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -3486,28 +3498,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -3517,12 +3529,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ตริตาภรณ์ช้างเผือก"), @@ -3532,14 +3544,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -3628,8 +3640,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -3644,28 +3657,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -3675,12 +3688,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์มงกุฎไทย"), @@ -3690,14 +3703,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -3789,8 +3802,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -3805,28 +3819,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year - 5, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year - 5, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -3836,12 +3850,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -3851,14 +3865,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4034,8 +4048,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -4050,28 +4065,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -4081,12 +4096,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -4096,14 +4111,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4175,8 +4190,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -4191,28 +4207,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -4222,12 +4238,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -4238,14 +4254,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ชำนาญการพิเศษ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4409,8 +4425,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -4425,28 +4442,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -4456,12 +4473,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -4471,14 +4488,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4568,8 +4585,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -4584,28 +4602,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -4615,12 +4633,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -4631,14 +4649,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4729,8 +4747,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -4745,28 +4764,28 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -4776,12 +4795,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -4791,14 +4810,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "เชี่ยวชาญ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -4972,8 +4991,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -4988,29 +5008,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -5020,12 +5040,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -5035,14 +5055,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -5139,8 +5159,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .ToList() .Count() == 0) select new @@ -5155,29 +5176,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo == null ? "" : p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -5187,12 +5208,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาวชิรมงกุฎ"), @@ -5202,14 +5223,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -5306,8 +5327,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -5322,29 +5344,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, @@ -5355,12 +5377,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), @@ -5371,12 +5393,12 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -5555,8 +5577,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -5571,29 +5594,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -5603,12 +5626,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -5618,14 +5641,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -5722,8 +5745,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .ToList() .Count() == 0) select new @@ -5738,29 +5762,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -5770,12 +5794,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาวชิรมงกุฎ"), @@ -5785,14 +5809,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "อาวุโส").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -5889,8 +5913,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -5905,29 +5930,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -5937,12 +5962,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), @@ -5952,12 +5977,12 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) .FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ทรงคุณวุฒิ").OrderBy(p => p.Date) - .FirstOrDefault().Date, + .FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -6134,8 +6159,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -6150,29 +6176,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo == null ? "" : p.PosNo, Gender = p.Gender == null ? "" : p.Gender, @@ -6182,12 +6208,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ทวีติยาภรณ์ช้างเผือก"), @@ -6197,12 +6223,12 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -6291,8 +6317,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -6307,29 +6334,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? "" : p.Gender, @@ -6339,12 +6366,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -6354,14 +6381,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "อำนวยการ") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -6519,8 +6546,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -6535,29 +6563,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? "" : p.Gender, @@ -6567,12 +6595,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -6582,14 +6610,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -6680,8 +6708,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -6696,29 +6725,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? "" : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? "" : p.Gender, @@ -6728,12 +6757,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -6743,14 +6772,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -6842,8 +6871,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .ToList() .Count() == 0) select new @@ -6858,29 +6888,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? "" : p.Gender, @@ -6890,12 +6920,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาวชิรมงกุฎ"), @@ -6905,14 +6935,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "อำนวยการ") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7083,8 +7113,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .ToList() .Count() == 0) select new @@ -7099,29 +7130,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7131,12 +7162,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์มงกุฎไทย"), @@ -7146,14 +7177,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ทวีติยาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7244,8 +7275,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -7260,29 +7292,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7292,12 +7324,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -7307,14 +7339,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7405,8 +7437,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .ToList() .Count() == 0) select new @@ -7421,29 +7454,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7453,12 +7486,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาวชิรมงกุฎ"), @@ -7468,14 +7501,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "ต้น" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7617,8 +7650,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -7633,29 +7667,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7665,12 +7699,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "ประถมาภรณ์ช้างเผือก"), @@ -7680,14 +7714,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์มงกุฎไทย")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7784,8 +7818,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .ToList() .Count() == 0) select new @@ -7800,29 +7835,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7832,12 +7867,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาวชิรมงกุฎ"), @@ -7847,14 +7882,14 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : p.ProfileInsignia - .Where(x => x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("ประถมาภรณ์ช้างเผือก")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -7951,8 +7986,9 @@ namespace BMA.EHR.Application.Repositories && p.ProfileInsignia != null && p.ProfileInsignia.Count > 0 && (p.ProfileInsignia.Where(x => - x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id && - x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก").Id) + x.InsigniaId.HasValue && + x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id && + x.InsigniaId.Value == GetInsigniaByName("มหาปรมาภรณ์ช้างเผือก")?.Id) .ToList() .Count() == 0) select new @@ -7967,29 +8003,29 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix == null ? null : p.Prefix)}{p.FirstName} {p.LastName}", Position = p.Position == null ? null : p.Position, Rank = p.PosLevel ?? "", - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryPosition = p.PositionSalaryAmount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PosNo = p.PosNo, Gender = p.Gender == null ? null : p.Gender, @@ -7999,12 +8035,12 @@ namespace BMA.EHR.Application.Repositories PositionTypeName = p.PosType, IsHigherLevel = p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? true : IsHigherLevel(p.ProfileInsignia - .Where(x => x.InsigniaId.Value != - GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != + GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .OrderByDescending(x => x.Year) .FirstOrDefault(), "มหาปรมาภรณ์ช้างเผือก"), @@ -8014,12 +8050,12 @@ namespace BMA.EHR.Application.Repositories p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") .OrderBy(p => p.Date).FirstOrDefault() == null ? null : p.ProfileSalary.Where(x => x.PositionLevel == "สูง" && x.PositionType == "บริหาร") - .OrderBy(p => p.Date).FirstOrDefault().Date, + .OrderBy(p => p.Date).FirstOrDefault()?.Date, FirstRecvInsigniaYear = p.ProfileInsignia.Count == 0 ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) .OrderBy(x => x.Year).FirstOrDefault() == null ? 0 : - p.ProfileInsignia.Where(x => x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ").Id) - .OrderBy(x => x.Year).FirstOrDefault().Year, + p.ProfileInsignia.Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value == GetInsigniaByName("มหาวชิรมงกุฎ")?.Id) + .OrderBy(x => x.Year).FirstOrDefault()?.Year, PositionSalaryAmount = p.PositionSalaryAmount, Amount = p.Amount, RootId = p.RootId, @@ -8179,144 +8215,146 @@ namespace BMA.EHR.Application.Repositories if (type.ToLower().Trim() == "officer") { var allOfficerProfilesByRoot = (await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken)); - - // calculate ตามแต่ละชั้น - var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level9_1 = - allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type2_level9_2 = - allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List(); - var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List(); - - - // union result - foreach (var r in type_coin) + if (allOfficerProfilesByRoot != null) { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type4_level11) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type4_level10) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type3_level11) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type3_level10) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level9_2) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level9_1) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level8) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level7) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level6) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type2_level5) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type1_level4) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type1_level3) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type1_level2) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - foreach (var r in type1_level1) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } - - // ย้ายที่ตามที่ มอสแจ้ง - if (period.Round != 1) - { - var insigniaIdList = await _dbContext.Set() - .Include(x => x.InsigniaType) - .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย") - .Select(x => x.Id) - .ToListAsync(); + // calculate ตามแต่ละชั้น + var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type1_level1 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type1_level2 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level2(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type1_level3 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level3(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type1_level4 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type1_Level4(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level5 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level5(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level6 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level6(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level7 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level7(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level8 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level8(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level9_1 = + allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_1(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type2_level9_2 = + allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type2_Level9_2(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type3_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type3_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type3_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type4_level10 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level10(periodId, ocId, allOfficerProfilesByRoot) : new List(); + var type4_level11 = allOfficerProfilesByRoot.Count() > 0 ? await GetInsigniaCandidate_Type4_Level11(periodId, ocId, allOfficerProfilesByRoot) : new List(); - result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList(); + // union result + foreach (var r in type_coin) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type4_level11) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type4_level10) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type3_level11) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type3_level10) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level9_2) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level9_1) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level8) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level7) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level6) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type2_level5) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type1_level4) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type1_level3) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type1_level2) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in type1_level1) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + // ย้ายที่ตามที่ มอสแจ้ง + if (period.Round != 1) + { + var insigniaIdList = await _dbContext.Set() + .Include(x => x.InsigniaType) + .Where(x => x.InsigniaType!.Name == "ชั้นสายสะพาย") + .Select(x => x.Id) + .ToListAsync(); + + + result_candidate = result_candidate.Where(x => insigniaIdList.Contains(x.RequestInsignia.Id)).ToList(); + } } } else if (type.ToLower().Trim() == "employee") @@ -8327,31 +8365,34 @@ namespace BMA.EHR.Application.Repositories allEmployeeProfileByRoot = (await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken)); } - var type_coin = allEmployeeProfileByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allEmployeeProfileByRoot) : new List(); - - var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List(); - var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List(); - - // union result - foreach (var r in type_coin) + if (allEmployeeProfileByRoot != null) { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } + var type_coin = allEmployeeProfileByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allEmployeeProfileByRoot) : new List(); - foreach (var r in employee_type2) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); - } + var employee_type1 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type1(periodId, ocId, allEmployeeProfileByRoot) : new List(); + var employee_type2 = allEmployeeProfileByRoot.Count() > 0 ? await GetEmployeeInsignia_Type2(periodId, ocId, allEmployeeProfileByRoot) : new List(); - foreach (var r in employee_type1) - { - var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); - if (old == null) - result_candidate.Add(r); + // union result + foreach (var r in type_coin) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in employee_type2) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } + + foreach (var r in employee_type1) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } } } else @@ -8571,7 +8612,7 @@ namespace BMA.EHR.Application.Repositories if (period == null) throw new Exception(GlobalMessages.CoinPeriodNotFound); - var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint != null) + var inst_profile = allProfilesByRoot.Where(x => x.DateAppoint.HasValue && x.DateAppoint != null) .Select(p => new { ProfileId = p.Id, @@ -8584,8 +8625,8 @@ namespace BMA.EHR.Application.Repositories FullName = $"{(p.Prefix ?? "")}{p.FirstName} {p.LastName}", Position = p.Position ?? "", Rank = p.PosLevel ?? "", - ProfileDateAppoint = p.DateAppoint.Value, - GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + ProfileDateAppoint = p.DateAppoint!.Value, + GovAge = p.DateStart!.Value.CalculateGovAgeStr(0, 0), PosNo = p.PosNo, PositionLevelId = p.PosLevelId, PositionLevelName = p.PosLevel, @@ -8594,24 +8635,24 @@ namespace BMA.EHR.Application.Repositories Gender = p.Gender ?? "", LastInsignia = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? "" : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().Insignia, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.Insignia, LastInsigniaId = p.ProfileInsignia == null || p.ProfileInsignia.Count == 0 ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) .FirstOrDefault() == null ? Guid.Empty : p.ProfileInsignia - .Where(x => x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา").Id) - .OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId, + .Where(x => x.InsigniaId.HasValue && x.InsigniaId.Value != GetInsigniaByName("เหรียญจักรพรรดิมาลา")?.Id) + .OrderByDescending(x => x.Year).FirstOrDefault()?.InsigniaId, Salary = p.Amount, SalaryCondition = p.ProfileSalary == null || p.ProfileSalary.Count == 0 ? 0 : - p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) + p.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) .OrderByDescending(x => x.Order).FirstOrDefault() != null ? p.ProfileSalary - .Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(period.Year, 4, 29)) - .OrderByDescending(x => x.Order).FirstOrDefault().Amount : + .Where(x => x.Date != null).Where(x => x.Date.HasValue && x.Date.Value <= new DateTime(period.Year, 4, 29)) + .OrderByDescending(x => x.Order).FirstOrDefault()?.Amount : p.Amount, PositionSalaryAmount = p.PositionSalaryAmount, ProfileInsignia = p.ProfileInsignia, diff --git a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs index 5fbbb8a1..2e550d71 100644 --- a/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/GenericLeaveRepository.cs @@ -2,8 +2,11 @@ using BMA.EHR.Domain.Models.Base; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; using System.IO.Pipes; +using System.Net.Http.Headers; using System.Security.Claims; +using System.Text; namespace BMA.EHR.Application.Repositories.Leaves { @@ -43,6 +46,38 @@ namespace BMA.EHR.Application.Repositories.Leaves #region " Methods " + public async Task PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey, CancellationToken cancellationToken = default) + { + try + { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); + var json = JsonConvert.SerializeObject(body); + var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); + //stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api-key", apiKey); + var _res = await client.PostAsync(apiPath, stringContent, combinedCts.Token); + if (_res.IsSuccessStatusCode) + { + var _result = await _res.Content.ReadAsStringAsync(); + + return _result; + } + return string.Empty; + } + } + catch + { + throw; + } + } + + public virtual async Task> GetAllAsync() { return await _dbSet.ToListAsync(); @@ -68,6 +103,24 @@ namespace BMA.EHR.Application.Repositories.Leaves return entity; } + public virtual async Task> AddRangeAsync(List entities) + { + foreach (var entity in entities) + { + if (entity is EntityBase) + { + (entity as EntityBase).CreatedUserId = UserId ?? ""; + (entity as EntityBase).CreatedFullName = FullName ?? "System Administrator"; + (entity as EntityBase).CreatedAt = DateTime.Now; + } + } + + await _dbSet.AddRangeAsync(entities); + await _dbContext.SaveChangesAsync(); + + return entities; + } + public virtual async Task UpdateAsync(T entity) { if (entity is EntityBase) diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs index 575a85bb..35b18090 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveBeginingRepository.cs @@ -79,7 +79,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public async Task UpdateLeaveUsageAsync(int year, Guid typeId, Guid userId, double day) { - var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (pf == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -98,9 +99,32 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests await _dbContext.SaveChangesAsync(); } + public async Task UpdateLeaveCountAsync(int year, Guid typeId, Guid userId, int count) + { + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); + if (pf == null) + { + throw new Exception(GlobalMessages.DataNotFound); + } + + var data = await _dbContext.Set() + .Include(x => x.LeaveType) + .FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id); + + if (data == null) + { + throw new Exception(GlobalMessages.DataNotFound); + } + data.LeaveCount += count; + + await _dbContext.SaveChangesAsync(); + } + public async Task GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId) { - var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (pf == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -125,7 +149,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var prevRemain = 0.0; if (prev != null) { - prevRemain = prev.LeaveDays - prev.LeaveDaysUsed; + prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0); } if (govAge >= 180) @@ -191,7 +215,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var prevRemain = 0.0; if (prev != null) { - prevRemain = prev.LeaveDays - prev.LeaveDaysUsed; + prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0); } if (govAge >= 180) @@ -238,7 +262,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public async Task GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId) { - var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (pf == null) { return null; @@ -263,7 +288,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var prevRemain = 0.0; if (prev != null) { - prevRemain = prev.LeaveDays - prev.LeaveDaysUsed; + prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0); } if (govAge >= 180) @@ -351,7 +376,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var prevRemain = 0.0; if (prev != null) { - prevRemain = prev.LeaveDays - prev.LeaveDaysUsed; + prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0); } if (govAge >= 180) @@ -413,5 +438,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public string LastName { get; set; } = string.Empty; public DateTime? DateStart { get; set; } = null; + + public DateTime? DateAppoint { get; set; } = null; } } diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs index e0e519e8..dee940fe 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs @@ -11,6 +11,8 @@ using Microsoft.Extensions.Configuration; using System.IO.Compression; using System.Net.Http.Headers; using System.Net.Http.Json; +using BMA.EHR.Application.Repositories.Leaves.TimeAttendants; +using BMA.EHR.Domain.Models.Leave.TimeAttendants; namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests { @@ -29,6 +31,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests private readonly MinIOLeaveService _minIOService; private readonly LeaveBeginningRepository _leaveBeginningRepository; + private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository; private readonly string URL = string.Empty; @@ -44,7 +47,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests EmailSenderService emailSenderService, IApplicationDBContext appDbContext, MinIOLeaveService minIOService, - LeaveBeginningRepository leaveBeginningRepository) : base(dbContext, httpContextAccessor) + LeaveBeginningRepository leaveBeginningRepository, + ProcessUserTimeStampRepository processUserTimeStampRepository) : base(dbContext, httpContextAccessor) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; @@ -58,6 +62,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests Console.WriteLine($"URL : {URL}"); _minIOService = minIOService; _leaveBeginningRepository = leaveBeginningRepository; + _processUserTimeStampRepository = processUserTimeStampRepository; } #endregion @@ -253,7 +258,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public async Task> GetLeaveRequestByYearAsync(int year, Guid userId) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { @@ -306,11 +312,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests rawData = rawData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)); } - else if (role == "PARENT") - { - rawData = rawData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); - } + // else if (role == "PARENT") + // { + // rawData = rawData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); + // } else if (role == "NORMAL") { rawData = rawData @@ -353,7 +359,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var rawData = _dbContext.Set().AsNoTracking() .Include(x => x.Type) .Where(x => x.LeaveStatus != "DRAFT") - .OrderByDescending(x => x.CreatedAt) + .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt)) .AsQueryable(); if (year != 0) @@ -379,7 +385,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var rawData = _dbContext.Set().AsNoTracking() .Include(x => x.Type) .Where(x => x.LeaveStatus != "DRAFT") - .OrderByDescending(x => x.CreatedAt) + .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt)) .AsQueryable(); // fix issue : 1830 if (year != 0) @@ -420,11 +426,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests rawData = rawData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)); } - else if (role == "PARENT") - { - rawData = rawData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); - } + // else if (role == "PARENT") + // { + // rawData = rawData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); + // } else if (role == "NORMAL") { rawData = rawData @@ -446,7 +452,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests .Include(x => x.Type) .Where(x => keycloakIdList.Contains(x.KeycloakUserId)) .Where(x => x.LeaveStatus != "DRAFT") - .OrderByDescending(x => x.CreatedAt) + .OrderByDescending(x =>(x.DateSendLeave ?? x.CreatedAt)) .AsQueryable(); if (year != 0) @@ -495,7 +501,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests public async Task GetSumLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year) { - var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(keycloakUserId, AccessToken); + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(keycloakUserId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(keycloakUserId, AccessToken); if (pf == null) throw new Exception(GlobalMessages.DataNotFound); @@ -520,7 +527,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE") .ToListAsync(); - return data.Sum(x => x.LeaveTotal) + (beginningLeave == null ? 0 : beginningLeave.LeaveDaysUsed); + return data.Sum(x => x.LeaveTotal) + (beginningLeave == null ? 0 : (beginningLeave.LeaveDaysUsed ?? 0.0)); } //public async Task GetSumApproveLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year) @@ -556,6 +563,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var data = await _dbContext.Set().AsQueryable().AsNoTracking() .Include(x => x.Type) .Where(x => x.LeaveStartDate.Date < beforeDate.Date) + //.Where(x => x.CreatedAt < beforeDate) .Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.Type.Id == leaveTypeId) .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") @@ -566,6 +574,22 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests return data; } + public async Task GetLastLeaveRequestByTypeForUserAsync2(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + //.Where(x => x.LeaveStartDate.Date < beforeDate.Date) + .Where(x => (x.DateSendLeave ?? x.CreatedAt) < beforeDate) + .Where(x => x.KeycloakUserId == keycloakUserId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") + //.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE") + .OrderByDescending(x => (x.DateSendLeave ?? x.CreatedAt)) + .FirstOrDefaultAsync(); + + return data; + } + public async Task> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status, string role, string? nodeId, int? node) { var rawData = _dbContext.Set().AsNoTracking() @@ -608,11 +632,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests rawData = rawData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)); } - else if (role == "PARENT") - { - rawData = rawData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); - } + // else if (role == "PARENT") + // { + // rawData = rawData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null); + // } else if (role == "NORMAL") { rawData = rawData @@ -631,7 +655,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests { try { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? ""); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken ?? ""); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken ?? ""); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -656,6 +681,9 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests thisYear = thisYear + 1; } await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal); + // update leave count ลดลง 1 ครั้ง + await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1); + var _baseAPI = _configuration["API"]; var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{data.Id}"; @@ -704,7 +732,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests throw new Exception(GlobalMessages.DataNotFound); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? ""); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? ""); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? ""); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -729,6 +758,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests } await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal); + // update leave count ลดลง 1 ครั้ง + await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1); var _baseAPI = _configuration["API"]; var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{rawData.Id}"; @@ -790,7 +821,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests throw new Exception(GlobalMessages.DataNotFound); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? ""); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? ""); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken ?? ""); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -877,6 +909,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests rawData.LeaveStatus = "NEW"; + rawData.DateSendLeave = DateTime.Now; // Update วันที่ยื่นลาเป็นวันที่ปัจจุบัน //rawData.ApproveStep = "st2"; await UpdateAsync(rawData); @@ -1214,7 +1247,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests } else { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -1235,6 +1269,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests // TODO : Update ไปตาราง beginning await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, rawData.LeaveTotal); + // update leave count เพิ่มขึ้น 1 ครั้ง + await _leaveBeginningRepository.UpdateLeaveCountAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, 1); var _baseAPI = _configuration["API"]; @@ -1258,6 +1294,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests status = "approve", reason = rawData.LeaveDetail, leaveId = rawData.Id, + leaveSubTypeName = rawData.LeaveSubTypeName, + coupleDayLevelCountry = rawData.CoupleDayLevelCountry, }); // var _result = await _res.Content.ReadAsStringAsync(); } @@ -1281,6 +1319,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests status = "approve", reason = rawData.LeaveDetail, leaveId = rawData.Id, + leaveSubTypeName = rawData.LeaveSubTypeName, + coupleDayLevelCountry = rawData.CoupleDayLevelCountry, }); } } @@ -1290,9 +1330,68 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests } await _appDbContext.SaveChangesAsync(); - // insert to process timestamp - - + // ปรับสถานะการลงเวลา + if (rawData.LeaveStartDate.Date == rawData.LeaveEndDate.Date) + { + var processCheckIn = await _dbContext.Set() + .Where(x => x.KeycloakUserId == rawData.KeycloakUserId) + .Where(x => x.CheckIn.Date == rawData.LeaveStartDate.Date) + .FirstOrDefaultAsync(); + + + if (processCheckIn is not null) + { + switch (rawData.LeaveRange.Trim().ToUpper()) + { + case "MORNING": + processCheckIn.CheckInStatus = "NORMAL"; + break; + case "AFTERNOON": + processCheckIn.CheckOutStatus = "NORMAL"; + break; + case "ALL": + processCheckIn.CheckInStatus = "NORMAL"; + processCheckIn.CheckOutStatus = "NORMAL"; + break; + default: + break; + } + } + await _dbContext.SaveChangesAsync(); + } + else + { + var from = rawData.LeaveStartDate.Date; + var to = rawData.LeaveEndDate.Date; + for (var day = from.Date; day <= to.Date; day = day.AddDays(1)) + { + var processCheckIn = await _dbContext.Set() + .Where(x => x.KeycloakUserId == rawData.KeycloakUserId) + .Where(x => x.CheckIn.Date == day.Date) + .FirstOrDefaultAsync(); + + if (processCheckIn is not null) + { + switch (rawData.LeaveRange.Trim().ToUpper()) + { + case "MORNING": + processCheckIn.CheckInStatus = "NORMAL"; + break; + case "AFTERNOON": + processCheckIn.CheckOutStatus = "NORMAL"; + break; + case "ALL": + processCheckIn.CheckInStatus = "NORMAL"; + processCheckIn.CheckOutStatus = "NORMAL"; + break; + default: + break; + } + } + } + await _dbContext.SaveChangesAsync(); + } + // Send Noti var noti = new Notification { @@ -1377,7 +1476,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests } else { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -1450,7 +1550,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests KeycloakUserId = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value, LeaveTypeId = b.LeaveTypeId, LeaveTypeCode = b.LeaveType!.Code, - SumLeaveDay = b.LeaveDaysUsed + SumLeaveDay = b.LeaveDaysUsed ?? 0.0 }); } } @@ -1664,10 +1764,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests { data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList(); } - else if (role == "PARENT") - { - data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => @@ -1683,7 +1783,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "BROTHER" || role == "PARENT") { data = data - .Where(x => nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) : nodeByReq == 3 ? x.Child3Id == Guid.Parse(nodeIdByReq) : nodeByReq == 2 ? x.Child2Id == Guid.Parse(nodeIdByReq) : nodeByReq == 1 ? x.Child1Id == Guid.Parse(nodeIdByReq) : nodeByReq == 0 ? x.RootId == Guid.Parse(nodeIdByReq) : true) + .Where(x => nodeByReq == 4 ? x.Child4DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 3 ? x.Child3DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 2 ? x.Child2DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 1 ? x.Child1DnaId == Guid.Parse(nodeIdByReq) : nodeByReq == 0 ? x.RootDnaId == Guid.Parse(nodeIdByReq) : true) .ToList(); } // รายงานการลางานจำแนกตามเพศฯ Template ให้หน่วยงานแสดงก่อนส่วนราชการ @@ -1824,6 +1924,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests .Include(x => x.Type) .Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.Type.Id == leaveTypeId) + //.Where(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") .ToListAsync(); @@ -1834,6 +1935,119 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests return 0; } + public async Task GetSumApproveLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.KeycloakUserId == keycloakUserId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") + .ToListAsync(); + + if (data.Count > 0) + return data.Sum(x => x.LeaveTotal); + else + return 0; + } + + public async Task GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.ProfileId == profileId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") + .ToListAsync(); + + if (data.Count > 0) + return data.Sum(x => x.LeaveTotal); + else + return 0; + } + + public async Task GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.ProfileId == profileId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") + .ToListAsync(); + + return data.Count; + } + + public async Task GetSumApproveLeaveCountByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.KeycloakUserId == keycloakUserId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") + .ToListAsync(); + + return data.Count; + } + + /// + /// วันลาที่สร้างแบบร่างยังไม่ได้ยื่น + /// + /// + /// + /// + /// + /// + public async Task GetSumDraftLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.KeycloakUserId == keycloakUserId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt).Date >= startDate + && (x.DateSendLeave ?? x.CreatedAt).Date < endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => x.LeaveStatus == "DRAFT") + .ToListAsync(); + + if (data.Count > 0) + return data.Sum(x => x.LeaveTotal); + else + return 0; + } + + /// + /// วันลาที่ยื่นแล้วรอพิจารณา + /// + /// + /// + /// + /// + /// + public async Task GetSumNewLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate) + { + var data = await _dbContext.Set().AsQueryable().AsNoTracking() + .Include(x => x.Type) + .Where(x => x.KeycloakUserId == keycloakUserId) + .Where(x => x.Type.Id == leaveTypeId) + .Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) < endDate)) + //.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + .Where(x => (x.LeaveStatus == "NEW" || x.LeaveStatus == "PENDING")) + .ToListAsync(); + + if (data.Count > 0) + return data.Sum(x => x.LeaveTotal); + else + return 0; + } + public async Task GetCountApproveLeaveByTypeAndRangeForUser(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate) { var data = await _dbContext.Set().AsQueryable().AsNoTracking() @@ -1841,6 +2055,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests .Where(x => x.KeycloakUserId == keycloakUserId) .Where(x => x.Type.Id == leaveTypeId) .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date) + //.Where(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate) .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING") .ToListAsync(); diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs index 12f51207..d4bc0ea8 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/AdditionalCheckRequestRepository.cs @@ -74,7 +74,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants await base.AddAsync(entity); var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? ""); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? ""); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken ?? ""); // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969 // send noti + inbox + mail @@ -144,7 +145,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants } } - public async Task> GetAdditionalCheckRequestsByAdminRole(int year, int month, string role, string nodeId, int? node) + public async Task> GetAdditionalCheckRequestsByAdminRole(int year, int month, string role, string nodeId, int? node, string? keyword) { try { @@ -152,6 +153,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants .Where(x => (x.CheckDate.Year == year && x.CheckDate.Month == month)) .OrderByDescending(x => x.CreatedAt.Date) .ToListAsync(); + + if (!string.IsNullOrEmpty(keyword)) + { + data = data.Where(x => + ( + (x.Prefix ?? "") + (x.FirstName ?? "") + " " + (x.LastName ?? "")).Contains(keyword) + || x.Description.Contains(keyword) + + ).ToList(); + } + if (role == "OWNER") { node = null; @@ -173,11 +185,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants data = data .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList(); } - else if (role == "PARENT") - { - data = data - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList(); - } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => @@ -201,6 +213,79 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants } } + public async Task> GetAdditionalCheckRequestsByAdminRole2(DateTime startDate, DateTime endDate, string role, string nodeId, int? node, string? keyword, string? status) + { + try + { + var data = await _dbContext.Set().AsQueryable() + .Where(x => (x.CheckDate.Date >= startDate.Date && x.CheckDate.Date <= endDate.Date)) + .OrderByDescending(x => x.CreatedAt.Date) + .ToListAsync(); + + if(!string.IsNullOrEmpty(status)) + data = data.Where(x => x.Status == status).ToList(); + + + if (!string.IsNullOrEmpty(keyword)) + { + data = data.Where(x => + ( + (x.Prefix ?? "") + (x.FirstName ?? "") + " " + (x.LastName ?? "")).Contains(keyword) + || x.Description.Contains(keyword) + + ).ToList(); + } + + if (role == "OWNER") + { + node = null; + } + if (role == "OWNER" || role == "CHILD") + { + data = data + .Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))) + .ToList(); + } + else if (role == "BROTHER") + { + data = data + .Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))) + .ToList(); + } + else if (role == "ROOT") + { + data = data + .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList(); + } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null && x.Child1DnaId != Guid.Empty).ToList(); + // } + else if (role == "NORMAL") + { + data = data.Where(x => + node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) && + (x.Child1DnaId == Guid.Empty || x.Child1DnaId == null) : + node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && + (x.Child2DnaId == Guid.Empty || x.Child2DnaId == null) : + node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && + (x.Child3DnaId == Guid.Empty || x.Child3DnaId == null) : + node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && + (x.Child4DnaId == Guid.Empty || x.Child4DnaId == null) : + node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : + true + ).ToList(); + } + return data; + } + catch + { + throw; + } + } + + #endregion } } diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs new file mode 100644 index 00000000..302bdd12 --- /dev/null +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/CheckInJobStatusRepository.cs @@ -0,0 +1,135 @@ +using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Domain.Models.Leave.TimeAttendants; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants +{ + public class CheckInJobStatusRepository : GenericLeaveRepository + { + #region " Fields " + + private readonly ILeaveDbContext _dbContext; + + #endregion + + #region " Constructor and Destructor " + + public CheckInJobStatusRepository(ILeaveDbContext dbContext, + IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) + { + _dbContext = dbContext; + } + + #endregion + + #region " Methods " + + /// + /// ดึงข้อมูล Job Status จาก TaskId + /// + public async Task GetByTaskIdAsync(Guid taskId) + { + var data = await _dbContext.Set() + .Where(x => x.TaskId == taskId) + .FirstOrDefaultAsync(); + + return data; + } + + /// + /// ดึงข้อมูล Job Status จาก UserId และสถานะ + /// + public async Task> GetByUserIdAndStatusAsync(Guid userId, string status) + { + var data = await _dbContext.Set() + .Where(x => x.KeycloakUserId == userId && x.Status == status) + .OrderByDescending(x => x.CreatedDate) + .ToListAsync(); + + return data; + } + + /// + /// ดึงข้อมูล Job Status ที่ยัง pending หรือ processing + /// + public async Task> GetPendingOrProcessingJobsAsync(Guid userId) + { + var data = await _dbContext.Set() + .Where(x => x.KeycloakUserId == userId && + (x.Status == "PENDING" || x.Status == "PROCESSING")) + //.OrderByDescending(x => x.CreatedDate) + .ToListAsync(); + + return data; + } + + /// + /// อัปเดตสถานะเป็น Processing + /// + public async Task UpdateToProcessingAsync(Guid taskId) + { + var job = await GetByTaskIdAsync(taskId); + if (job != null) + { + job.Status = "PROCESSING"; + job.ProcessingDate = DateTime.Now; + await UpdateAsync(job); + } + return job!; + } + + /// + /// อัปเดตสถานะเป็น Completed + /// + public async Task UpdateToCompletedAsync(Guid taskId, string? additionalData = null) + { + var job = await GetByTaskIdAsync(taskId); + if (job != null) + { + job.Status = "COMPLETED"; + job.CompletedDate = DateTime.Now; + if (!string.IsNullOrEmpty(additionalData)) + { + job.AdditionalData = additionalData; + } + await UpdateAsync(job); + } + return job!; + } + + /// + /// อัปเดตสถานะเป็น Failed + /// + public async Task UpdateToFailedAsync(Guid taskId, string errorMessage) + { + var job = await GetByTaskIdAsync(taskId); + if (job != null) + { + job.Status = "FAILED"; + job.CompletedDate = DateTime.Now; + job.ErrorMessage = errorMessage; + await UpdateAsync(job); + } + return job!; + } + + /// + /// ล้างข้อมูล Job Status ที่เก่าเกิน X วัน + /// + public async Task CleanupOldJobsAsync(int daysOld = 30) + { + var cutoffDate = DateTime.Now.AddDays(-daysOld); + var oldJobs = await _dbContext.Set() + .Where(x => x.CreatedDate < cutoffDate) + .ToListAsync(); + + _dbContext.Set().RemoveRange(oldJobs); + await _dbContext.SaveChangesAsync(); + + return oldJobs.Count; + } + + #endregion + } +} diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs index 2db889ac..e96c35a9 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/DutyTimeRepository.cs @@ -61,9 +61,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return await _dbContext.Set().Where(x => x.IsActive).ToListAsync(); } - public async Task GetDefaultAsync() + public async Task GetDefaultAsync(CancellationToken cancellationToken = default) { - return await _dbContext.Set().Where(x => x.IsDefault).FirstOrDefaultAsync(); + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); + return await _dbContext.Set().Where(x => x.IsDefault).FirstOrDefaultAsync(combinedCts.Token); } #endregion diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs new file mode 100644 index 00000000..5e9944ad --- /dev/null +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/LeaveProcessJobStatusRepository.cs @@ -0,0 +1,795 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Text.Json; +using System.IO; +using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Application.Repositories.Leaves.LeaveRequests; +using BMA.EHR.Application.Repositories.MetaData; +using BMA.EHR.Application.Responses.Profiles; +using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Models.Leave.TimeAttendants; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; + +namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants +{ + public class LeaveProcessJobStatusRepository: GenericLeaveRepository + { + #region " Fields " + + private readonly ILeaveDbContext _dbContext; + private readonly IHttpContextAccessor _httpContextAccessor; + private readonly UserProfileRepository _userProfileRepository; + private readonly HolidayRepository _holidayRepository; + private readonly DutyTimeRepository _dutyTimeRepository; + private readonly UserDutyTimeRepository _userDutyTimeRepository; + private readonly ProcessUserTimeStampRepository _processUserTimeStampRepository; + private readonly LeaveRequestRepository _leaveRequestRepository; + private readonly IConfiguration _configuration; + private readonly IWebHostEnvironment _env; + + #endregion + + #region " Constructor and Destructor " + + public LeaveProcessJobStatusRepository(ILeaveDbContext dbContext, + IHttpContextAccessor httpContextAccessor, + UserProfileRepository userProfileRepository, + HolidayRepository holidayRepository, + DutyTimeRepository dutyTimeRepository, + UserDutyTimeRepository userDutyTimeRepository, + ProcessUserTimeStampRepository processUserTimeStampRepository, + LeaveRequestRepository leaveRequestRepository, + IConfiguration configuration, + IWebHostEnvironment env) : base(dbContext, httpContextAccessor) + { + _dbContext = dbContext; + _httpContextAccessor = httpContextAccessor; + _userProfileRepository = userProfileRepository; + _holidayRepository = holidayRepository; + _configuration = configuration; + _leaveRequestRepository = leaveRequestRepository; + _dutyTimeRepository = dutyTimeRepository; + _userDutyTimeRepository = userDutyTimeRepository; + _processUserTimeStampRepository = processUserTimeStampRepository; + _env = env; + } + + #endregion + + #region " Methods " + + /// + /// ดึงข้อมูล Job Status จาก TaskId + /// + public async Task GetByTaskIdAsync(Guid id) + { + var data = await _dbContext.Set() + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + + return data; + } + + /// + /// ดึงข้อมูล Job Status จาก UserId และสถานะ + /// + public async Task> GetByUserIdAndStatusAsync(Guid userId, string status) + { + var data = await _dbContext.Set() + .Where(x => x.CreatedUserId == userId.ToString("D") && x.Status == status) + .OrderByDescending(x => x.CreatedDate) + .ToListAsync(); + + return data; + } + + /// + /// ดึงข้อมูล Job Status จาก UserId + /// + public async Task> GetByUserIdAsync(Guid userId) + { + var data = await _dbContext.Set() + .Where(x => x.CreatedUserId == userId.ToString("D")) + .OrderByDescending(x => x.CreatedDate) + .ToListAsync(); + + return data; + } + + /// + /// ดึงข้อมูล Job Status ที่ยัง pending หรือ processing + /// + public async Task> GetPendingOrProcessingJobsAsync(Guid userId) + { + var data = await _dbContext.Set() + .Where(x => x.CreatedUserId == userId.ToString("D") && + (x.Status == "PENDING" || x.Status == "PROCESSING")) + //.OrderByDescending(x => x.CreatedDate) + .ToListAsync(); + + return data; + } + + public async Task> GetPendingJobsAsync() + { + var data = await _dbContext.Set() + .Where(x => x.Status == "PENDING") + .ToListAsync(); + + return data; + } + + /// + /// อัปเดตสถานะเป็น Processing + /// + public async Task UpdateToProcessingAsync(Guid id) + { + var job = await GetByTaskIdAsync(id); + if (job != null) + { + job.Status = "PROCESSING"; + job.ProcessingDate = DateTime.Now; + await UpdateAsync(job); + } + return job!; + } + + /// + /// อัปเดตสถานะเป็น Completed + /// + public async Task UpdateToCompletedAsync(Guid id, string? additionalData = null) + { + var job = await GetByTaskIdAsync(id); + if (job != null) + { + job.Status = "COMPLETED"; + job.CompletedDate = DateTime.Now; + await UpdateAsync(job); + } + return job!; + } + + /// + /// อัปเดตสถานะเป็น Failed + /// + public async Task UpdateToFailedAsync(Guid id, string errorMessage) + { + var job = await GetByTaskIdAsync(id); + if (job != null) + { + job.Status = "FAILED"; + job.CompletedDate = DateTime.Now; + job.ErrorMessage = errorMessage; + await UpdateAsync(job); + } + return job!; + } + + public async Task ProcessTaskAsync(Guid rootDnaId, DateTime? startDate, DateTime? endDate) + { + + var profiles = new List(); + var dateStart = startDate?.Date ?? DateTime.Now.Date; + var dateEnd = endDate?.Date ?? DateTime.Now.Date; + + var holidays = await _holidayRepository.GetHolidayAsync(dateStart, dateEnd); + var weekend = _holidayRepository.GetWeekEnd(dateStart, dateEnd); + var excludeDates = holidays.Union(weekend).ToList(); + + var dateList = new List(); + for (DateTime i = dateStart; i <= dateEnd; i = i.AddDays(1)) + { + if (holidays.Contains(i)) + { + var d = await _holidayRepository.GetHolidayAsync(i); + dateList.Add(new LoopDate + { + date = i, + isHoliday = true, + isWeekEnd = false, + dateRemark = d + }); + } + else if (weekend.Contains(i)) + { + dateList.Add(new LoopDate + { + date = i, + isHoliday = true, + isWeekEnd = false, + dateRemark = "วันหยุด" + }); + } + else + { + dateList.Add(new LoopDate + { + date = i, + isHoliday = false, + isWeekEnd = false, + dateRemark = "" + }); + } + } + + var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (defaultRound == null) + { + throw new Exception("ไม่พบรอบการลงเวลา Default"); + } + + var employees = new List(); + + foreach (var dd in dateList.Where(x => !x.isHoliday && !x.isWeekEnd)) + { + profiles = await _userProfileRepository.GetAllOfficerByRootDnaId(rootDnaId.ToString(),dd.date); + foreach (var p in profiles) + { + var count = 1; + var keycloakUserId = p.Keycloak ?? Guid.Empty; + + var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd.date); + + var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; + + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date); + var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + + var duty = userRound ?? defaultRound; + + // check วันลาของแต่ละคน + var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd.date); + var remarkStr = string.Empty; + var status = string.Empty; + var stampType = string.Empty; + var stampAmount = 0.0; + + if (leaveReq != null) + { + switch (leaveReq.Type.Code.ToUpper()) + { + case "LV-001": + case "LV-002": + case "LV-005": + remarkStr += leaveReq.Type.Name; + var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper(); + + if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + + + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRangeEnd == "MORNING") + // remarkStr += "ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += "ครึ่งวันบ่าย"; + + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange != leaveRangeEnd) + { + if (leaveRangeEnd == "MORNING") + remarkStr += " - ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += " - ครึ่งวันบ่าย"; + } + } + else + { + if(dd.date == leaveReq.LeaveStartDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else if(dd.date == leaveReq.LeaveEndDate.Date) + { + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRangeEnd == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + else + remarkStr += "เต็มวัน"; + } + else + { + remarkStr += "เต็มวัน"; + } + } + + + break; + default: + remarkStr += leaveReq.Type.Name; + break; + } + status = "LEAVE"; + if(leaveReq.LeaveStartDate.Date == dd.date) + { + stampType = leaveReq.LeaveRange ?? ""; + stampAmount = leaveReq.LeaveRange != "ALL" ? 0.5 : 1; + } + else if(leaveReq.LeaveEndDate.Date == dd.date) + { + stampAmount = leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1; + stampType = leaveReq.LeaveRangeEnd ?? ""; + } + else + stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1; + if(stampType == "ALL") stampType = "FULL_DAY"; + } + else + { + if (timeStamps == null) + { + if (dd.date <= DateTime.Now.Date) + { + remarkStr = "ขาดราชการ"; + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + if (dd.isHoliday == true) + { + remarkStr = $"วันหยุด ({dd.dateRemark})"; + status = "HOLIDAY"; + } + else if (dd.isWeekEnd) + { + remarkStr = dd.dateRemark; + status = "WEEKEND"; + } + } + else remarkStr = ""; + } + else + { + // check status ของการลงเวลา + if (timeStamps.CheckOut != null) + { + if (timeStamps.CheckOutStatus == "ABSENT") + { + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckOut ? $" (นอกสถานที่:{timeStamps.CheckOutLocationName})".Trim() : ""); + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + } + else if (timeStamps.CheckInStatus == "ABSENT") + { + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + } + else if (timeStamps.CheckInStatus == "LATE") + { + remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + status = "LATE"; + stampType = "FULL_DAY"; + stampAmount = 1; + //lateTotal += 1; + } + else + remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : ""; + } + else + { + if (timeStamps.CheckInStatus == "ABSENT") + { + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + } + else if (timeStamps.CheckInStatus == "LATE") + { + status = "LATE"; + stampType = "FULL_DAY"; + stampAmount = 1; + remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + //lateTotal += 1; + } + else + remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : ""; + } + } + } + + var emp = new DateResultReport + { + profileId = p.Id.ToString(), + stampDate = dd.date, + stampType = stampType, + stampAmount = stampAmount, + remark = remarkStr, + status = status + }; + + employees.Add(emp); + count++; + } + + // Write employees to JSON file + // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt"; + // var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Exports", fileName); + + // // Ensure directory exists + // var directory = Path.GetDirectoryName(filePath); + // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) + // { + // Directory.CreateDirectory(directory); + // } + + // var jsonOptions = new JsonSerializerOptions + // { + // WriteIndented = true, + // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + // }; + + // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions); + // await File.WriteAllTextAsync(filePath, jsonContent); + } + + //call api + var apiPath = $"{_configuration["API"]}/org/unauthorize/profile/absent-late/batch"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + records = employees.Where(x => x.status == "ABSENT" || x.status == "LATE").ToList() + }; + + var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey); + if(apiResult == "") + { + throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ"); + } + } + + public async Task ProcessEmpTaskAsync(Guid rootDnaId, DateTime? startDate, DateTime? endDate) + { + + var profiles = new List(); + var dateStart = startDate?.Date ?? DateTime.Now.Date; + var dateEnd = endDate?.Date ?? DateTime.Now.Date; + + var holidays = await _holidayRepository.GetHolidayAsync(dateStart, dateEnd); + var weekend = _holidayRepository.GetWeekEnd(dateStart, dateEnd); + var excludeDates = holidays.Union(weekend).ToList(); + + var dateList = new List(); + for (DateTime i = dateStart; i <= dateEnd; i = i.AddDays(1)) + { + if (holidays.Contains(i)) + { + var d = await _holidayRepository.GetHolidayAsync(i); + dateList.Add(new LoopDate + { + date = i, + isHoliday = true, + isWeekEnd = false, + dateRemark = d + }); + } + else if (weekend.Contains(i)) + { + dateList.Add(new LoopDate + { + date = i, + isHoliday = true, + isWeekEnd = false, + dateRemark = "วันหยุด" + }); + } + else + { + dateList.Add(new LoopDate + { + date = i, + isHoliday = false, + isWeekEnd = false, + dateRemark = "" + }); + } + } + + var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (defaultRound == null) + { + throw new Exception("ไม่พบรอบการลงเวลา Default"); + } + + var employees = new List(); + + foreach (var dd in dateList.Where(x => !x.isHoliday && !x.isWeekEnd)) + { + profiles = await _userProfileRepository.GetAllEmployeeByRootDnaId(rootDnaId.ToString(),dd.date); + foreach (var p in profiles) + { + var count = 1; + var keycloakUserId = p.Keycloak ?? Guid.Empty; + + var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd.date); + + var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; + + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date); + var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + + var duty = userRound ?? defaultRound; + + // check วันลาของแต่ละคน + var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd.date); + var remarkStr = string.Empty; + var status = string.Empty; + var stampType = string.Empty; + var stampAmount = 0.0; + + if (leaveReq != null) + { + switch (leaveReq.Type.Code.ToUpper()) + { + case "LV-001": + case "LV-002": + case "LV-005": + remarkStr += leaveReq.Type.Name; + var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper(); + + if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + + + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRangeEnd == "MORNING") + // remarkStr += "ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += "ครึ่งวันบ่าย"; + + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange != leaveRangeEnd) + { + if (leaveRangeEnd == "MORNING") + remarkStr += " - ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += " - ครึ่งวันบ่าย"; + } + } + else + { + if(dd.date == leaveReq.LeaveStartDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else if(dd.date == leaveReq.LeaveEndDate.Date) + { + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRangeEnd == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else + { + remarkStr += "เต็มวัน"; + } + } + break; + default: + remarkStr += leaveReq.Type.Name; + break; + } + status = "LEAVE"; + if(leaveReq.LeaveStartDate.Date == dd.date) + { + stampType = leaveReq.LeaveRange ?? ""; + stampAmount = leaveReq.LeaveRange != "ALL" ? 0.5 : 1; + } + else if(leaveReq.LeaveEndDate.Date == dd.date) + { + stampAmount = leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1; + stampType = leaveReq.LeaveRangeEnd ?? ""; + } + else + stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1; + if(stampType == "ALL") stampType = "FULL_DAY"; + //stampAmount = leaveReq.LeaveRange != "ALL" || leaveReq.LeaveRangeEnd != "ALL" ? 0.5 : 1; + } + else + { + if (timeStamps == null) + { + if (dd.date <= DateTime.Now.Date) + { + remarkStr = "ขาดราชการ"; + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + if (dd.isHoliday == true) + { + remarkStr = $"วันหยุด ({dd.dateRemark})"; + status = "HOLIDAY"; + } + else if (dd.isWeekEnd) + { + remarkStr = dd.dateRemark; + status = "WEEKEND"; + } + } + else remarkStr = ""; + } + else + { + // check status ของการลงเวลา + if (timeStamps.CheckOut != null) + { + if (timeStamps.CheckOutStatus == "ABSENT") + { + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckOut ? $" (นอกสถานที่:{timeStamps.CheckOutLocationName})".Trim() : ""); + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + } + else if (timeStamps.CheckInStatus == "ABSENT") + { + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + } + else if (timeStamps.CheckInStatus == "LATE") + { + remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + status = "LATE"; + stampType = "FULL_DAY"; + stampAmount = 1; + //lateTotal += 1; + } + else + remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : ""; + } + else + { + if (timeStamps.CheckInStatus == "ABSENT") + { + status = "ABSENT"; + stampType = "FULL_DAY"; + stampAmount = 1; + remarkStr = "ขาดราชการ" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + } + else if (timeStamps.CheckInStatus == "LATE") + { + status = "LATE"; + stampType = "FULL_DAY"; + stampAmount = 1; + remarkStr = "สาย" + (!timeStamps.IsLocationCheckIn ? $" (นอกสถานที่:{timeStamps.CheckInLocationName})".Trim() : ""); + //lateTotal += 1; + } + else + remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : ""; + } + } + } + + var emp = new DateResultReport + { + profileId = p.Id.ToString(), + stampDate = dd.date, + stampType = stampType, + stampAmount = stampAmount, + remark = remarkStr, + status = status + }; + + employees.Add(emp); + count++; + } + + // Write employees to JSON file + // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt"; + // var filePath = Path.Combine(_env.ContentRootPath, "Exports", fileName); + + // // Ensure directory exists + // var directory = Path.GetDirectoryName(filePath); + // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) + // { + // Directory.CreateDirectory(directory); + // } + + // var jsonOptions = new JsonSerializerOptions + // { + // WriteIndented = true, + // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + // }; + + // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions); + // Console.WriteLine($"Writing file to: {filePath}"); + // await File.WriteAllTextAsync(filePath, jsonContent); + // Console.WriteLine($"File written successfully: {fileName}"); + } + + // call api + var apiPath = $"{_configuration["API"]}/org/unauthorize/profile-employee/absent-late/batch"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + records = employees.Where(x => x.status == "ABSENT" || x.status == "LATE").ToList() + }; + + var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey); + if(apiResult == "") + { + throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ"); + } + } + + + public async Task ProcessPendingJobsAsync() + { + var pendingJobs = await GetPendingJobsAsync(); + Console.WriteLine($"พบงานที่ค้างอยู่ในสถานะ PENDING จำนวน {pendingJobs.Count} งาน"); + + foreach (var job in pendingJobs) + { + try + { + // อัปเดตสถานะเป็น Processing + await UpdateToProcessingAsync(job.Id); + + // ทำงานที่ต้องการที่นี่ (เช่น เรียก API, ประมวลผลข้อมูล ฯลฯ) + await ProcessTaskAsync(job.RootDnaId,job.StartDate, job.EndDate); + await ProcessEmpTaskAsync(job.RootDnaId,job.StartDate, job.EndDate); + + // อัปเดตสถานะเป็น Completed + await UpdateToCompletedAsync(job.Id); + } + catch (Exception ex) + { + // หากเกิดข้อผิดพลาด อัปเดตสถานะเป็น Failed พร้อมข้อความแสดงข้อผิดพลาด + await UpdateToFailedAsync(job.Id, ex.Message); + } + } + } + + #endregion + } + + class LoopDate + { + public DateTime date { get; set; } + + public bool isHoliday { get; set; } + + public bool isWeekEnd { get; set; } + + public string dateRemark { get; set; } + + } + + class DateResultReport + { + public string? profileId { get; set; } + public DateTime stampDate { get; set; } + public string stampType { get; set; } + public double stampAmount { get; set; } + public string remark { get; set; } + public string status { get; set; } + } + +} \ No newline at end of file diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs index 64d32a19..77aba421 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/ProcessUserTimeStampRepository.cs @@ -172,10 +172,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants { data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList(); } - else if (role == "PARENT") - { - data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => @@ -191,11 +191,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "BROTHER" || role == "PARENT") { data = data.Where(x => - nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) : - nodeByReq == 3 ? x.Child3Id == Guid.Parse(nodeIdByReq) : - nodeByReq == 2 ? x.Child2Id == Guid.Parse(nodeIdByReq) : - nodeByReq == 1 ? x.Child1Id == Guid.Parse(nodeIdByReq) : - nodeByReq == 0 ? x.RootId == Guid.Parse(nodeIdByReq) : true + nodeByReq == 4 ? x.Child4DnaId == Guid.Parse(nodeIdByReq) : + nodeByReq == 3 ? x.Child3DnaId == Guid.Parse(nodeIdByReq) : + nodeByReq == 2 ? x.Child2DnaId == Guid.Parse(nodeIdByReq) : + nodeByReq == 1 ? x.Child1DnaId == Guid.Parse(nodeIdByReq) : + nodeByReq == 0 ? x.RootDnaId == Guid.Parse(nodeIdByReq) : true ).ToList(); } return data; @@ -227,6 +227,19 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return data; } + public async Task> GetTimeStampHistoryAsync2(Guid keycloakId, int year) + { + var fiscalDateStart = new DateTime(year - 1, 10, 1); + var fiscalDateEnd = new DateTime(year, 9, 30); + + var data = await _dbContext.Set() + .Where(u => u.KeycloakUserId == keycloakId) + .Where(u => u.CheckIn.Date >= fiscalDateStart && u.CheckIn.Date <= fiscalDateEnd) + .OrderByDescending(u => u.CheckIn.Date) + .ToListAsync(); + return data; + } + public async Task GetTimeStampHistoryForAdminCountAsync(DateTime startDate, DateTime endDate) { var data = await _dbContext.Set() @@ -288,12 +301,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants .Where(x => x.RootDnaId == Guid.Parse(nodeId!)) .ToList(); } - else if (role == "PARENT") - { - data = data - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null) - .ToList(); - } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null) + // .ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs index 3eefefe0..b34bc4db 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserDutyTimeRepository.cs @@ -101,14 +101,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return data; } - public async Task GetLastEffectRound(Guid profileId) + public async Task GetLastEffectRound(Guid profileId, DateTime? effectiveDate = null, CancellationToken cancellationToken = default) { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); + effectiveDate ??= DateTime.Now; var data = await _dbContext.Set() .Where(x => x.ProfileId == profileId) - .Where(x => x.IsProcess) - .Where(x => x.EffectiveDate.Value.Date <= DateTime.Now.Date) + .Where(x => x.EffectiveDate.Value.Date <= effectiveDate.Value.Date) .OrderByDescending(x => x.EffectiveDate) - .FirstOrDefaultAsync(); + .FirstOrDefaultAsync(combinedCts.Token); return data; } diff --git a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs index b7a766e9..6dffcb6c 100644 --- a/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/TimeAttendants/UserTimeStampRepository.cs @@ -74,12 +74,16 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants return data; } - public async Task GetLastRecord(Guid keycloakId) + public async Task GetLastRecord(Guid keycloakId, CancellationToken cancellationToken = default) { + // กำหนด timeout เป็น 30 นาที + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(30)); + using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token); + var data = await _dbContext.Set() .Where(u => u.KeycloakUserId == keycloakId) .OrderByDescending(u => u.CheckIn) - .FirstOrDefaultAsync(); + .FirstOrDefaultAsync(combinedCts.Token); return data; } @@ -136,12 +140,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants .Where(x => x.RootDnaId == Guid.Parse(nodeId!)) .ToList(); } - else if (role == "PARENT") - { - data = data - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null) - .ToList(); - } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null) + // .ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => diff --git a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs index f0d0bc0c..46019cfc 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs @@ -51,7 +51,8 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // // throw new Exception(GlobalMessages.DataNotFound); // } - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; var profileId = ""; using (var client = new HttpClient()) { diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index eeb1d71e..a9d5ceb7 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -55,7 +55,8 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // // throw new Exception(GlobalMessages.DataNotFound); // } - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; var profileId = ""; using (var client = new HttpClient()) { @@ -131,7 +132,8 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // { // return 0; // } - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; var profileId = ""; using (var client = new HttpClient()) { diff --git a/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs b/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs index c5c09a44..1c8ae006 100644 --- a/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs +++ b/BMA.EHR.Application/Repositories/MetaData/HolidayRepository.cs @@ -49,12 +49,16 @@ namespace BMA.EHR.Application.Repositories.MetaData public async Task GetHolidayCountAsync(DateTime startDate, DateTime endDate, string category = "NORMAL") { - var data = await _dbContext.Set().AsQueryable() + var query = _dbContext.Set().AsQueryable() .Where(x => x.Category == category) - .Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate) - .CountAsync(); + .Where(x => x.HolidayDate.Date >= startDate && x.HolidayDate.Date <= endDate); - return data; + if (category == "NORMAL") + query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Saturday && x.HolidayDate.DayOfWeek != DayOfWeek.Sunday); + else + query = query.Where(x => x.HolidayDate.DayOfWeek != DayOfWeek.Sunday); + + return await query.CountAsync(); } public List GetWeekEnd(DateTime startDate, DateTime endDate, string category = "NORMAL") diff --git a/BMA.EHR.Application/Repositories/PermissionRepository.cs b/BMA.EHR.Application/Repositories/PermissionRepository.cs index d5ac981a..a63207ec 100644 --- a/BMA.EHR.Application/Repositories/PermissionRepository.cs +++ b/BMA.EHR.Application/Repositories/PermissionRepository.cs @@ -10,6 +10,7 @@ using System.Net.Http.Headers; using Microsoft.Extensions.Configuration; using System.Security.Claims; using System.Net.Http.Json; +using BMA.EHR.Application.Responses.Leaves; namespace BMA.EHR.Application.Repositories { @@ -62,6 +63,10 @@ namespace BMA.EHR.Application.Repositories new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); var req = await client.GetAsync(apiPath); + if (!req.IsSuccessStatusCode) + { + throw new Exception("Error calling permission API"); + } var res = await req.Content.ReadAsStringAsync(); return res; } @@ -72,6 +77,39 @@ namespace BMA.EHR.Application.Repositories } } + public async Task GetPermissionWithActingAPIAsync(string action, string system) + { + try + { + var apiPath = $"{_configuration["API"]}/org/permission/dotnet-acting/{action}/{system}"; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = + new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + var req = await client.GetAsync(apiPath); + if (!req.IsSuccessStatusCode) + { + throw new Exception("Error calling permission API"); + } + var apiResult = await req.Content.ReadAsStringAsync(); + //return res; + + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + return raw; + } + return null; + } + } + catch + { + throw; + } + } + public async Task GetPermissionOrgAPIAsync(string action, string system, string profileId) { try diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index c094738e..a1dd7936 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -893,7 +893,7 @@ namespace BMA.EHR.Application.Repositories.Reports select new { RowNo = 1, - DepartmentName = _userProfileRepository.GetOc(g.Key.OcId, 0, AccessToken).Root, //_organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), + DepartmentName = _userProfileRepository.GetOc(g.Key.OcId, 0, AccessToken)?.Root ?? "-", //_organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false), G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0), G2Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0), diff --git a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs index ecb65e2f..6ad5a61a 100644 --- a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs @@ -192,7 +192,7 @@ namespace BMA.EHR.Application.Repositories.Reports }).ToList(); } string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-"; - return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles }; + return new { SignDate, Detail = retireHistorys.Detail.ToThaiNumber(), retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles }; } } else @@ -312,7 +312,7 @@ namespace BMA.EHR.Application.Repositories.Reports root = (isDuplicateRoot ? "" : profile.root + "\n") + (isDuplicateHospital || !hospital.ToObject>().Contains(profile.child1) ? "" : profile.child1 + "\n") + (isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") + - (isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}"), + (isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}").ToThaiNumber(), child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") + (profile.child4 == null ? "" : profile.child4 + "\n") + (profile.child3 == null ? "" : profile.child3 + "\n") + @@ -326,7 +326,7 @@ namespace BMA.EHR.Application.Repositories.Reports }).ToList(); } string SignDate = retire.SignDate != null ? DateTime.Parse(retire.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-"; - return new { SignDate, retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profiles = mapProfiles }; + return new { SignDate, Detail = retire.Detail.ToThaiNumber(), retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profiles = mapProfiles }; } } #endregion diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index 15e06ca9..2d9ae7b4 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -157,7 +157,7 @@ namespace BMA.EHR.Application.Repositories return null; } - catch(Exception ex) + catch (Exception ex) { throw; } @@ -186,6 +186,78 @@ namespace BMA.EHR.Application.Repositories } } + + + public async Task GetProfileByKeycloakIdNewAsync(Guid keycloakId, string? accessToken,CancellationToken cancellationToken = default) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak/{keycloakId}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey, cancellationToken); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task GetProfileByKeycloakIdNew2Async(Guid keycloakId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak2/{keycloakId}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task GetProfileByCheckInAsync(Guid keycloakId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/check-keycloak/{keycloakId}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task GetProfileLeaveByKeycloakIdAsync(Guid keycloakId, string? accessToken) { try @@ -209,6 +281,66 @@ namespace BMA.EHR.Application.Repositories } } + public async Task?> GetOCStaffAsync(Guid profileId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/find-staff"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + assignId = "SYS_LEAVE_LIST", + profileId = profileId + }; + + //var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task GetProfileLeaveReportByKeycloakIdAsync(Guid keycloakId, string? accessToken, string? report) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/profile-leave/keycloak"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + keycloakId = keycloakId, + report = report + }; + + //var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + public async Task GetProfileByProfileIdAsync(Guid profileId, string? accessToken) { try @@ -232,6 +364,31 @@ namespace BMA.EHR.Application.Repositories } } + + public async Task GetProfileByProfileIdNoAuthAsync(Guid profileId, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/unauthorize/profile/{profileId}"; + var apiKey = _configuration["API_KEY"]; + + var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task UpdateDutyTimeAsync(Guid profileId, Guid roundId, DateTime effectiveDate, string? accessToken) { try @@ -520,7 +677,7 @@ namespace BMA.EHR.Application.Repositories } } - public async Task> GetProfileByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId) + public async Task> GetProfileByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate) { try { @@ -533,7 +690,9 @@ namespace BMA.EHR.Application.Repositories role = role, revisionId = revisionId, reqNode = reqNode, - reqNodeId = reqNodeId + reqNodeId = reqNodeId, + //startDate = startDate, + //endDate = endDate }; var profiles = new List(); @@ -554,6 +713,187 @@ namespace BMA.EHR.Application.Repositories } } + public async Task> GetProfileByAdminRolev2(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev2"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + role = role, + // revisionId = revisionId, + reqNode = reqNode, + reqNodeId = reqNodeId, + // startDate = startDate, + // endDate = endDate + date = endDate + }; + Console.WriteLine(body); + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return new List(); + } + catch + { + throw; + } + } + + public async Task> GetProfileByAdminRolev3(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev3"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + role = role, + // revisionId = revisionId, + reqNode = reqNode, + reqNodeId = reqNodeId, + startDate = startDate, + endDate = endDate + }; + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return null; + } + catch + { + throw; + } + } + + public async Task> GetAllOfficerByRootDnaId(string? rootDnaId, DateTime date) + { + try + { + var apiPath = $"{_configuration["API"]}/org/unauthorize/officer-list"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + reqNode = 0, + reqNodeId = rootDnaId, + date = date + }; + //Console.WriteLine(body); + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, "", body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + else + return new List(); + } + else + return new List(); + } + catch + { + throw; + } + } + + public async Task> GetAllEmployeeByRootDnaId(string? rootDnaId, DateTime date) + { + try + { + var apiPath = $"{_configuration["API"]}/org/unauthorize/employee-list"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + reqNode = 0, + reqNodeId = rootDnaId, + startDate = date, + endDate = date + }; + //Console.WriteLine(body); + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, "", body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + else + return new List(); + } + else + return new List(); + } + catch + { + throw; + } + } + + public async Task> GetProfileByAdminRolev4(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate) + { + try + { + var apiPath = $"{_configuration["API"]}/org/dotnet/officer-by-admin-rolev4"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + node = node, + nodeId = nodeId, + role = role, + // revisionId = revisionId, + reqNode = reqNode, + reqNodeId = reqNodeId, + // startDate = startDate, + // endDate = endDate + date = endDate + }; + Console.WriteLine(body); + + var profiles = new List(); + + var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey); + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null) + return raw.Result; + } + + return new List(); + } + catch + { + throw; + } + } + public async Task> GetProfileWithKeycloakAllOfficerRetireFilterAndRevision(string? accessToken, int? node, string? nodeId, bool isAll, bool? isRetirement, string? revisionId) { try @@ -686,7 +1026,7 @@ namespace BMA.EHR.Application.Repositories } } - public async Task> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId) + public async Task> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate) { try { @@ -699,7 +1039,9 @@ namespace BMA.EHR.Application.Repositories role = role, revisionId = revisionId, reqNode = reqNode, - reqNodeId = reqNodeId + reqNodeId = reqNodeId, + startDate = startDate, + endDate = endDate }; var profiles = new List(); @@ -720,7 +1062,7 @@ namespace BMA.EHR.Application.Repositories } } - public async Task SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node) + public async Task SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node,string? selectedNodeId,int? selectedNode ) { try { @@ -736,6 +1078,8 @@ namespace BMA.EHR.Application.Repositories node = node, page = page, pageSize = pageSize, + selectedNodeId = selectedNodeId, + selectedNode = selectedNode }; var profiles = new List(); @@ -938,7 +1282,7 @@ namespace BMA.EHR.Application.Repositories } } - public GetOrganizationResponseDTO? GetOc(Guid ocId, int level, string? accessToken) + public GetOrganizationResponseDTO? GetOcByNodeId(Guid ocId, int level, string? accessToken) { try { @@ -969,6 +1313,38 @@ namespace BMA.EHR.Application.Repositories } } + + public GetOrganizationResponseDTO? GetOc(Guid ocId, int level, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/find/allv2"; + var apiKey = _configuration["API_KEY"]; + var body = new + { + nodeId = ocId, + node = level + + }; + + var apiResult = PostExternalAPIAsync(apiPath, accessToken ?? "", body, apiKey).Result; + if (apiResult != null) + { + var raw = JsonConvert.DeserializeObject(apiResult); + if (raw != null && raw.Result != null) + { + return raw.Result; + } + } + + return null; + } + catch + { + throw; + } + } + public GetProfileByIdDto GetOfficerProfileById(Guid id, string? accessToken) { try diff --git a/BMA.EHR.Application/Responses/Leaves/GetPermissionWithActingDto.cs b/BMA.EHR.Application/Responses/Leaves/GetPermissionWithActingDto.cs new file mode 100644 index 00000000..083c4b20 --- /dev/null +++ b/BMA.EHR.Application/Responses/Leaves/GetPermissionWithActingDto.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BMA.EHR.Domain.Shared; +using Newtonsoft.Json; + +namespace BMA.EHR.Application.Responses.Leaves +{ + public class GetPermissionWithActingDto + { + public string privilege {get; set;} = string.Empty; + public bool isAct {get; set;} = false; + public List posMasterActs {get; set;} = new(); + } + + public class ActingPermission + { + public string posNo {get; set;} = string.Empty; + //public string? privilege {get; set;} = "PARENT"; + [JsonConverter(typeof(PrivilegeConverter))] + public string privilege {get; set;} = "CHILD"; + + public Guid? rootDnaId {get; set;} + public Guid? child1DnaId {get; set;} + public Guid? child2DnaId {get; set;} + public Guid? child3DnaId {get; set;} + public Guid? child4DnaId {get; set;} + } + + public class GetPermissionWithActingResultDto + { + public int status {get; set;} = 0; + public string message {get; set;} = string.Empty; + public GetPermissionWithActingDto result {get; set;} = new(); + } +} \ No newline at end of file diff --git a/BMA.EHR.Application/Responses/Leaves/GetProfileLeaveByKeycloakDto.cs b/BMA.EHR.Application/Responses/Leaves/GetProfileLeaveByKeycloakDto.cs index 52a9b948..9d13d834 100644 --- a/BMA.EHR.Application/Responses/Leaves/GetProfileLeaveByKeycloakDto.cs +++ b/BMA.EHR.Application/Responses/Leaves/GetProfileLeaveByKeycloakDto.cs @@ -2,19 +2,27 @@ { public class GetProfileLeaveByKeycloakDto { + public string ProfileType { get; set; } + public string Prefix { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string CitizenId { get; set; } public DateTime BirthDate { get; set; } public DateTime RetireDate { get; set; } public string GovAge { get; set; } = string.Empty; public string Age { get; set; } = string.Empty; public DateTime DateAppoint { get; set; } public DateTime DateCurrent { get; set; } - public int Amount { get; set; } + public int? Amount { get; set; } = 0; public string? TelephoneNumber { get; set; } = string.Empty; - public string PositionName { get; set; } = string.Empty; + public string Position { get; set; } = string.Empty; public string PosLevel { get; set; } = string.Empty; public string PosType { get; set; } = string.Empty; + public string? PositionLeaveName { get; set; } + public string? PosExecutiveName { get; set; } public string CurrentAddress { get; set; } = string.Empty; public string Oc { get; set; } = string.Empty; + public bool isCommission { get; set; } = false; public string Root { get; set; } = string.Empty; public string? Child1 { get; set; } public string? Child2 { get; set; } diff --git a/BMA.EHR.Application/Responses/Profiles/GetOcStaff.cs b/BMA.EHR.Application/Responses/Profiles/GetOcStaff.cs new file mode 100644 index 00000000..fa3ce936 --- /dev/null +++ b/BMA.EHR.Application/Responses/Profiles/GetOcStaff.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BMA.EHR.Application.Responses.Profiles +{ + public class GetOcStaff + { + public Guid ProfileId { get; set; } + public Guid Keycloak { get; set; } + public string FullName { get; set; } = null!; + public Guid? RootId { get; set; } + public Guid? OrgChild1Id { get; set; } + public Guid? OrgChild2Id { get; set; } + public Guid? OrgChild3Id { get; set; } + public Guid? OrgChild4Id { get; set; } + public Guid? RootDnaId { get; set; } + public Guid? Child1DnaId { get; set; } + public Guid? Child2DnaId { get; set; } + public Guid? Child3DnaId { get; set; } + public Guid? Child4DnaId { get; set; } + + } + + public class GetOcStaffResultDto + { + public string Message { get; set; } = string.Empty; + + public int Status { get; set; } = -1; + + public List Result { get; set; } = new(); + + } +} \ No newline at end of file diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs index bb377f3e..8e319904 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs @@ -44,6 +44,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? ProfileType { get; set; } public bool? IsLeave { get; set; } + public bool? IsProbation { get; set; } + public string? Root { get; set; } public string? Child1 { get; set; } public string? Child2 { get; set; } @@ -80,6 +82,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? CurrentZipCode { get; set; } public string? PositionLeaveName { get; set; } + + public string? PosExecutiveName { get; set; } public string? CommanderPositionName { get; set; } = string.Empty; diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdRootDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdRootDto.cs index 1110ca9e..2eff51dd 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdRootDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdRootDto.cs @@ -25,6 +25,12 @@ namespace BMA.EHR.Application.Responses.Profiles public DateTime? DateStart { get; set; } public DateTime? DateAppoint { get; set; } + + public string? RootDnaId { get; set; } + public string? Child1DnaId { get; set; } + public string? Child2DnaId { get; set; } + public string? Child3DnaId { get; set; } + public string? Child4DnaId { get; set; } } public class GetProfileByKeycloakIdRootAddTotalDto diff --git a/BMA.EHR.CheckInConsumer/Program.cs b/BMA.EHR.CheckInConsumer/Program.cs index 1a5a68d1..95dac001 100644 --- a/BMA.EHR.CheckInConsumer/Program.cs +++ b/BMA.EHR.CheckInConsumer/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using RabbitMQ.Client; using RabbitMQ.Client.Events; using System.Text; @@ -21,81 +21,104 @@ var queue = configuration["Rabbit:Queue"] ?? "basic-queue"; // create connection var factory = new ConnectionFactory() { - //Uri = new Uri("amqp://admin:P@ssw0rd@192.168.4.11:5672") - HostName = host,// หรือ hostname ของ RabbitMQ Server ที่คุณใช้ - UserName = user, // ใส่ชื่อผู้ใช้ของคุณ - Password = pass // ใส่รหัสผ่านของคุณ + HostName = host, + UserName = user, + Password = pass, + DispatchConsumersAsync = true }; using var connection = factory.CreateConnection(); using var channel = connection.CreateModel(); -//channel.QueueDeclare(queue: "bma-checkin-queue", durable: true, exclusive: false, autoDelete: false, arguments: null); channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null); -var consumer = new EventingBasicConsumer(channel); +// Create a SINGLE static HttpClient instance to prevent socket exhaustion +using var httpClient = new HttpClient(); +httpClient.Timeout = TimeSpan.FromSeconds(300); // 5 นาที + +var consumer = new AsyncEventingBasicConsumer(channel); consumer.Received += async (model, ea) => { - var body = ea.Body.ToArray(); - var message = Encoding.UTF8.GetString(body); - await CallRestApi(message); + try + { + var body = ea.Body.ToArray(); + var message = Encoding.UTF8.GetString(body); - // convert string into object - //var request = JsonConvert.DeserializeObject(message); - //using (var db = new ApplicationDbContext()) - //{ - // var item = new AttendantItem - // { - // Name = request.Name, - // CheckInDateTime = request.CheckInDateTime, - // }; - // db.AttendantItems.Add(item); - // db.SaveChanges(); + WriteToConsole($"Received message: {message}"); - // WriteToConsole($"ได้รับคำขอจาก Queue: {message}"); - // WriteToConsole($"ตอบกลับจาก REST API: {JsonConvert.SerializeObject(item)}"); - //} + var success = await CallRestApi(message, httpClient, configuration); - WriteToConsole($"ได้รับคำขอจาก Queue: {message}"); - //WriteToConsole($"ตอบกลับจาก REST API: {JsonConvert.SerializeObject(item)}"); + if (success) + { + channel.BasicAck(ea.DeliveryTag, multiple: false); + WriteToConsole("Message processed successfully"); + } + else + { + channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false); + WriteToConsole("Message processing failed - message rejected"); + } + } + catch (Exception ex) + { + WriteToConsole($"Error processing message: {ex.Message}"); + channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false); + } }; -//channel.BasicConsume(queue: "bma-checkin-queue", autoAck: true, consumer: consumer); -channel.BasicConsume(queue: queue, autoAck: true, consumer: consumer); +channel.BasicConsume(queue: queue, autoAck: false, consumer: consumer); -//Console.WriteLine("\nPress 'Enter' to exit the process..."); +WriteToConsole("Consumer started. Waiting for messages..."); +// Keep the application running await Task.Delay(-1); static void WriteToConsole(string message) { - Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} : {message}"); + Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} : {message}"); } -async Task CallRestApi(string requestData) +static async Task CallRestApi(string requestData, HttpClient client, IConfiguration configuration) { - using var client = new HttpClient(); - var apiPath = $"{configuration["API"]}/leave/process-check-in"; - - var content = new StringContent(requestData, Encoding.UTF8, "application/json"); - - var response = await client.PostAsync(apiPath, content); - - if (response.IsSuccessStatusCode) + try { - var responseContent = await response.Content.ReadAsStringAsync(); - WriteToConsole(responseContent); + var apiPath = $"{configuration["API"]}/leave/process-check-in"; + var content = new StringContent(requestData, Encoding.UTF8, "application/json"); + + var response = await client.PostAsync(apiPath, content); + + if (response.IsSuccessStatusCode) + { + var responseContent = await response.Content.ReadAsStringAsync(); + WriteToConsole($"API Success: {responseContent}"); + return true; + } + else + { + var errorMessage = await response.Content.ReadAsStringAsync(); + var res = JsonSerializer.Deserialize(errorMessage); + WriteToConsole($"API Error ({response.StatusCode}): {res?.Message ?? errorMessage}"); + return false; + } } - else + catch (HttpRequestException ex) { - var errorMessage = await response.Content.ReadAsStringAsync(); - var res = JsonSerializer.Deserialize(errorMessage); - WriteToConsole($"Error: {res.Message}"); + WriteToConsole($"HTTP Error: {ex.Message}"); + return false; + } + catch (TaskCanceledException ex) + { + WriteToConsole($"Timeout: {ex.Message}"); + return false; + } + catch (Exception ex) + { + WriteToConsole($"Unexpected Error: {ex.Message}"); + return false; } } - public class ResponseObject { [JsonPropertyName("status")] @@ -111,28 +134,14 @@ public class ResponseObject public class CheckTimeDtoRB { public Guid? CheckInId { get; set; } - - public double Lat { get; set; } = 0; - - public double Lon { get; set; } = 0; - - public string POI { get; set; } = string.Empty; - - public bool IsLocation { get; set; } = true; - public string? LocationName { get; set; } = string.Empty; - public string? Remark { get; set; } = string.Empty; - public Guid? UserId { get; set; } - public DateTime? CurrentDate { get; set; } - public string? CheckInFileName { get; set; } - public byte[]? CheckInFileBytes { get; set; } -} \ No newline at end of file +} diff --git a/BMA.EHR.CheckInConsumer/appsettings.json b/BMA.EHR.CheckInConsumer/appsettings.json index b180f90c..76f86c86 100644 --- a/BMA.EHR.CheckInConsumer/appsettings.json +++ b/BMA.EHR.CheckInConsumer/appsettings.json @@ -1,9 +1,9 @@ { - "Rabbit": { - "Host": "192.168.1.40", - "User": "admin", - "Password": "Test123456", - "Queue": "bma-checkin-queue" - }, - "API": "https://localhost:7283/api/v1" -} \ No newline at end of file + "Rabbit": { + "Host": "192.168.1.63", + "User": "admin", + "Password": "12345678", + "Queue": "hrms-checkin-queue-dev" + }, + "API": "https://localhost:7283/api/v1" +} diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_AppealController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_AppealController.cs index a9d14a71..619756c2 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_AppealController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineComplaint_AppealController.cs @@ -93,7 +93,8 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers public async Task> GetDisciplineUser(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = null, bool descending = false) { var id = ""; - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -357,7 +358,8 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers [HttpPost()] public async Task> CreateDiscipline([FromForm] DisciplineComplaint_AppealRequest req) { - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + //var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; var id = ""; var type = ""; using (var client = new HttpClient()) @@ -784,7 +786,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -824,11 +826,11 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers data_search = data_search .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - data_search = data_search - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // data_search = data_search + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { data_search = data_search.Where(x => diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs index 202eaa44..c4bd24ae 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs @@ -392,7 +392,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, token.Replace("Bearer ", "")); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, token.Replace("Bearer ", "")); if (profile == null) return Error(GlobalMessages.DataNotFound); diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index e5be6189..5301a5ae 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -1013,6 +1013,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1061,8 +1066,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - // คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้ - data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); + //// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้ + // data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); var _profile = new List(); DateTime _date = DateTime.Now; foreach (var item in data) @@ -1150,6 +1155,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1198,8 +1208,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers var _result = await _res.Content.ReadAsStringAsync(); if (_res.IsSuccessStatusCode) { - // คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้ - data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); + //// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้ + // data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; }); var _profile = new List(); DateTime _date = DateTime.Now; foreach (var item in data) @@ -1242,14 +1252,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command25/report")] - public async Task> PostReportCommand25([FromBody] ReportPersonRequest req) + public async Task> PostReportCommand25([FromBody] ReportPersonAndCommandRequest req) { try { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + // data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + data.ForEach(profile => + { + profile.Status = !string.IsNullOrEmpty(req.status) + ? req.status.Trim().ToUpper() : null; + profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId) + ? cmdTypeId : null; + profile.CommandCode = req.commandCode ?? null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1276,7 +1294,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "PENDING"); + // data.ForEach(profile => profile.Status = "PENDING"); + data.ForEach(profile => + { + profile.Status = "PENDING"; + profile.CommandTypeId = null; + profile.CommandCode = null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1365,6 +1389,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers // .Where(x => x.Status == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1410,12 +1439,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.Status = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -1429,14 +1458,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("command26/report")] - public async Task> PostReportCommand26([FromBody] ReportPersonRequest req) + public async Task> PostReportCommand26([FromBody] ReportPersonAndCommandRequest req) { try { var data = await _context.DisciplineReport_Profiles .Where(x => req.refIds.Contains(x.Id.ToString())) .ToListAsync(); - data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + // data.ForEach(profile => profile.Status = req.status.Trim().ToUpper()); + data.ForEach(profile => + { + profile.Status = !string.IsNullOrEmpty(req.status) + ? req.status.Trim().ToUpper() : null; + profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId) + ? cmdTypeId : null; + profile.CommandCode = req.commandCode ?? null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1463,7 +1500,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.Status.ToUpper() == "REPORT") .ToListAsync(); - data.ForEach(profile => profile.Status = "PENDING"); + // data.ForEach(profile => profile.Status = "PENDING"); + data.ForEach(profile => + { + profile.Status = "PENDING"; + profile.CommandTypeId = null; + profile.CommandCode = null; + }); await _context.SaveChangesAsync(); return Success(); } @@ -1490,6 +1533,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers // .Where(x => x.Status == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1535,12 +1583,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.Status = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -1613,6 +1661,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1658,12 +1711,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -1736,6 +1789,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1781,12 +1839,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -1859,6 +1917,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1904,12 +1967,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -1982,6 +2045,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -2027,12 +2095,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -2105,6 +2173,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers .Include(x => x.DisciplineDisciplinary) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -2150,12 +2223,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; }); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -2244,6 +2317,11 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers // .Where(x => x.IsReport == "REPORT") .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.IsReport = "DONE"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -2289,12 +2367,12 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.IsReport = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.IsReport = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs index 732c518b..3e171f9b 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineSuspendController.cs @@ -71,6 +71,13 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } + + // ถ้า FE ส่ง status = PENDING กรอง start/end suspend not null + bool isPending = + !string.IsNullOrEmpty(profileType) && + !string.IsNullOrEmpty(status) && + status.Trim().ToUpper() == "PENDING"; + // กรองสิทธิ์ string role = jsonData["result"]?.ToString() ?? ""; var nodeId = string.Empty; @@ -102,14 +109,14 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } var data_search = (from x in _context.DisciplineReport_Profiles.Include(x => x.DisciplineDisciplinary) where ( - endDate != null && startDate != null? + endDate != null && startDate != null ? ( (x.StartDateSuspend.Value.Date >= startDate.Value.Date && x.StartDateSuspend.Value.Date <= endDate.Value.Date) || (x.EndDateSuspend.Value.Date >= startDate.Value.Date && x.EndDateSuspend.Value.Date <= endDate.Value.Date) || @@ -137,14 +144,19 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers ( !string.IsNullOrEmpty(status) ? x.Status!.Trim().ToUpper() == status : true ) + // ถ้า FE ส่ง status = PENDING กรอง start/end suspend not null + && + ( + isPending + ? x.StartDateSuspend != null && x.EndDateSuspend != null + : true + ) && ( role == "OWNER" ? true : role == "ROOT" ? x.rootDnaId == nodeId - : role == "PARENT" - ? x.rootDnaId == nodeId && x.child1DnaId != null : role == "CHILD" ? ( profileAdmin.Node == 4 ? x.child4DnaId == nodeId : @@ -177,125 +189,119 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers ) select x).ToList(); var query = data_search - .Select(x => new - { - Id = x.Id, - CitizenId = x.CitizenId, - Prefix = x.Prefix, - FirstName = x.FirstName, - LastName = x.LastName, - ProfileId = x.PersonId, - Organization = x.Organization, - root = x.root, - rootId = x.rootId, - rootDnaId = x.rootDnaId, - rootShortName = x.rootShortName, - child1 = x.child1, - child1Id = x.child1Id, - child1DnaId = x.child1DnaId, - child1ShortName = x.child1ShortName, - child2 = x.child2, - child2Id = x.child2Id, - child2DnaId = x.child2DnaId, - child2ShortName = x.child2ShortName, - child3 = x.child3, - child3Id = x.child3Id, - child3DnaId = x.child3DnaId, - child3ShortName = x.child3ShortName, - child4 = x.child4, - child4Id = x.child4Id, - child4DnaId = x.child4DnaId, - child4ShortName = x.child4ShortName, - posMasterNo = x.posMasterNo, - posTypeId = x.posTypeId, - posTypeName = x.posTypeName, - posLevelId = x.posLevelId, - posLevelName = x.posLevelName, + .Select(x => new + { + Id = x.Id, + CitizenId = x.CitizenId, + Prefix = x.Prefix, + FirstName = x.FirstName, + LastName = x.LastName, + ProfileId = x.PersonId, + Organization = x.Organization, + root = x.root, + rootId = x.rootId, + rootDnaId = x.rootDnaId, + rootShortName = x.rootShortName, + child1 = x.child1, + child1Id = x.child1Id, + child1DnaId = x.child1DnaId, + child1ShortName = x.child1ShortName, + child2 = x.child2, + child2Id = x.child2Id, + child2DnaId = x.child2DnaId, + child2ShortName = x.child2ShortName, + child3 = x.child3, + child3Id = x.child3Id, + child3DnaId = x.child3DnaId, + child3ShortName = x.child3ShortName, + child4 = x.child4, + child4Id = x.child4Id, + child4DnaId = x.child4DnaId, + child4ShortName = x.child4ShortName, + posMasterNo = x.posMasterNo, + posTypeId = x.posTypeId, + posTypeName = x.posTypeName, + posLevelId = x.posLevelId, + posLevelName = x.posLevelName, - Position = x.Position, - PosNo = x.PosNo, - PositionLevel = x.PositionLevel == null ? "" : x.PositionLevel, - PositionType = x.PositionType == null ? "" : x.PositionType, - Salary = x.Salary, - Status = x.Status, - DescriptionSuspend = x.DescriptionSuspend, - StartDateSuspend = x.StartDateSuspend, - EndDateSuspend = x.EndDateSuspend, - Title = x.DisciplineDisciplinary.Title, - OffenseDetails = x.DisciplineDisciplinary.OffenseDetails,//ลักษณะความผิด - DisciplinaryFaultLevel = x.DisciplineDisciplinary.DisciplinaryFaultLevel,//ระดับโทษความผิด - DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด - profileType = x.profileType, - CreatedAt = x.CreatedAt, - }); + Position = x.Position, + PosNo = x.PosNo, + PositionLevel = x.PositionLevel == null ? "" : x.PositionLevel, + PositionType = x.PositionType == null ? "" : x.PositionType, + Salary = x.Salary, + Status = x.Status, + DescriptionSuspend = x.DescriptionSuspend, + StartDateSuspend = x.StartDateSuspend, + EndDateSuspend = x.EndDateSuspend, + Title = x.DisciplineDisciplinary.Title, + OffenseDetails = x.DisciplineDisciplinary.OffenseDetails,//ลักษณะความผิด + DisciplinaryFaultLevel = x.DisciplineDisciplinary.DisciplinaryFaultLevel,//ระดับโทษความผิด + DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด + profileType = x.profileType, + CreatedAt = x.CreatedAt, + }); - bool desc = descending ?? false; - if (!string.IsNullOrEmpty(sortBy)) - { - if (sortBy == "title") - { - query = desc ? query.OrderByDescending(x => x.Title) - : query.OrderBy(x => x.Title); - } - else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName") - { - query = desc ? - query - //.OrderByDescending(x => x.Prefix) - .OrderByDescending(x => x.FirstName) - .ThenByDescending(x => x.LastName) : - query - //.OrderBy(x => x.Prefix) - .OrderBy(x => x.FirstName) - .ThenBy(x => x.LastName); - } - else if (sortBy == "position") - { - query = desc ? query.OrderByDescending(x => x.Position) - : query.OrderBy(x => x.Position); - } - else if (sortBy == "positionType" || sortBy == "positionLevel") - { - query = desc ? - query - .OrderByDescending(x => x.PositionType) - .ThenByDescending(x => x.PositionLevel) : - query - .OrderBy(x => x.PositionType) - .ThenBy(x => x.PositionLevel); - } - else if (sortBy == "organization") - { - query = desc ? query.OrderByDescending(x => x.Organization) - : query.OrderBy(x => x.Organization); - } - else if (sortBy == "startDateSuspend") - { - query = desc ? query.OrderByDescending(x => x.StartDateSuspend) - : query.OrderBy(x => x.StartDateSuspend); - } - else if (sortBy == "endDateSuspend") - { - query = desc ? query.OrderByDescending(x => x.EndDateSuspend) - : query.OrderBy(x => x.EndDateSuspend); - } - else if (sortBy == "descriptionSuspend") - { - query = desc ? query.OrderByDescending(x => x.DescriptionSuspend) - : query.OrderBy(x => x.DescriptionSuspend); - } - else - { - query = query.OrderByDescending(x => x.profileType) - .ThenByDescending(x => x.CreatedAt) - .ThenByDescending(x => x.CitizenId); - } - } + bool desc = descending ?? false; + if (!string.IsNullOrEmpty(sortBy)) + { + if (sortBy == "title") + { + query = desc ? query.OrderByDescending(x => x.Title) + : query.OrderBy(x => x.Title); + } + else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName") + { + query = desc ? + query.OrderByDescending(x => x.FirstName).ThenByDescending(x => x.LastName) : + query.OrderBy(x => x.FirstName).ThenBy(x => x.LastName); + } + else if (sortBy == "position") + { + query = desc ? query.OrderByDescending(x => x.Position) + : query.OrderBy(x => x.Position); + } + else if (sortBy == "positionType" || sortBy == "positionLevel") + { + query = desc ? + query + .OrderByDescending(x => x.PositionType) + .ThenByDescending(x => x.PositionLevel) : + query + .OrderBy(x => x.PositionType) + .ThenBy(x => x.PositionLevel); + } + else if (sortBy == "organization") + { + query = desc ? query.OrderByDescending(x => x.Organization) + : query.OrderBy(x => x.Organization); + } + else if (sortBy == "startDateSuspend") + { + query = desc ? query.OrderByDescending(x => x.StartDateSuspend) + : query.OrderBy(x => x.StartDateSuspend); + } + else if (sortBy == "endDateSuspend") + { + query = desc ? query.OrderByDescending(x => x.EndDateSuspend) + : query.OrderBy(x => x.EndDateSuspend); + } + else if (sortBy == "descriptionSuspend") + { + query = desc ? query.OrderByDescending(x => x.DescriptionSuspend) + : query.OrderBy(x => x.DescriptionSuspend); + } + else + { + query = query.OrderByDescending(x => x.profileType) + .ThenByDescending(x => x.CreatedAt) + .ThenByDescending(x => x.CitizenId); + } + } - var data = query - .Skip((page - 1) * pageSize) - .Take(pageSize) - .ToList(); + var data = query + .Skip((page - 1) * pageSize) + .Take(pageSize) + .ToList(); return Success(new { data, total = data_search.Count() }); } diff --git a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs index 1bd61c56..f7a16efc 100644 --- a/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs +++ b/BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs @@ -8,4 +8,12 @@ namespace BMA.EHR.Discipline.Service.Requests public string[] refIds { get; set; } public string? status { get; set; } } + + public class ReportPersonAndCommandRequest + { + public string[] refIds { get; set; } + public string? status { get; set; } + public string? commandTypeId { get; set; } + public string? commandCode { get; set; } + } } diff --git a/BMA.EHR.Domain/Common/BaseController.cs b/BMA.EHR.Domain/Common/BaseController.cs index 44d8dac0..0b382d95 100644 --- a/BMA.EHR.Domain/Common/BaseController.cs +++ b/BMA.EHR.Domain/Common/BaseController.cs @@ -1,4 +1,5 @@ -using BMA.EHR.Domain.Shared; +using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -81,6 +82,23 @@ namespace BMA.EHR.Domain.Common } + #endregion + + #region " Properties " + + protected string? EmpType => User.GetEmpType(); + protected Guid? OrgChild1DnaId => User.GetOrgChild1DnaId(); + protected Guid? OrgChild2DnaId => User.GetOrgChild2DnaId(); + protected Guid? OrgChild3DnaId => User.GetOrgChild3DnaId(); + protected Guid? OrgChild4DnaId => User.GetOrgChild4DnaId(); + protected Guid? OrgRootDnaId => User.GetOrgRootDnaId(); + protected Guid? ProfileId => User.GetProfileId(); + protected string? Prefix => User.GetPrefix(); + protected string? FullNameFromClaim => User.GetName(); + + protected string? FirstName => User.GetFirstName(); + protected string? LastName => User.GetLastName(); + #endregion #endregion diff --git a/BMA.EHR.Domain/Common/TokenUserInfo.cs b/BMA.EHR.Domain/Common/TokenUserInfo.cs new file mode 100644 index 00000000..cdae6fb1 --- /dev/null +++ b/BMA.EHR.Domain/Common/TokenUserInfo.cs @@ -0,0 +1,39 @@ +namespace BMA.EHR.Domain.Common +{ + public class TokenUserInfo + { + // Existing properties + public string KeycloakId { get; set; } = string.Empty; + public string? PreferredUsername { get; set; } + public string? GivenName { get; set; } + public string? FamilyName { get; set; } + + // New properties to add + public string? EmpType { get; set; } + public Guid? OrgChild1DnaId { get; set; } + public Guid? OrgChild2DnaId { get; set; } + public Guid? OrgChild3DnaId { get; set; } + public Guid? OrgChild4DnaId { get; set; } + public Guid? OrgRootDnaId { get; set; } + public Guid? ProfileId { get; set; } + public string? Prefix { get; set; } + public string? Name { get; set; } + } + + // Claim type constants + public static class BmaClaimTypes + { + public const string EmpType = "empType"; + public const string OrgChild1DnaId = "orgChild1DnaId"; + public const string OrgChild2DnaId = "orgChild2DnaId"; + public const string OrgChild3DnaId = "orgChild3DnaId"; + public const string OrgChild4DnaId = "orgChild4DnaId"; + public const string OrgRootDnaId = "orgRootDnaId"; + public const string ProfileId = "profileId"; + public const string Prefix = "prefix"; + public const string Name = "name"; + public const string GivenName = "given_name"; + public const string FamilyName = "family_name"; + public const string PreferredUsername = "preferred_username"; + } +} diff --git a/BMA.EHR.Domain/Extensions/ClaimsPrincipalExtensions.cs b/BMA.EHR.Domain/Extensions/ClaimsPrincipalExtensions.cs new file mode 100644 index 00000000..cc44f8a1 --- /dev/null +++ b/BMA.EHR.Domain/Extensions/ClaimsPrincipalExtensions.cs @@ -0,0 +1,32 @@ +using BMA.EHR.Domain.Common; +using System.Security.Claims; + +namespace BMA.EHR.Domain.Extensions +{ + public static class ClaimsPrincipalExtensions + { + public static string? GetClaimValue(this ClaimsPrincipal user, string claimType) + { + return user?.FindFirst(claimType)?.Value; + } + + public static Guid? GetGuidClaim(this ClaimsPrincipal user, string claimType) + { + var value = user?.GetClaimValue(claimType); + return Guid.TryParse(value, out var guid) ? guid : null; + } + + // Convenience methods for common claims + public static string? GetEmpType(this ClaimsPrincipal user) => user.GetClaimValue(BmaClaimTypes.EmpType); + public static Guid? GetOrgChild1DnaId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.OrgChild1DnaId); + public static Guid? GetOrgChild2DnaId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.OrgChild2DnaId); + public static Guid? GetOrgChild3DnaId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.OrgChild3DnaId); + public static Guid? GetOrgChild4DnaId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.OrgChild4DnaId); + public static Guid? GetOrgRootDnaId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.OrgRootDnaId); + public static Guid? GetProfileId(this ClaimsPrincipal user) => user.GetGuidClaim(BmaClaimTypes.ProfileId); + public static string? GetPrefix(this ClaimsPrincipal user) => user.GetClaimValue(BmaClaimTypes.Prefix); + public static string? GetName(this ClaimsPrincipal user) => user.GetClaimValue(BmaClaimTypes.Name); + public static string? GetFirstName(this ClaimsPrincipal user) => user.GetClaimValue(BmaClaimTypes.GivenName); + public static string? GetLastName(this ClaimsPrincipal user) => user.GetClaimValue(BmaClaimTypes.FamilyName); + } +} diff --git a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs index a6a07c79..bbfc0a12 100644 --- a/BMA.EHR.Domain/Extensions/DateTimeExtension.cs +++ b/BMA.EHR.Domain/Extensions/DateTimeExtension.cs @@ -174,6 +174,29 @@ namespace BMA.EHR.Domain.Extensions } } + public static (int Years, int Months, int Days) GetDifference(this DateTime from, DateTime to) + { + if (from > to) (from, to) = (to, from); // swap ถ้าลำดับสลับ + + int years = to.Year - from.Year; + int months = to.Month - from.Month; + int days = to.Day - from.Day; + + if (days < 0) + { + months--; + days += DateTime.DaysInMonth(to.Year, to.Month == 1 ? 12 : to.Month - 1); + } + + if (months < 0) + { + years--; + months += 12; + } + + return (years, months, days); + } + public static int CalculateAge(this DateTime date, int plusYear = 0, int subtractYear = 0) { try diff --git a/BMA.EHR.Domain/Middlewares/CombinedErrorHandlerAndLoggingMiddleware.cs b/BMA.EHR.Domain/Middlewares/CombinedErrorHandlerAndLoggingMiddleware.cs index a9de25fc..4216fa43 100644 --- a/BMA.EHR.Domain/Middlewares/CombinedErrorHandlerAndLoggingMiddleware.cs +++ b/BMA.EHR.Domain/Middlewares/CombinedErrorHandlerAndLoggingMiddleware.cs @@ -18,6 +18,10 @@ namespace BMA.EHR.Domain.Middlewares { private readonly RequestDelegate _next; private readonly IConfiguration _configuration; + private static ElasticClient? _elasticClient; + private static readonly object _lock = new object(); + private static readonly Dictionary _profileCache = new(); + private static readonly TimeSpan _cacheExpiry = TimeSpan.FromMinutes(10); private string Uri = ""; private string IndexFormat = ""; @@ -31,19 +35,28 @@ namespace BMA.EHR.Domain.Middlewares Uri = _configuration["ElasticConfiguration:Uri"] ?? "http://192.168.1.40:9200"; IndexFormat = _configuration["ElasticConfiguration:IndexFormat"] ?? "bma-ehr-log-index"; SystemName = _configuration["ElasticConfiguration:SystemName"] ?? "Unknown"; + + // สร้าง ElasticClient แค่ครั้งเดียว + if (_elasticClient == null) + { + lock (_lock) + { + if (_elasticClient == null) + { + var settings = new ConnectionSettings(new Uri(Uri)) + .DefaultIndex(IndexFormat) + .DisableDirectStreaming() // เพิ่มประสิทธิภาพ + .RequestTimeout(TimeSpan.FromSeconds(5)); // กำหนด timeout + _elasticClient = new ElasticClient(settings); + } + } + } } public async Task Invoke(HttpContext context) { - Console.WriteLine("=== CombinedErrorHandlerAndLoggingMiddleware Start ==="); - - var settings = new ConnectionSettings(new Uri(Uri)) - .DefaultIndex(IndexFormat); - var client = new ElasticClient(settings); - var startTime = DateTime.UtcNow; var stopwatch = Stopwatch.StartNew(); - string? responseBodyJson = null; string? requestBodyJson = null; Exception? caughtException = null; @@ -64,27 +77,41 @@ namespace BMA.EHR.Domain.Middlewares string keycloakId = Guid.Empty.ToString("D"); var token = context.Request.Headers["Authorization"]; GetProfileByKeycloakIdLocal? pf = null; + var tokenUserInfo = await ExtractTokenUserInfoAsync(token); - // ลองดึง keycloakId จาก JWT token ก่อน (ถ้ามี) - try - { - keycloakId = await ExtractKeycloakIdFromToken(token); - } - catch (Exception ex) - { - Console.WriteLine($"Error extracting keycloakId from token: {ex.Message}"); - } + // Store tokenUserInfo in HttpContext.Items for controllers to use + context.Items["TokenUserInfo"] = tokenUserInfo; - try + // ดึง keycloakId จาก JWT token + keycloakId = tokenUserInfo.KeycloakId; + + // ดึง profile จาก claims หรือ cache หรือ API + if (Guid.TryParse(keycloakId, out var parsedId) && parsedId != Guid.Empty) { - if (Guid.TryParse(keycloakId, out var parsedId) && parsedId != Guid.Empty) + // Build profile from token claims if available + if (tokenUserInfo.OrgRootDnaId.HasValue && tokenUserInfo.ProfileId.HasValue) { - pf = await GetProfileByKeycloakIdAsync(parsedId, token); + pf = new GetProfileByKeycloakIdLocal + { + Id = tokenUserInfo.ProfileId.Value, + CitizenId = tokenUserInfo.PreferredUsername, + Prefix = tokenUserInfo.Prefix, + FirstName = tokenUserInfo.GivenName, + LastName = tokenUserInfo.FamilyName, + RootDnaId = tokenUserInfo.OrgRootDnaId, + Child1DnaId = tokenUserInfo.OrgChild1DnaId, + Child2DnaId = tokenUserInfo.OrgChild2DnaId, + Child3DnaId = tokenUserInfo.OrgChild3DnaId, + Child4DnaId = tokenUserInfo.OrgChild4DnaId, + }; + Console.WriteLine($"[INFO] Using claims for profile - OrgRootDnaId: {pf.RootDnaId}, ProfileId: {pf.Id}"); + } + else + { + // Fallback to API only if critical claims are missing + Console.WriteLine("[WARN] Critical claims missing, falling back to API call"); + pf = await GetProfileWithCacheAsync(parsedId, token); } - } - catch (Exception ex) - { - Console.WriteLine($"Error getting profile: {ex.Message}"); } try @@ -103,17 +130,17 @@ namespace BMA.EHR.Domain.Middlewares Console.WriteLine($"Updated keycloakId from authenticated user: {keycloakId}"); // อัพเดต profile ด้วย keycloakId ที่ถูกต้อง - try - { - if (Guid.TryParse(keycloakId, out var parsedId)) - { - pf = await GetProfileByKeycloakIdAsync(parsedId, token); - } - } - catch (Exception ex) - { - Console.WriteLine($"Error updating profile after authentication: {ex.Message}"); - } + // try + // { + // if (Guid.TryParse(keycloakId, out var parsedId)) + // { + // //pf = await GetProfileByKeycloakIdAsync(parsedId, token); + // } + // } + // catch (Exception ex) + // { + // Console.WriteLine($"Error updating profile after authentication: {ex.Message}"); + // } } } @@ -142,14 +169,48 @@ namespace BMA.EHR.Domain.Middlewares finally { stopwatch.Stop(); - await LogRequest(context, client, startTime, stopwatch, pf, keycloakId, requestBodyJson, memoryStream, caughtException); - - // เขียนข้อมูลกลับไปยัง original Response body + + // อ่านข้อมูล response ก่อนที่ stream จะถูก dispose + string? responseBodyForLogging = null; + if (memoryStream.Length > 0) + { + memoryStream.Seek(0, SeekOrigin.Begin); + using var reader = new StreamReader(memoryStream, leaveOpen: true); + responseBodyForLogging = await reader.ReadToEndAsync(); + memoryStream.Seek(0, SeekOrigin.Begin); + } + + // เก็บข้อมูลที่จำเป็นจาก HttpContext ก่อนที่มันจะถูก dispose + var logData = new + { + RemoteIpAddress = context.Connection.RemoteIpAddress?.ToString(), + HostValue = context.Request.Host.Value, + Method = context.Request.Method, + Path = context.Request.Path.ToString(), + QueryString = context.Request.QueryString.ToString(), + StatusCode = context.Response.StatusCode, + ContentType = context.Response.ContentType ?? "" + }; + + // เขียนข้อมูลกลับไปยัง original Response body ก่อน if (memoryStream.Length > 0) { memoryStream.Seek(0, SeekOrigin.Begin); await memoryStream.CopyToAsync(originalBodyStream); } + + // ทำ logging แบบ await + Console.WriteLine("[DEBUG] Starting logging..."); + try + { + await LogRequestAsync(_elasticClient!, startTime, stopwatch, pf, keycloakId, requestBodyJson, responseBodyForLogging, caughtException, logData); + Console.WriteLine("[DEBUG] Logging completed successfully"); + } + catch (Exception ex) + { + Console.WriteLine($"[ERROR] Logging error: {ex.Message}"); + Console.WriteLine($"[ERROR] Stack trace: {ex.StackTrace}"); + } } } @@ -379,15 +440,16 @@ namespace BMA.EHR.Domain.Middlewares } } - private async Task LogRequest(HttpContext context, ElasticClient client, DateTime startTime, Stopwatch stopwatch, - GetProfileByKeycloakIdLocal? pf, string keycloakId, string? requestBodyJson, MemoryStream memoryStream, Exception? caughtException) + private async Task LogRequestAsync(ElasticClient client, DateTime startTime, Stopwatch stopwatch, + GetProfileByKeycloakIdLocal? pf, string keycloakId, string? requestBodyJson, string? responseBodyForLogging, Exception? caughtException, dynamic contextData) { + Console.WriteLine("[DEBUG] LogRequestAsync called"); try { var processTime = stopwatch.ElapsedMilliseconds; var endTime = DateTime.UtcNow; - var statusCode = caughtException != null ? (int)HttpStatusCode.InternalServerError : context.Response.StatusCode; + var statusCode = caughtException != null ? (int)HttpStatusCode.InternalServerError : (int)contextData.StatusCode; var logType = caughtException != null ? "error" : statusCode switch { @@ -399,58 +461,41 @@ namespace BMA.EHR.Domain.Middlewares string? message = null; string? responseBodyJson = null; - // อ่านข้อมูลจาก Response - if (memoryStream.Length > 0) + // ใช้ response body ที่ส่งมาจากการอ่านก่อนหน้า + if (!string.IsNullOrEmpty(responseBodyForLogging)) { - memoryStream.Seek(0, SeekOrigin.Begin); - var responseBody = new StreamReader(memoryStream).ReadToEnd(); + var contentType = (string)contextData.ContentType; + var isFileResponse = !contentType.StartsWith("application/json") && !contentType.StartsWith("text/html") && ( + contentType.StartsWith("application/") || + contentType.StartsWith("image/") || + contentType.StartsWith("audio/") + ); - if (!string.IsNullOrEmpty(responseBody)) + if (isFileResponse) { - var contentType = context.Response.ContentType; - var isFileResponse = !contentType.StartsWith("application/json") && !contentType.StartsWith("text/html") && ( - contentType.StartsWith("application/") || - contentType.StartsWith("image/") || - contentType.StartsWith("audio/") || - context.Response.Headers.ContainsKey("Content-Disposition") - ); - - if (isFileResponse) + responseBodyJson = ""; + message = "success"; + } + else + { + // ใช้ response body ที่มีอยู่แล้วโดยไม่ serialize ซ้ำ + responseBodyJson = responseBodyForLogging; + + try { - responseBodyJson = ""; - message = "success"; + var json = JsonSerializer.Deserialize(responseBodyForLogging); + if (json.ValueKind == JsonValueKind.Array) + { + message = "success"; + } + else if (json.TryGetProperty("message", out var messageElement)) + { + message = messageElement.GetString(); + } } - else + catch { - try - { - var jsonOptions = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - WriteIndented = true, - Converters = { new DateTimeFixConverter() } - }; - responseBodyJson = JsonSerializer.Serialize(JsonSerializer.Deserialize(responseBody), jsonOptions); - - var json = JsonSerializer.Deserialize(responseBody); - if (json.ValueKind == JsonValueKind.Array) - { - message = "success"; - } - else - { - if (json.TryGetProperty("message", out var messageElement)) - { - message = messageElement.GetString(); - } - } - } - catch - { - responseBodyJson = responseBody; - message = caughtException?.Message ?? "Unknown error"; - } + message = caughtException?.Message ?? "Unknown error"; } } } @@ -463,15 +508,16 @@ namespace BMA.EHR.Domain.Middlewares var logData = new { logType = logType, - ip = context.Connection.RemoteIpAddress?.ToString(), - rootId = pf?.RootId, + ip = (string)contextData.RemoteIpAddress, + //rootId = pf?.RootId, + rootId = pf?.RootDnaId, systemName = SystemName, startTimeStamp = startTime.ToString("o"), endTimeStamp = endTime.ToString("o"), processTime = processTime, - host = context.Request.Host.Value, - method = context.Request.Method, - endpoint = context.Request.Path + context.Request.QueryString, + host = (string)contextData.HostValue, + method = (string)contextData.Method, + endpoint = (string)contextData.Path + (string)contextData.QueryString, responseCode = statusCode == 304 ? "200" : statusCode.ToString(), responseDescription = message, input = requestBodyJson, @@ -482,11 +528,19 @@ namespace BMA.EHR.Domain.Middlewares exception = caughtException?.ToString() }; - await client.IndexDocumentAsync(logData); + Console.WriteLine($"[DEBUG] Sending log to Elasticsearch: {logType} - {(string)contextData.Method} {(string)contextData.Path}"); + var response = await client.IndexDocumentAsync(logData); + Console.WriteLine($"[DEBUG] Elasticsearch response: IsValid={response.IsValid}, Index={response.Index}"); + + if (!response.IsValid) + { + Console.WriteLine($"[ERROR] Elasticsearch error: {response.OriginalException?.Message ?? response.ServerError?.ToString()}"); + } } catch (Exception ex) { - Console.WriteLine($"Error logging request: {ex.Message}"); + Console.WriteLine($"[ERROR] Error logging request: {ex.Message}"); + Console.WriteLine($"[ERROR] Stack trace: {ex.StackTrace}"); } } @@ -536,11 +590,19 @@ namespace BMA.EHR.Domain.Middlewares private async Task ExtractKeycloakIdFromToken(string? authorizationHeader) { + var tokenInfo = await ExtractTokenUserInfoAsync(authorizationHeader); + return tokenInfo.KeycloakId; + } + + private async Task ExtractTokenUserInfoAsync(string? authorizationHeader) + { + var defaultResult = new TokenUserInfo { KeycloakId = Guid.Empty.ToString("D") }; + try { if (string.IsNullOrEmpty(authorizationHeader) || !authorizationHeader.StartsWith("Bearer ")) { - return Guid.Empty.ToString("D"); + return defaultResult; } var token = authorizationHeader.Replace("Bearer ", ""); @@ -549,7 +611,7 @@ namespace BMA.EHR.Domain.Middlewares var parts = token.Split('.'); if (parts.Length != 3) { - return Guid.Empty.ToString("D"); + return defaultResult; } // Decode Base64Url payload (JWT uses Base64Url encoding, not standard Base64) @@ -570,31 +632,136 @@ namespace BMA.EHR.Domain.Middlewares Console.WriteLine($"JWT Payload: {payloadJson}"); - // Parse JSON และดึง sub (subject) claim + // Parse JSON และดึง claims ต่างๆ var jsonDoc = JsonDocument.Parse(payloadJson); + var result = new TokenUserInfo(); - // ลองหา keycloak ID ใน claims ต่างๆ - string? keycloakId = null; - + // ดึง keycloak ID if (jsonDoc.RootElement.TryGetProperty("sub", out var subElement)) { - keycloakId = subElement.GetString(); + result.KeycloakId = subElement.GetString() ?? Guid.Empty.ToString("D"); } else if (jsonDoc.RootElement.TryGetProperty("nameid", out var nameidElement)) { - keycloakId = nameidElement.GetString(); + result.KeycloakId = nameidElement.GetString() ?? Guid.Empty.ToString("D"); } else if (jsonDoc.RootElement.TryGetProperty("user_id", out var userIdElement)) { - keycloakId = userIdElement.GetString(); + result.KeycloakId = userIdElement.GetString() ?? Guid.Empty.ToString("D"); + } + else + { + result.KeycloakId = Guid.Empty.ToString("D"); } - return keycloakId ?? Guid.Empty.ToString("D"); + // ดึง preferred_username + if (jsonDoc.RootElement.TryGetProperty("preferred_username", out var preferredUsernameElement)) + { + result.PreferredUsername = preferredUsernameElement.GetString(); + Console.WriteLine($"Extracted preferred_username: {result.PreferredUsername}"); + } + + // ดึง given_name + if (jsonDoc.RootElement.TryGetProperty("given_name", out var givenNameElement)) + { + result.GivenName = givenNameElement.GetString(); + Console.WriteLine($"Extracted given_name: {result.GivenName}"); + } + + // ดึง family_name + if (jsonDoc.RootElement.TryGetProperty("family_name", out var familyNameElement)) + { + result.FamilyName = familyNameElement.GetString(); + Console.WriteLine($"Extracted family_name: {result.FamilyName}"); + } + + // ดึง empType + if (jsonDoc.RootElement.TryGetProperty("empType", out var empTypeElement)) + { + result.EmpType = empTypeElement.GetString(); + Console.WriteLine($"Extracted empType: {result.EmpType}"); + } + + // ดึง orgChild1DnaId + if (jsonDoc.RootElement.TryGetProperty("orgChild1DnaId", out var orgChild1Element)) + { + if (Guid.TryParse(orgChild1Element.GetString(), out var orgChild1Guid)) + { + result.OrgChild1DnaId = orgChild1Guid; + Console.WriteLine($"Extracted orgChild1DnaId: {result.OrgChild1DnaId}"); + } + } + + // ดึง orgChild2DnaId + if (jsonDoc.RootElement.TryGetProperty("orgChild2DnaId", out var orgChild2Element)) + { + if (Guid.TryParse(orgChild2Element.GetString(), out var orgChild2Guid)) + { + result.OrgChild2DnaId = orgChild2Guid; + Console.WriteLine($"Extracted orgChild2DnaId: {result.OrgChild2DnaId}"); + } + } + + // ดึง orgChild3DnaId + if (jsonDoc.RootElement.TryGetProperty("orgChild3DnaId", out var orgChild3Element)) + { + if (Guid.TryParse(orgChild3Element.GetString(), out var orgChild3Guid)) + { + result.OrgChild3DnaId = orgChild3Guid; + Console.WriteLine($"Extracted orgChild3DnaId: {result.OrgChild3DnaId}"); + } + } + + // ดึง orgChild4DnaId + if (jsonDoc.RootElement.TryGetProperty("orgChild4DnaId", out var orgChild4Element)) + { + if (Guid.TryParse(orgChild4Element.GetString(), out var orgChild4Guid)) + { + result.OrgChild4DnaId = orgChild4Guid; + Console.WriteLine($"Extracted orgChild4DnaId: {result.OrgChild4DnaId}"); + } + } + + // ดึง orgRootDnaId + if (jsonDoc.RootElement.TryGetProperty("orgRootDnaId", out var orgRootElement)) + { + if (Guid.TryParse(orgRootElement.GetString(), out var orgRootGuid)) + { + result.OrgRootDnaId = orgRootGuid; + Console.WriteLine($"Extracted orgRootDnaId: {result.OrgRootDnaId}"); + } + } + + // ดึง profileId + if (jsonDoc.RootElement.TryGetProperty("profileId", out var profileIdElement)) + { + if (Guid.TryParse(profileIdElement.GetString(), out var profileIdGuid)) + { + result.ProfileId = profileIdGuid; + Console.WriteLine($"Extracted profileId: {result.ProfileId}"); + } + } + + // ดึง prefix + if (jsonDoc.RootElement.TryGetProperty("prefix", out var prefixElement)) + { + result.Prefix = prefixElement.GetString(); + Console.WriteLine($"Extracted prefix: {result.Prefix}"); + } + + // ดึง name + if (jsonDoc.RootElement.TryGetProperty("name", out var nameElement)) + { + result.Name = nameElement.GetString(); + Console.WriteLine($"Extracted name: {result.Name}"); + } + + return result; } catch (Exception ex) { - Console.WriteLine($"Error extracting keycloak ID from token: {ex.Message}"); - return Guid.Empty.ToString("D"); + Console.WriteLine($"Error extracting token user info: {ex.Message}"); + return defaultResult; } } @@ -625,7 +792,8 @@ namespace BMA.EHR.Domain.Middlewares { try { - var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}"; + //var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak/{keycloakId}"; + var apiPath = $"{_configuration["API"]}/org/dotnet/user-logs/{keycloakId}"; var apiKey = _configuration["API_KEY"]; var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey); @@ -640,7 +808,58 @@ namespace BMA.EHR.Domain.Middlewares } catch { - throw; + return null; + } + } + + private async Task GetProfileWithCacheAsync(Guid keycloakId, string? accessToken) + { + var cacheKey = keycloakId.ToString(); + + // ตรวจสอบ cache + lock (_profileCache) + { + if (_profileCache.TryGetValue(cacheKey, out var cached)) + { + if (cached.ExpiryTime > DateTime.UtcNow) + { + return cached.Profile; + } + // ลบ cache ที่หมดอายุ + _profileCache.Remove(cacheKey); + } + } + + // ดึงข้อมูลจาก API + try + { + var profile = await GetProfileByKeycloakIdAsync(keycloakId, accessToken); + if (profile != null) + { + // เก็บใน cache + lock (_profileCache) + { + _profileCache[cacheKey] = (profile, DateTime.UtcNow.Add(_cacheExpiry)); + + // ลบ cache เก่าที่เกิน 1000 รายการ + if (_profileCache.Count > 1000) + { + var expiredKeys = _profileCache + .Where(x => x.Value.ExpiryTime < DateTime.UtcNow) + .Select(x => x.Key) + .ToList(); + foreach (var key in expiredKeys) + { + _profileCache.Remove(key); + } + } + } + } + return profile; + } + catch + { + return null; } } diff --git a/BMA.EHR.Domain/Models/Leave/Requests/LeaveBeginning.cs b/BMA.EHR.Domain/Models/Leave/Requests/LeaveBeginning.cs index 9c459c69..0bb9a1c1 100644 --- a/BMA.EHR.Domain/Models/Leave/Requests/LeaveBeginning.cs +++ b/BMA.EHR.Domain/Models/Leave/Requests/LeaveBeginning.cs @@ -24,11 +24,14 @@ namespace BMA.EHR.Domain.Models.Leave.Requests [Required, Comment("ปีงบประมาณ")] public int LeaveYear { get; set; } = 0; - [Required, Comment("จำนวนวันลายกมา")] + [Required, Comment("จำนวนวันลาทั้งหมด")] public double LeaveDays { get; set; } = 0.0; - [Required, Comment("จำนวนวันลาที่ใช้ไป")] - public double LeaveDaysUsed { get; set; } = 0.0; + [Comment("จำนวนวันลาที่ใช้ไป")] + public double? LeaveDaysUsed { get; set; } = 0.0; + + [Comment("จำนวนครั้งที่ลาสะสม")] + public int? LeaveCount { get; set; } = 0; public Guid? RootDnaId { get; set; } @@ -39,5 +42,11 @@ namespace BMA.EHR.Domain.Models.Leave.Requests public Guid? Child3DnaId { get; set; } public Guid? Child4DnaId { get; set; } + + [Required, Comment("จำนวนวันลายกมา")] + public double BeginningLeaveDays { get; set; } = 0.0; + + [Comment("จำนวนครั้งที่ลายกมา")] + public int BeginningLeaveCount { get; set; } = 0; } } diff --git a/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequest.cs b/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequest.cs index 69088cbb..f6c9ce2d 100644 --- a/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequest.cs +++ b/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequest.cs @@ -210,5 +210,7 @@ namespace BMA.EHR.Domain.Models.Leave.Requests public Guid? Child4DnaId { get; set; } = Guid.Empty; + public DateTime? DateSendLeave { get; set; } + } } diff --git a/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequestApprover.cs b/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequestApprover.cs index 10e7175d..0a46c199 100644 --- a/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequestApprover.cs +++ b/BMA.EHR.Domain/Models/Leave/Requests/LeaveRequestApprover.cs @@ -17,6 +17,15 @@ namespace BMA.EHR.Domain.Models.Leave.Requests public string PositionName { get; set; } = string.Empty; + [Comment("ประเภทระดับตำแหน่ง")] + public string PositionLevelName { get; set; } = string.Empty; + + [Comment("ตำแหน่งทางการบริหาร")] + public string PosExecutiveName { get; set; } = string.Empty; + + [Comment("สังกัด")] + public string OrganizationName { get; set; } = string.Empty; + [Comment("ตำแหน่งใต้ลายเช็นต์")] public string? PositionSign { get; set; } = string.Empty; @@ -29,5 +38,10 @@ namespace BMA.EHR.Domain.Models.Leave.Requests public string Comment { get; set; } = string.Empty; public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver + + + public bool IsAct { get; set; } = false; + + public string KeyId { get; set; } = string.Empty; } } diff --git a/BMA.EHR.Domain/Models/Leave/TimeAttendants/CheckInJobStatus.cs b/BMA.EHR.Domain/Models/Leave/TimeAttendants/CheckInJobStatus.cs new file mode 100644 index 00000000..922f966b --- /dev/null +++ b/BMA.EHR.Domain/Models/Leave/TimeAttendants/CheckInJobStatus.cs @@ -0,0 +1,39 @@ +using BMA.EHR.Domain.Models.Base; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; + +namespace BMA.EHR.Domain.Models.Leave.TimeAttendants +{ + public class CheckInJobStatus : EntityBase + { + [Required, Comment("Task ID สำหรับติดตามสถานะงาน")] + public Guid TaskId { get; set; } = Guid.Empty; + + [Required, Comment("รหัส User ของ Keycloak")] + public Guid KeycloakUserId { get; set; } = Guid.Empty; + + [Comment("วันเวลาที่สร้างงาน")] + public DateTime CreatedDate { get; set; } = DateTime.Now; + + [Comment("วันเวลาที่เริ่มประมวลผล")] + public DateTime? ProcessingDate { get; set; } + + [Comment("วันเวลาที่เสร็จสิ้นการประมวลผล")] + public DateTime? CompletedDate { get; set; } + + [Required, Comment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED")] + public string Status { get; set; } = "PENDING"; + + [Comment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT")] + public string? CheckType { get; set; } + + [Comment("CheckInId สำหรับ Check-Out")] + public Guid? CheckInId { get; set; } + + [Comment("ข้อความแสดงข้อผิดพลาด")] + public string? ErrorMessage { get; set; } + + [Comment("ข้อมูลเพิ่มเติม (JSON)")] + public string? AdditionalData { get; set; } + } +} diff --git a/BMA.EHR.Domain/Models/Leave/TimeAttendants/LeaveProcessJobStatus.cs b/BMA.EHR.Domain/Models/Leave/TimeAttendants/LeaveProcessJobStatus.cs new file mode 100644 index 00000000..be986189 --- /dev/null +++ b/BMA.EHR.Domain/Models/Leave/TimeAttendants/LeaveProcessJobStatus.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using BMA.EHR.Domain.Models.Base; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Domain.Models.Leave.TimeAttendants +{ + public class LeaveProcessJobStatus: EntityBase + { + [Required, Comment("วันเริ่มต้น")] + public DateTime StartDate { get; set; } + + [Required, Comment("วันสิ้นสุด")] + public DateTime EndDate { get; set; } + + [Required, Comment("รหัส Root DNA Id")] + public Guid RootDnaId { get; set; } = Guid.Empty; + + [Comment("วันเวลาที่สร้างงาน")] + public DateTime CreatedDate { get; set; } = DateTime.Now; + + [Comment("วันเวลาที่เริ่มประมวลผล")] + public DateTime? ProcessingDate { get; set; } + + [Comment("วันเวลาที่เสร็จสิ้นการประมวลผล")] + public DateTime? CompletedDate { get; set; } + + [Required, Comment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED")] + public string Status { get; set; } = "PENDING"; + + [Comment("ข้อความแสดงข้อผิดพลาด")] + public string? ErrorMessage { get; set; } + } +} \ No newline at end of file diff --git a/BMA.EHR.Domain/Models/Placement/PlacementReceive.cs b/BMA.EHR.Domain/Models/Placement/PlacementReceive.cs index 9d366d19..5187360e 100644 --- a/BMA.EHR.Domain/Models/Placement/PlacementReceive.cs +++ b/BMA.EHR.Domain/Models/Placement/PlacementReceive.cs @@ -64,6 +64,10 @@ namespace BMA.EHR.Domain.Models.Placement public string? profileId { get; set; } [Comment("คำนำหน้า")] public string? prefix { get; set; } + + [Comment("ยศ")] + public string? rank { get; set; } + [Comment("ชื่อ")] public string? firstName { get; set; } [Comment("นามสกุล")] diff --git a/BMA.EHR.Domain/Shared/GlobalMessages.cs b/BMA.EHR.Domain/Shared/GlobalMessages.cs index 8746de95..a99dc3c9 100644 --- a/BMA.EHR.Domain/Shared/GlobalMessages.cs +++ b/BMA.EHR.Domain/Shared/GlobalMessages.cs @@ -8,6 +8,8 @@ public static readonly string DataNotFound = "ไม่พบข้อมูลในระบบ"; + public static readonly string ProfileNotFound = "ไม่พบข้อมูลในระบบทะเบียนประวัติ"; + public static readonly string NotAuthorized = "กรุณาเข้าสู่ระบบก่อนใช้งาน!"; public static readonly string ForbiddenAccess = "คุณไม่ได้รับอนุญาติให้เข้าใช้งาน!"; diff --git a/BMA.EHR.Domain/Shared/PrivilegeConverter.cs b/BMA.EHR.Domain/Shared/PrivilegeConverter.cs new file mode 100644 index 00000000..59f8168c --- /dev/null +++ b/BMA.EHR.Domain/Shared/PrivilegeConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace BMA.EHR.Domain.Shared +{ + public class PrivilegeConverter : JsonConverter +{ + public override bool CanConvert(Type objectType) + { + return objectType == typeof(string); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + return "EMPTY"; + } + return reader.Value; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteValue(value); + } +} +} \ No newline at end of file diff --git a/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.Designer.cs b/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.Designer.cs new file mode 100644 index 00000000..b65f0774 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.Designer.cs @@ -0,0 +1,21250 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDBContext))] + [Migration("20260512073417_update_PlacementReceives_add_rank")] + partial class update_PlacementReceives_add_rank + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ActEndDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุดการรักษาการแทน"); + + b.Property("ActStartDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่มรักษาการแทน"); + + b.Property("AuthorizedPosition") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้มีอำนาจลงนาม"); + + b.Property("AuthorizedUserFullName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อผู้มีอำนาจลงนาม"); + + b.Property("AuthorizedUserId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงผู้มีอำนาจลงนาม"); + + b.Property("CaseFault") + .HasColumnType("longtext") + .HasComment("กรณีความผิด"); + + b.Property("ChairManFullName") + .HasColumnType("longtext") + .HasComment("ประธานคณะกรรมการ"); + + b.Property("CommandAffectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่คำสั่งมีผล"); + + b.Property("CommandExcecuteDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกคำสั่ง"); + + b.Property("CommandNo") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("เลขที่คำสั่ง"); + + b.Property("CommandStatusId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงสถานะคำสั่ง"); + + b.Property("CommandSubject") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)") + .HasComment("คำสั่งเรื่อง"); + + b.Property("CommandTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงประเภทคำสั่ง"); + + b.Property("CommandYear") + .IsRequired() + .HasMaxLength(4) + .HasColumnType("varchar(4)") + .HasComment("ปีที่ออกคำสั่ง"); + + b.Property("ComplaintId") + .HasColumnType("char(36)") + .HasComment("Id เรื่องร้องเรียน"); + + b.Property("ConclusionFireDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (เรื่องการดำเนินการทางวินัย)"); + + b.Property("ConclusionFireNo") + .HasColumnType("longtext") + .HasComment("ครั้งที่ (เรื่องการดำเนินการทางวินัย)"); + + b.Property("ConclusionFireResolution") + .HasColumnType("longtext") + .HasComment("มติที่ประชุม (เรื่องการดำเนินการทางวินัย)"); + + b.Property("ConclusionMeetingDate") + .HasColumnType("datetime(6)") + .HasComment("การประชุม ลงวันที่"); + + b.Property("ConclusionMeetingNo") + .HasColumnType("longtext") + .HasComment("การประชุม ครั้งที่"); + + b.Property("ConclusionReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (การรับโอน)"); + + b.Property("ConclusionReceiveNo") + .HasColumnType("longtext") + .HasComment("มติ กก. ครั้งที่ (การรับโอน)"); + + b.Property("ConclusionRegisterDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (เรื่อง รับสมัครสอบฯ)"); + + b.Property("ConclusionRegisterNo") + .HasColumnType("longtext") + .HasComment("มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)"); + + b.Property("ConclusionResultDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)"); + + b.Property("ConclusionResultNo") + .HasColumnType("longtext") + .HasComment("มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)"); + + b.Property("ConclusionReturnDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (เรื่อง กลับเข้ารับราชการ)"); + + b.Property("ConclusionReturnNo") + .HasColumnType("longtext") + .HasComment("มติ กก. ครั้งที่ (เรื่อง กลับเข้ารับราชการ)"); + + b.Property("ConclusionTranferDate") + .HasColumnType("datetime(6)") + .HasComment("การประชุม ลงวันที่"); + + b.Property("ConclusionTranferNo") + .HasColumnType("longtext") + .HasComment("การประชุม ครั้งที่"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Fault") + .HasColumnType("longtext") + .HasComment("รายละเอียดการกระทำผิด"); + + b.Property("FaultLevel") + .HasColumnType("longtext") + .HasComment("ระดับความผิด"); + + b.Property("GovAidCommandDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (คำสั่งช่วยราชการ)"); + + b.Property("GovAidCommandNo") + .HasColumnType("longtext") + .HasComment("คำสั่งเลขที่ (คำสั่งช่วยราชการ)"); + + b.Property("GuiltyBasis") + .HasColumnType("longtext") + .HasComment("ฐานความผิด"); + + b.Property("IssuerOrganizationId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงหน่วยงานที่ออกคำสั่ง"); + + b.Property("IssuerOrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ออกคำสั่ง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Member1FullName") + .HasColumnType("longtext") + .HasComment("กรรมการคนที่ 1"); + + b.Property("Member2FullName") + .HasColumnType("longtext") + .HasComment("กรรมการคนที่ 2"); + + b.Property("MilitaryCommanDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่ (ให้เข้ารับราชการทหาร)"); + + b.Property("MilitaryCommandNo") + .HasColumnType("longtext") + .HasComment("คำสั่งที่ (ให้เข้ารับราชการทหาร)"); + + b.Property("OwnerGovId") + .HasColumnType("char(36)") + .HasComment("รหัสส่วนราชการผู้ออกคำสั่ง"); + + b.Property("PlacementCommandDate") + .HasColumnType("datetime(6)") + .HasComment("คำสั่งบรรจุลงวันที่"); + + b.Property("PlacementCommandIssuer") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ออกคำสั่งบรรจุ"); + + b.Property("PlacementCommandNo") + .HasColumnType("longtext") + .HasComment("เลขที่คำสั่งบรรจุ"); + + b.Property("PlacementId") + .HasColumnType("char(36)") + .HasComment("อ้างอิงรอบการสอบ"); + + b.Property("PlacementOrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดที่บรรจุ"); + + b.Property("PlacementPositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งที่บรรจุ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งที่บรรจุ"); + + b.Property("ProbationEndDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุดการทดลองปฏิบัติราชการ"); + + b.Property("ProbationStartDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่มทดลองปฏิบัติราชการ"); + + b.Property("ReceiveOrganizationName") + .HasColumnType("longtext") + .HasComment("ส่วนราชการที่รับโอน"); + + b.Property("RefRaw") + .HasColumnType("longtext") + .HasComment("อ้างอิงมาตราตามกฏหมาย"); + + b.Property("Result") + .HasColumnType("longtext") + .HasComment("ผลดำเนินการพิจารณา"); + + b.Property("SalaryPeriod") + .HasColumnType("longtext") + .HasComment("รอบเงินเดือน"); + + b.Property("SalaryPeriodId") + .HasColumnType("char(36)") + .HasComment("Id เรื่องเงินเดือน"); + + b.Property("SourceOrganizationName") + .HasColumnType("longtext") + .HasComment("หน่วยงานต้นสังกัด ก่อนรับราชการทหาร"); + + b.Property("TransferOrganizationName") + .HasColumnType("longtext") + .HasComment("ส่วนราชการที่ให้โอน"); + + b.Property("Year") + .HasMaxLength(4) + .HasColumnType("varchar(4)") + .HasComment("ปีรอบเงินเดือน"); + + b.HasKey("Id"); + + b.HasIndex("CommandStatusId"); + + b.HasIndex("CommandTypeId"); + + b.HasIndex("PlacementId"); + + b.ToTable("Commands"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CommandId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงคำสั่ง"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("IsSendInbox") + .HasColumnType("tinyint(1)") + .HasComment("ส่งกล่องข้อความหรือไม่?"); + + b.Property("IsSendMail") + .HasColumnType("tinyint(1)") + .HasComment("ส่งอีเมล์หรือไม่?"); + + b.Property("IsSendNotification") + .HasColumnType("tinyint(1)") + .HasComment("ส่งแจ้งเตือนหรือไม่?"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("คำนำหน้านาม"); + + b.Property("ReceiveUserId") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสอ้างอิงผู้ใช้งานระบบ"); + + b.Property("Sequence") + .HasColumnType("int") + .HasComment("ลำดับ"); + + b.HasKey("Id"); + + b.HasIndex("CommandId"); + + b.ToTable("CommandDeployments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Category") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทเอกสาร"); + + b.Property("CommandId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.HasIndex("CommandId"); + + b.HasIndex("DocumentId"); + + b.ToTable("CommandDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("BirthDate") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CommandId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงคำสั่ง"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text") + .HasComment("หมายเหตุ"); + + b.Property("Comment2") + .IsRequired() + .HasColumnType("text") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MouthSalaryAmount") + .HasColumnType("double") + .HasComment("เงินค่าตอบแทนรายเดือน"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("PositionLevel") + .HasColumnType("longtext") + .HasComment("ระดับ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง"); + + b.Property("PositionNumber") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double") + .HasComment("เงินประจำตำแหน่ง"); + + b.Property("PositionType") + .HasColumnType("longtext") + .HasComment("ประเภท"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("คำนำหน้านาม"); + + b.Property("RefDisciplineId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงไปยังข้อมูลวินัย"); + + b.Property("RefPlacementProfileId") + .HasColumnType("char(36)") + .HasComment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ"); + + b.Property("Sequence") + .HasColumnType("int") + .HasComment("ลำดับในบัญชีแนบท้าย"); + + b.HasKey("Id"); + + b.HasIndex("CommandId"); + + b.ToTable("CommandReceivers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สถานะของคำสั่ง"); + + b.Property("Sequence") + .HasColumnType("int") + .HasComment("ลำดับการทำงาน"); + + b.HasKey("Id"); + + b.ToTable("CommandStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ประเภทคำสั่ง"); + + b.Property("CommandCode") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสของประเภทคำสั่ง"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ชื่อคำสั่ง"); + + b.HasKey("Id"); + + b.ToTable("CommandTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.DeploymentChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsSendEmail") + .HasColumnType("tinyint(1)"); + + b.Property("IsSendInbox") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.ToTable("DeploymentChannels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ยังไม่ชัวใช้อะไรเป็นkey"); + + b.HasKey("Id"); + + b.ToTable("LimitLeaves"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitTypeLeave", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LimitLeaveId") + .HasColumnType("char(36)"); + + b.Property("NumLeave") + .HasColumnType("double") + .HasComment("จำนวนที่ลาได้"); + + b.Property("TypeLeaveId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LimitLeaveId"); + + b.HasIndex("TypeLeaveId"); + + b.ToTable("LimitTypeLeaves"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.Profile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Ability") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("AvatarId") + .HasColumnType("char(36)"); + + b.Property("AvatarRef") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("BloodGroupId") + .HasColumnType("char(36)") + .HasComment("Id กลุ่มเลือด"); + + b.Property("CitizenId") + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("รหัสบัตรประชาชน"); + + b.Property("Couple") + .HasColumnType("tinyint(1)") + .HasComment("คู่สมรส"); + + b.Property("CoupleCareer") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("อาชีพคู่สมรส"); + + b.Property("CoupleCitizenId") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่บัตรประชาชนคู่สมรส"); + + b.Property("CoupleFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อคู่สมรส"); + + b.Property("CoupleLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลคู่สมรส"); + + b.Property("CoupleLastNameOld") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลคู่สมรส(เดิม)"); + + b.Property("CoupleLive") + .HasColumnType("tinyint(1)") + .HasComment("มีชีวิตคู่สมรส"); + + b.Property("CouplePrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าคู่สมรส"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUser") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CurrentAddress") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ที่อยู่ปัจจุบัน"); + + b.Property("CurrentDistrictId") + .HasColumnType("char(36)") + .HasComment("Id เขตปัจจุบัน"); + + b.Property("CurrentProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดปัจจุบัน"); + + b.Property("CurrentSubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id แขวงปัจจุบัน"); + + b.Property("CurrentZipCode") + .HasMaxLength(5) + .HasColumnType("varchar(5)") + .HasComment("รหัสไปรษณีย์ปัจจุบัน"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("DateRetire") + .HasColumnType("datetime(6)"); + + b.Property("DateStart") + .HasColumnType("datetime(6)"); + + b.Property("DutyTimeEffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่รอบการลงเวลามีผล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รอบการลงเวลาเข้างาน"); + + b.Property("EmployeeClass") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ประเภทลูกจ้าง"); + + b.Property("EmployeeMoneyAllowance") + .HasColumnType("double") + .HasComment("เงินช่วยเหลือค่าครองชีพชั่วคราว"); + + b.Property("EmployeeMoneyEmployee") + .HasColumnType("double") + .HasComment("เงินสมทบประกันสังคม(ลูกจ้าง)"); + + b.Property("EmployeeMoneyEmployer") + .HasColumnType("double") + .HasComment("เงินสมทบประกันสังคม(นายจ้าง)"); + + b.Property("EmployeeMoneyIncrease") + .HasColumnType("double") + .HasComment("เงินเพิ่มการครองชีพชั่วคราว"); + + b.Property("EmployeeOc") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("EmployeeType") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ประเภทการจ้าง"); + + b.Property("EmployeeTypeIndividual") + .HasColumnType("longtext") + .HasComment("ประเภทบุคคล"); + + b.Property("EmployeeWage") + .HasColumnType("double") + .HasComment("ค่าจ้าง"); + + b.Property("EntryStatus") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.Property("FatherCareer") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("อาชีพบิดา"); + + b.Property("FatherCitizenId") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่บัตรประชาชนบิดา"); + + b.Property("FatherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อบิดา"); + + b.Property("FatherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลบิดา"); + + b.Property("FatherLive") + .HasColumnType("tinyint(1)") + .HasComment("มีชีวิตบิดา"); + + b.Property("FatherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าบิดา"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("FirstNameOld") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ(เดิม)"); + + b.Property("GenderId") + .HasColumnType("char(36)"); + + b.Property("GovAgeAbsent") + .HasColumnType("int"); + + b.Property("GovAgePlus") + .HasColumnType("int"); + + b.Property("GovernmentCode") + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsLeave") + .HasColumnType("tinyint(1)"); + + b.Property("IsProbation") + .HasColumnType("tinyint(1)"); + + b.Property("IsSendVerified") + .HasColumnType("tinyint(1)"); + + b.Property("IsTransfer") + .HasColumnType("tinyint(1)"); + + b.Property("IsVerified") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastNameOld") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล(เดิม)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveDateOrder") + .HasColumnType("datetime(6)"); + + b.Property("LeaveDetail") + .HasColumnType("longtext"); + + b.Property("LeaveNumberOrder") + .HasColumnType("longtext"); + + b.Property("LeaveReason") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("LimitLeaveId") + .HasColumnType("char(36)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("MotherCareer") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("อาชีพมารดา"); + + b.Property("MotherCitizenId") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่บัตรประชาชนมารดา"); + + b.Property("MotherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อมารดา"); + + b.Property("MotherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลมารดา"); + + b.Property("MotherLive") + .HasColumnType("tinyint(1)") + .HasComment("มีชีวิตมารดา"); + + b.Property("MotherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้ามารดา"); + + b.Property("Nationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติ"); + + b.Property("Oc") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("OcId") + .HasColumnType("char(36)") + .HasComment("Id สังกัด"); + + b.Property("OrganizationOrganization") + .HasColumnType("longtext"); + + b.Property("OrganizationOrganizationId") + .HasColumnType("char(36)"); + + b.Property("OrganizationShortName") + .HasColumnType("longtext"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)"); + + b.Property("Physical") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สถานภาพทางกาย"); + + b.Property("PosNoEmployee") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่งลูกจ้าง"); + + b.Property("PosNoId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeeGroupId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeeLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeeLineId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeePositionId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeePositionSideId") + .HasColumnType("char(36)"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveSide") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("PositionExecutiveSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้านทางการบริหาร"); + + b.Property("PositionId") + .HasColumnType("char(36)"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionLine") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("PositionLineId") + .HasColumnType("char(36)") + .HasComment("Id สายงาน"); + + b.Property("PositionPathSide") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้าน/สาขา"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)"); + + b.Property("PrefixId") + .HasColumnType("char(36)"); + + b.Property("PrefixOldId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้า(เดิม)"); + + b.Property("ProfileType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Race") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("เชื้อชาติ"); + + b.Property("ReasonSameDate") + .HasColumnType("longtext"); + + b.Property("RegistrationAddress") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("Id แขวงตามทะเบียนบ้าน"); + + b.Property("RegistrationDistrictId") + .HasColumnType("char(36)") + .HasComment("Id เขตตามทะเบียนบ้าน"); + + b.Property("RegistrationProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดตามทะเบียนบ้าน"); + + b.Property("RegistrationSame") + .HasColumnType("tinyint(1)") + .HasComment("ที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้านหรือไม่"); + + b.Property("RegistrationSubDistrictId") + .HasColumnType("char(36)") + .HasComment("แขวงตามทะเบียนบ้าน"); + + b.Property("RegistrationZipCode") + .HasMaxLength(5) + .HasColumnType("varchar(5)") + .HasComment("รหัสไปรษณีย์ตามทะเบียนบ้าน"); + + b.Property("RelationshipId") + .HasColumnType("char(36)") + .HasComment("Id สถานะภาพ"); + + b.Property("ReligionId") + .HasColumnType("char(36)") + .HasComment("Id ศาสนา"); + + b.Property("TelephoneNumber") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("เบอร์โทร"); + + b.Property("TransferDate") + .HasColumnType("datetime(6)"); + + b.Property("VerifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("VerifiedUser") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("AvatarId"); + + b.HasIndex("GenderId"); + + b.HasIndex("LimitLeaveId"); + + b.HasIndex("PosNoId"); + + b.HasIndex("PositionEmployeeGroupId"); + + b.HasIndex("PositionEmployeeLevelId"); + + b.HasIndex("PositionEmployeeLineId"); + + b.HasIndex("PositionEmployeePositionId"); + + b.HasIndex("PositionEmployeePositionSideId"); + + b.HasIndex("PositionId"); + + b.HasIndex("PositionLevelId"); + + b.HasIndex("PositionTypeId"); + + b.HasIndex("PrefixId"); + + b.ToTable("Profiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbility", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEnd") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุด"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่มต้น"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("Field") + .HasColumnType("longtext") + .HasComment("ด้าน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileAbilitys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbilityHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEnd") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุด"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่มต้น"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("Field") + .HasColumnType("longtext") + .HasComment("ด้าน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileAbilityId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileAbilityId"); + + b.ToTable("ProfileAbilityHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAddressHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CurrentAddress") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ที่อยู่ปัจจุบัน"); + + b.Property("CurrentDistrict") + .HasColumnType("longtext") + .HasComment("เขตปัจจุบัน"); + + b.Property("CurrentDistrictId") + .HasColumnType("char(36)") + .HasComment("Id เขตปัจจุบัน"); + + b.Property("CurrentProvince") + .HasColumnType("longtext") + .HasComment("จังหวัดปัจจุบัน"); + + b.Property("CurrentProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดปัจจุบัน"); + + b.Property("CurrentSubDistrict") + .HasColumnType("longtext") + .HasComment("แขวงปัจจุบัน"); + + b.Property("CurrentSubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id แขวงปัจจุบัน"); + + b.Property("CurrentZipCode") + .HasMaxLength(5) + .HasColumnType("varchar(5)") + .HasComment("รหัสไปรษณีย์ปัจจุบัน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RegistrationAddress") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistrationDistrict") + .HasColumnType("longtext") + .HasComment("เขตตามทะเบียนบ้าน"); + + b.Property("RegistrationDistrictId") + .HasColumnType("char(36)") + .HasComment("Id เขตตามทะเบียนบ้าน"); + + b.Property("RegistrationProvince") + .HasColumnType("longtext") + .HasComment("จังหวัดตามทะเบียนบ้าน"); + + b.Property("RegistrationProvinceId") + .HasColumnType("char(36)") + .HasComment("Id จังหวัดตามทะเบียนบ้าน"); + + b.Property("RegistrationSame") + .HasColumnType("tinyint(1)") + .HasComment("ที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้านหรือไม่"); + + b.Property("RegistrationSubDistrict") + .HasColumnType("longtext") + .HasComment("แขวงตามทะเบียนบ้าน"); + + b.Property("RegistrationSubDistrictId") + .HasColumnType("char(36)") + .HasComment("Id แขวงตามทะเบียนบ้าน"); + + b.Property("RegistrationZipCode") + .HasMaxLength(5) + .HasColumnType("varchar(5)") + .HasComment("รหัสไปรษณีย์ตามทะเบียนบ้าน"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileAddressHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ชื่อแบบประเมิน"); + + b.Property("Point1") + .HasColumnType("double") + .HasComment("ผลประเมินส่วนที่1 (คะแนน)"); + + b.Property("Point1Total") + .HasColumnType("double") + .HasComment("ส่วนที่1 (คะแนน)"); + + b.Property("Point2") + .HasColumnType("double") + .HasComment("ผลประเมินส่วนที่2 (คะแนน)"); + + b.Property("Point2Total") + .HasColumnType("double") + .HasComment("ส่วนที่2 (คะแนน)"); + + b.Property("PointSum") + .HasColumnType("double") + .HasComment("ผลประเมินรวม (คะแนน)"); + + b.Property("PointSumTotal") + .HasColumnType("double") + .HasComment("ผลรวม (คะแนน)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileAssessments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAssessmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ชื่อแบบประเมิน"); + + b.Property("Point1") + .HasColumnType("double") + .HasComment("ผลประเมินส่วนที่1 (คะแนน)"); + + b.Property("Point1Total") + .HasColumnType("double") + .HasComment("ส่วนที่1 (คะแนน)"); + + b.Property("Point2") + .HasColumnType("double") + .HasComment("ผลประเมินส่วนที่2 (คะแนน)"); + + b.Property("Point2Total") + .HasColumnType("double") + .HasComment("ส่วนที่2 (คะแนน)"); + + b.Property("PointSum") + .HasColumnType("double") + .HasComment("ผลประเมินรวม (คะแนน)"); + + b.Property("PointSumTotal") + .HasColumnType("double") + .HasComment("ผลรวม (คะแนน)"); + + b.Property("ProfileAssessmentId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileAssessmentId"); + + b.ToTable("ProfileAssessmentHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAvatarHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AvatarFileId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("AvatarFileId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileAvatarHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCertificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่ใบอนุญาต"); + + b.Property("CertificateType") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อใบอนุญาต"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExpireDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่หมดอายุ"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกใบอนุญาต"); + + b.Property("Issuer") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานผู้ออกใบอนุญาต"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileCertificates"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCertificateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่ใบอนุญาต"); + + b.Property("CertificateType") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อใบอนุญาต"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExpireDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่หมดอายุ"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกใบอนุญาต"); + + b.Property("Issuer") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานผู้ออกใบอนุญาต"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileCertificateId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileCertificateId"); + + b.ToTable("ProfileCertificateHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChangeName", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("FirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("LastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("PrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้า"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สถานะ"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileChangeNames"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChangeNameHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("FirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("LastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("PrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้า"); + + b.Property("ProfileChangeNameId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สถานะ"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("ProfileChangeNameId"); + + b.ToTable("ProfileChangeNameHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChildren", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ChildrenCareer") + .HasColumnType("longtext") + .HasComment("อาชีพบุตร"); + + b.Property("ChildrenFirstName") + .HasColumnType("longtext") + .HasComment("ชื่อบุตร"); + + b.Property("ChildrenLastName") + .HasColumnType("longtext") + .HasComment("นามสกุลบุตร"); + + b.Property("ChildrenPrefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้าบุตร"); + + b.Property("ChildrenPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าบุตร"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileChildrens"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChildrenHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ChildrenCareer") + .HasColumnType("longtext") + .HasComment("อาชีพบุตร"); + + b.Property("ChildrenFirstName") + .HasColumnType("longtext") + .HasComment("ชื่อบุตร"); + + b.Property("ChildrenLastName") + .HasColumnType("longtext") + .HasComment("นามสกุลบุตร"); + + b.Property("ChildrenPrefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้าบุตร"); + + b.Property("ChildrenPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าบุตร"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileChildrenId") + .HasColumnType("char(36)"); + + b.Property("ProfileFamilyHistoryId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileChildrenId"); + + b.HasIndex("ProfileFamilyHistoryId"); + + b.ToTable("ProfileChildrenHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCoupleHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Career") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileCoupleHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCurrentAddressHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("DistrictId") + .HasColumnType("char(36)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProvinceId") + .HasColumnType("char(36)"); + + b.Property("SubDistrictId") + .HasColumnType("char(36)"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileCurrentAddressHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDiscipline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี"); + + b.Property("Detail") + .HasColumnType("text") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Level") + .HasColumnType("longtext") + .HasComment("ระดับความผิด"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RefCommandDate") + .HasColumnType("datetime(6)") + .HasComment("เอกสารอ้างอิง (ลงวันที่)"); + + b.Property("RefCommandNo") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileDisciplines"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDisciplineHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี"); + + b.Property("Detail") + .HasColumnType("text") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Level") + .HasColumnType("longtext") + .HasComment("ระดับความผิด"); + + b.Property("ProfileDisciplineId") + .HasColumnType("char(36)"); + + b.Property("RefCommandDate") + .HasColumnType("datetime(6)") + .HasComment("เอกสารอ้างอิง (ลงวันที่)"); + + b.Property("RefCommandNo") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileDisciplineId"); + + b.ToTable("ProfileDisciplineHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDuty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEnd") + .HasColumnType("datetime(6)") + .HasComment("สิ้นสุด"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("เริ่มต้น"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileDutys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDutyHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEnd") + .HasColumnType("datetime(6)") + .HasComment("สิ้นสุด"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("เริ่มต้น"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileDutyId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.HasKey("Id"); + + b.HasIndex("ProfileDutyId"); + + b.ToTable("ProfileDutyHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEducation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Country") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ประเทศ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("วุฒิการศึกษา"); + + b.Property("Duration") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ระยะเวลา"); + + b.Property("DurationYear") + .HasColumnType("int") + .HasComment("ระยะเวลาหลักสูตร"); + + b.Property("EducationLevel") + .HasColumnType("longtext") + .HasComment("ระดับศึกษา"); + + b.Property("EducationLevelId") + .HasColumnType("char(36)") + .HasComment("Id ระดับศึกษา"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("ถึง"); + + b.Property("Field") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("สาขาวิชา/ทาง"); + + b.Property("FinishDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สำเร็จการศึกษา"); + + b.Property("FundName") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ทุน"); + + b.Property("Gpa") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เกรดเฉลี่ย"); + + b.Property("Institute") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("สถานศึกษา"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Note") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("Other") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ข้อมูลการติดต่อ"); + + b.Property("PositionPath") + .HasColumnType("longtext") + .HasComment("เป็นวุฒิการศึกษาในตำแหน่ง"); + + b.Property("PositionPathId") + .HasColumnType("char(36)") + .HasComment("Id เป็นวุฒิการศึกษาในตำแหน่ง"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileEducations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEducationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Country") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ประเทศ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("วุฒิการศึกษา"); + + b.Property("Duration") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ระยะเวลา"); + + b.Property("DurationYear") + .HasColumnType("int") + .HasComment("ระยะเวลาหลักสูตร"); + + b.Property("EducationLevel") + .HasColumnType("longtext") + .HasComment("ระดับศึกษา"); + + b.Property("EducationLevelId") + .HasColumnType("char(36)") + .HasComment("Id ระดับศึกษา"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("ถึง"); + + b.Property("Field") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("สาขาวิชา/ทาง"); + + b.Property("FinishDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สำเร็จการศึกษา"); + + b.Property("FundName") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ทุน"); + + b.Property("Gpa") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เกรดเฉลี่ย"); + + b.Property("Institute") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("สถานศึกษา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Note") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("Other") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ข้อมูลการติดต่อ"); + + b.Property("PositionPath") + .HasColumnType("longtext") + .HasComment("เป็นวุฒิการศึกษาในตำแหน่ง"); + + b.Property("PositionPathId") + .HasColumnType("char(36)") + .HasComment("Id เป็นวุฒิการศึกษาในตำแหน่ง"); + + b.Property("ProfileEducationId") + .HasColumnType("char(36)"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่"); + + b.HasKey("Id"); + + b.HasIndex("ProfileEducationId"); + + b.ToTable("ProfileEducationHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmployment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Command") + .HasColumnType("longtext") + .HasComment("คำสั่ง"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่จ้าง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileEmployments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmploymentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Command") + .HasColumnType("longtext") + .HasComment("คำสั่ง"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่จ้าง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileEmploymentId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileEmploymentId"); + + b.ToTable("ProfileEmploymentHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Couple") + .HasColumnType("tinyint(1)") + .HasComment("คู่สมรส"); + + b.Property("CoupleCareer") + .HasColumnType("longtext") + .HasComment("อาชีพคู่สมรส"); + + b.Property("CoupleFirstName") + .HasColumnType("longtext") + .HasComment("ชื่อคู่สมรส"); + + b.Property("CoupleLastName") + .HasColumnType("longtext") + .HasComment("นามสกุลคู่สมรส"); + + b.Property("CoupleLastNameOld") + .HasColumnType("longtext") + .HasComment("นามสกุลคู่สมรส(เดิม)"); + + b.Property("CouplePrefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้าคู่สมรส"); + + b.Property("CouplePrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าคู่สมรส"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FatherCareer") + .HasColumnType("longtext") + .HasComment("อาชีพบิดา"); + + b.Property("FatherFirstName") + .HasColumnType("longtext") + .HasComment("ชื่อบิดา"); + + b.Property("FatherLastName") + .HasColumnType("longtext") + .HasComment("นามสกุลบิดา"); + + b.Property("FatherPrefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้าบิดา"); + + b.Property("FatherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้าบิดา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MotherCareer") + .HasColumnType("longtext") + .HasComment("อาชีพมารดา"); + + b.Property("MotherFirstName") + .HasColumnType("longtext") + .HasComment("ชื่อมารดา"); + + b.Property("MotherLastName") + .HasColumnType("longtext") + .HasComment("นามสกุลมารดา"); + + b.Property("MotherPrefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้ามารดา"); + + b.Property("MotherPrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้ามารดา"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileFamilyHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFatherHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Career") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileFatherHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileGovernmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)") + .HasComment("วันที่สั่งบรรจุ"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("เริ่มปฎิบัติราชการ"); + + b.Property("GovAge") + .HasColumnType("longtext") + .HasComment("อายุราชการ"); + + b.Property("GovAgeAbsent") + .HasColumnType("int") + .HasComment("ขาดราชการ"); + + b.Property("GovAgePlus") + .HasColumnType("int") + .HasComment("อายุราชการเกื้อกูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Oc") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("OcId") + .HasColumnType("char(36)") + .HasComment("Id สังกัด"); + + b.Property("PosNo") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("PosNoId") + .HasColumnType("char(36)") + .HasComment("Id เลขที่ตำแหน่ง"); + + b.Property("Position") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง"); + + b.Property("PositionEmployeeGroup") + .HasColumnType("longtext") + .HasComment("กลุ่มงาน"); + + b.Property("PositionEmployeeLevel") + .HasColumnType("longtext") + .HasComment("ระดับชั้นงาน"); + + b.Property("PositionEmployeePosition") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง"); + + b.Property("PositionEmployeePositionSide") + .HasColumnType("longtext") + .HasComment("ด้านของตำแหน่ง"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionLevel") + .HasColumnType("longtext") + .HasComment("ระดับตำแหน่ง"); + + b.Property("PositionLine") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("PositionType") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่ง"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ReasonSameDate") + .HasColumnType("longtext") + .HasComment("เหตุผลกรณีไม่ตรงวัน"); + + b.Property("RetireDate") + .HasColumnType("longtext") + .HasComment("วันเกษียณอายุ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileGovernmentHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("BloodGroup") + .HasColumnType("longtext") + .HasComment("กลุ่มเลือด"); + + b.Property("BloodGroupId") + .HasColumnType("char(36)") + .HasComment("Id กลุ่มเลือด"); + + b.Property("CitizenId") + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("รหัสบัตรประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EmployeeClass") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ประเภทลูกจ้าง"); + + b.Property("EmployeeType") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ประเภทการจ้าง"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("Gender") + .HasColumnType("longtext") + .HasComment("เพศ"); + + b.Property("GenderId") + .HasColumnType("char(36)") + .HasComment("Id เพศ"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Nationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติ"); + + b.Property("Prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("PrefixId") + .HasColumnType("char(36)") + .HasComment("Id คำนำหน้า"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Race") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("เชื้อชาติ"); + + b.Property("Relationship") + .HasColumnType("longtext") + .HasComment("สถานะภาพ"); + + b.Property("RelationshipId") + .HasColumnType("char(36)") + .HasComment("Id สถานะภาพ"); + + b.Property("Religion") + .HasColumnType("longtext") + .HasComment("ศาสนา"); + + b.Property("ReligionId") + .HasColumnType("char(36)") + .HasComment("Id ศาสนา"); + + b.Property("TelephoneNumber") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("เบอร์โทร"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHonor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)") + .HasComment("รายละเอียด"); + + b.Property("IsDate") + .HasColumnType("tinyint(1)") + .HasComment("ประเภทช่วงเวลา"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("Issuer") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานที่ออก"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileHonors"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHonorHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)") + .HasComment("รายละเอียด"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("Issuer") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานที่ออก"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileHonorId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileHonorId"); + + b.ToTable("ProfileHonorHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsignia", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAnnounce") + .HasColumnType("datetime(6)") + .HasComment("วันที่ประกาศในราชกิจจาฯ"); + + b.Property("InsigniaId") + .HasColumnType("char(36)"); + + b.Property("InsigniaType") + .HasColumnType("longtext") + .HasComment("ประเภท"); + + b.Property("Issue") + .HasMaxLength(300) + .HasColumnType("varchar(300)") + .HasComment("ราชกิจจาฯ ฉบับที่"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("No") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ลำดับที่"); + + b.Property("Note") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("Page") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("หน้า"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่"); + + b.Property("RefCommandDate") + .HasColumnType("datetime(6)") + .HasComment("เอกสารอ้างอิง (ลงวันที่)"); + + b.Property("RefCommandNo") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)"); + + b.Property("Section") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("ตอน"); + + b.Property("Volume") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("เล่ม"); + + b.Property("VolumeNo") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("เล่มที่"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปีที่ยื่นขอ"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileInsignias"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsigniaHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAnnounce") + .HasColumnType("datetime(6)") + .HasComment("วันที่ประกาศในราชกิจจาฯ"); + + b.Property("Insignia") + .HasColumnType("longtext") + .HasComment("ชื่อเครื่องราชฯ"); + + b.Property("InsigniaId") + .HasColumnType("char(36)"); + + b.Property("InsigniaType") + .HasColumnType("longtext") + .HasComment("ประเภท"); + + b.Property("Issue") + .HasMaxLength(300) + .HasColumnType("varchar(300)") + .HasComment("ราชกิจจาฯ ฉบับที่"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("No") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("ลำดับที่"); + + b.Property("Note") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("Page") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("หน้า"); + + b.Property("ProfileInsigniaId") + .HasColumnType("char(36)"); + + b.Property("ReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("ลงวันที่"); + + b.Property("Section") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("ตอน"); + + b.Property("Volume") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("เล่ม"); + + b.Property("VolumeNo") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasComment("เล่มที่"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปีที่ยื่นขอ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileInsigniaId"); + + b.ToTable("ProfileInsigniaHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeave", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEndLeave") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี ที่สิ้นสุดลา"); + + b.Property("DateStartLeave") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี ที่เริ่มลา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("NumLeave") + .HasColumnType("double") + .HasComment("ลาครั้งที่"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะ"); + + b.Property("SumLeave") + .HasColumnType("double") + .HasComment("ลามาแล้ว"); + + b.Property("TotalLeave") + .HasColumnType("double") + .HasComment("รวมเป็น"); + + b.Property("TypeLeaveId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.HasIndex("TypeLeaveId"); + + b.ToTable("ProfileLeaves"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeaveHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEndLeave") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี ที่สิ้นสุดลา"); + + b.Property("DateStartLeave") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี ที่เริ่มลา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("NumLeave") + .HasColumnType("double") + .HasComment("ลาครั้งที่"); + + b.Property("ProfileLeaveId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะ"); + + b.Property("SumLeave") + .HasColumnType("double") + .HasComment("ลามาแล้ว"); + + b.Property("TotalLeave") + .HasColumnType("double") + .HasComment("รวมเป็น"); + + b.Property("TypeLeaveId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileLeaveId"); + + b.HasIndex("TypeLeaveId"); + + b.ToTable("ProfileLeaveHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeaveSummary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveYear") + .HasColumnType("int"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("SumAbsent") + .HasColumnType("longtext"); + + b.Property("SumEducation") + .HasColumnType("longtext"); + + b.Property("SumLate") + .HasColumnType("longtext"); + + b.Property("SumRest") + .HasColumnType("longtext"); + + b.Property("SumSick") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileLeaveSummary"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileMotherHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Career") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileMotherHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileNopaid", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileNopaids"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileNopaidHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileNopaidId") + .HasColumnType("char(36)"); + + b.Property("Reference") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.HasKey("Id"); + + b.HasIndex("ProfileNopaidId"); + + b.ToTable("ProfileNopaidHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOrganization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationId") + .HasColumnType("char(36)") + .HasComment("Id หน่วยงานที่สังกัด"); + + b.Property("UserId") + .HasColumnType("char(36)") + .HasComment("User Id KeyCloak"); + + b.HasKey("Id"); + + b.ToTable("ProfileOrganizations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOther", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileOthers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOtherHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่"); + + b.Property("Detail") + .HasColumnType("longtext") + .HasComment("รายละเอียด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileOtherId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileOtherId"); + + b.ToTable("ProfileOtherHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfilePaper", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CategoryName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasComment("ประเภทไฟล์-ไม่ใช้"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasComment("ชื่อไฟล์"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfilePapers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileRegistrationAddressHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("DistrictId") + .HasColumnType("char(36)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProvinceId") + .HasColumnType("char(36)"); + + b.Property("SubDistrictId") + .HasColumnType("char(36)"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("varchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileRegistrationAddressHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AgencyName") + .HasColumnType("longtext") + .HasComment("AgencyName"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("CLevel") + .HasColumnType("longtext") + .HasComment("CLevel"); + + b.Property("CommandNo") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เลขที่คำสั่ง"); + + b.Property("CommandTypeName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทคำสั่ง"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี รับตำแหน่ง"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MouthSalaryAmount") + .HasColumnType("double") + .HasComment("เงินค่าตอบแทนรายเดือน"); + + b.Property("OcId") + .HasColumnType("char(36)") + .HasComment("Id สังกัด"); + + b.Property("Order") + .HasColumnType("int") + .HasComment("ลำดับ"); + + b.Property("OrgName") + .HasColumnType("longtext") + .HasComment("OrgName"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)") + .HasComment("Id ชื่อย่อหน่วยงาน"); + + b.Property("PosNoEmployee") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่งลูกจ้าง"); + + b.Property("PosNoId") + .HasColumnType("char(36)") + .HasComment("Id เลขที่ตำแหน่ง"); + + b.Property("PosNoName") + .HasColumnType("longtext") + .HasComment("PosNoName"); + + b.Property("PositionEmployeeGroupId") + .HasColumnType("char(36)") + .HasComment("Id กลุ่มงาน"); + + b.Property("PositionEmployeeLevelId") + .HasColumnType("char(36)") + .HasComment(" Id ระดับชั้นงาน"); + + b.Property("PositionEmployeePositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionEmployeePositionSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้านของตำแหน่ง"); + + b.Property("PositionExecutiveId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveName") + .HasColumnType("longtext") + .HasComment("PositionExecutiveName"); + + b.Property("PositionExecutiveSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้านทางการบริหาร"); + + b.Property("PositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionLevelName") + .HasColumnType("longtext"); + + b.Property("PositionLineId") + .HasColumnType("char(36)") + .HasComment("Id สายงาน"); + + b.Property("PositionLineName") + .HasColumnType("longtext") + .HasComment("PositionLineName"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("PositionName"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้าน/สาขา"); + + b.Property("PositionPathSideName") + .HasColumnType("longtext") + .HasComment("PositionPathSideName"); + + b.Property("PositionRef") + .HasColumnType("longtext"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double") + .HasComment("เงินประจำตำแหน่ง"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)") + .HasComment("Id ประเภทตำแหน่ง"); + + b.Property("PositionTypeName") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RefCommandNo") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)"); + + b.Property("SalaryClass") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง (รายละเอียด)"); + + b.Property("SalaryRef") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.Property("SalaryStatus") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่งกรณีพิเศษ"); + + b.HasKey("Id"); + + b.HasIndex("PositionLevelId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileSalaries"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปี รับตำแหน่ง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MouthSalaryAmount") + .HasColumnType("double") + .HasComment("เงินค่าตอบแทนรายเดือน"); + + b.Property("Oc") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("OcId") + .HasColumnType("char(36)") + .HasComment("Id สังกัด"); + + b.Property("OrganizationShortName") + .HasColumnType("longtext"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)"); + + b.Property("PosNo") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("PosNoEmployee") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่งลูกจ้าง"); + + b.Property("PosNoId") + .HasColumnType("char(36)") + .HasComment("Id เลขที่ตำแหน่ง"); + + b.Property("Position") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง"); + + b.Property("PositionEmployeeGroup") + .HasColumnType("longtext") + .HasComment("กลุ่มงาน"); + + b.Property("PositionEmployeeGroupId") + .HasColumnType("char(36)") + .HasComment("Id กลุ่มงาน"); + + b.Property("PositionEmployeeLevel") + .HasColumnType("longtext") + .HasComment("ระดับชั้นงาน"); + + b.Property("PositionEmployeeLevelId") + .HasColumnType("char(36)") + .HasComment(" Id ระดับชั้นงาน"); + + b.Property("PositionEmployeePosition") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง"); + + b.Property("PositionEmployeePositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionEmployeePositionSide") + .HasColumnType("longtext") + .HasComment("ด้านของตำแหน่ง"); + + b.Property("PositionEmployeePositionSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้านของตำแหน่ง"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveId") + .HasColumnType("char(36)") + .HasComment("Id ด้านทางการบริหาร"); + + b.Property("PositionExecutiveSide") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("PositionExecutiveSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้านทางการบริหาร"); + + b.Property("PositionId") + .HasColumnType("char(36)") + .HasComment("Id ตำแหน่ง"); + + b.Property("PositionLevel") + .HasColumnType("longtext") + .HasComment("ระดับ"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)") + .HasComment(" Id ระดับ"); + + b.Property("PositionLine") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("PositionLineId") + .HasColumnType("char(36)") + .HasComment("Id สายงาน"); + + b.Property("PositionPathSide") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)") + .HasComment("Id ด้าน/สาขา"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double") + .HasComment("เงินประจำตำแหน่ง"); + + b.Property("PositionType") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่ง"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)") + .HasComment("Id ประเภทตำแหน่ง"); + + b.Property("ProfileSalaryId") + .HasColumnType("char(36)"); + + b.Property("SalaryClass") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง (รายละเอียด)"); + + b.Property("SalaryRef") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.HasKey("Id"); + + b.HasIndex("ProfileSalaryId"); + + b.ToTable("ProfileSalaryHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryOrganization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("ProfileSalaryOrganizations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryPosition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("PositionId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.ToTable("ProfileSalaryPositions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryPositionLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("ProfileSalaryPositionLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryPositionNumber", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("ProfileSalaryPositionsNumbers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryPositionType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasComment("ไม่ใช้"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.HasKey("Id"); + + b.ToTable("ProfileSalaryPositionTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileTraining", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOrder") + .HasColumnType("datetime(6)") + .HasComment("คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"); + + b.Property("Department") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานที่รับผิดชอบจัดการฝึกอบรม/ดูงาน"); + + b.Property("Duration") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("รวมระยะเวลาในการฝึกอบรม/ดูงาน"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุดการฝึกอบรม/ดูงาน"); + + b.Property("IsDate") + .HasColumnType("tinyint(1)") + .HasComment("ประเภทช่วงเวลา"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ชื่อโครงการ/หลักสูตรการฝึกอบรม"); + + b.Property("NumberOrder") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"); + + b.Property("Place") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("สถานที่ฝึกอบรม/ดูงาน"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้นการฝึกอบรม/ดูงาน"); + + b.Property("Topic") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หัวข้อการฝึกอบรม/ดูงาน"); + + b.Property("Yearly") + .HasMaxLength(200) + .HasColumnType("int") + .HasComment("ปีที่อบรม (พ.ศ.)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfileTrainings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileTrainingHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOrder") + .HasColumnType("datetime(6)") + .HasComment("คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่"); + + b.Property("Department") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานที่รับผิดชอบจัดการฝึกอบรม/ดูงาน"); + + b.Property("Duration") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("รวมระยะเวลาในการฝึกอบรม/ดูงาน"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุดการฝึกอบรม/ดูงาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ชื่อโครงการ/หลักสูตรการฝึกอบรม"); + + b.Property("NumberOrder") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ"); + + b.Property("Place") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("สถานที่ฝึกอบรม/ดูงาน"); + + b.Property("ProfileTrainingId") + .HasColumnType("char(36)"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้นการฝึกอบรม/ดูงาน"); + + b.Property("Topic") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หัวข้อการฝึกอบรม/ดูงาน"); + + b.Property("Yearly") + .HasMaxLength(200) + .HasColumnType("int") + .HasComment("ปีที่อบรม (พ.ศ.)"); + + b.HasKey("Id"); + + b.HasIndex("ProfileTrainingId"); + + b.ToTable("ProfileTrainingHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.TypeLeave", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasColumnType("longtext") + .HasComment("ประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("TypeLeaves"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaEmployee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaPeriodId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RefId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่งลูกจ้าง"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaPeriodId"); + + b.ToTable("InsigniaEmployees"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Total") + .HasColumnType("int") + .HasComment("จำนวนทั้งหมด"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปี"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaId"); + + b.ToTable("InsigniaManages"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManageOrganiation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaManageId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("รหัสหน่วยงาน"); + + b.Property("OrganizationId") + .HasColumnType("char(36)") + .HasComment("รหัสหน่วยงาน"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Total") + .HasColumnType("int") + .HasComment("จำนวนทั้งหมด"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaManageId"); + + b.ToTable("InsigniaManageOrganiations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManageProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BorrowDate") + .HasColumnType("datetime(6)") + .HasComment("ยืมวันที่"); + + b.Property("BorrowOrganization") + .HasColumnType("longtext"); + + b.Property("BorrowOrganizationId") + .HasColumnType("char(36)") + .HasComment("Fk Table OrganizationOrganization Borrow"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaManageOrganiationId") + .HasColumnType("char(36)"); + + b.Property("InsigniaNoteProfileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ReturnDate") + .HasColumnType("datetime(6)") + .HasComment("คืนวันที่"); + + b.Property("ReturnOrganization") + .HasColumnType("longtext"); + + b.Property("ReturnOrganizationId") + .HasColumnType("char(36)") + .HasComment("Fk Table OrganizationOrganization Return"); + + b.Property("ReturnReason") + .HasColumnType("longtext") + .HasComment("เหตุผลคืน"); + + b.Property("Status") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการคืน"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaManageOrganiationId"); + + b.HasIndex("InsigniaNoteProfileId"); + + b.ToTable("InsigniaManageProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("InsigniaNotes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("InsigniaNoteId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("InsigniaNoteId"); + + b.ToTable("InsigniaNoteDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Address") + .HasColumnType("longtext") + .HasComment("ที่อยู่ที่จ่าย"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("DatePayment") + .HasColumnType("datetime(6)") + .HasComment("วันที่จ่ายใบกำกับ"); + + b.Property("DateReceive") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับพระราชทานเครื่องราชฯ"); + + b.Property("DateReceiveInsignia") + .HasColumnType("datetime(6)") + .HasComment("วันที่รับเครื่องราชฯ"); + + b.Property("DateReturnInsignia") + .HasColumnType("datetime(6)") + .HasComment("วันที่คืนเครื่องราชฯ"); + + b.Property("DocReceiveInsigniaId") + .HasColumnType("char(36)"); + + b.Property("DocReturnInsigniaId") + .HasColumnType("char(36)"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("InsigniaNoteId") + .HasColumnType("char(36)"); + + b.Property("IsApprove") + .HasColumnType("tinyint(1)"); + + b.Property("Issue") + .HasColumnType("longtext") + .HasComment("ทะเบียนฐานันดร"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("No") + .HasColumnType("longtext") + .HasComment("ลำดับที่"); + + b.Property("Number") + .HasColumnType("longtext") + .HasComment("หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ"); + + b.Property("OrgReceiveInsignia") + .HasColumnType("longtext") + .HasComment("หน่วยงานรับเครื่องราชฯ"); + + b.Property("OrgReceiveInsigniaId") + .HasColumnType("char(36)") + .HasComment("หน่วยงานรับเครื่องราชฯ"); + + b.Property("OrgReturnInsignia") + .HasColumnType("longtext") + .HasComment("หน่วยงานคืนเครื่องราชฯ"); + + b.Property("OrgReturnInsigniaId") + .HasColumnType("char(36)") + .HasComment("หน่วยงานคืนเครื่องราชฯ"); + + b.Property("OrganizationOrganizationReceive") + .HasColumnType("longtext") + .HasComment("สังกัด ณ วันที่ได้รับพระราชทานเครื่องราชฯ"); + + b.Property("OrganizationOrganizationSend") + .HasColumnType("longtext") + .HasComment("สังกัด ณ วันที่ขอพระราชทานเครื่องราชฯ"); + + b.Property("Page") + .HasColumnType("longtext") + .HasComment("หน้าที่"); + + b.Property("PosLevelName") + .HasColumnType("longtext"); + + b.Property("PosNo") + .HasColumnType("longtext"); + + b.Property("PosTypeName") + .HasColumnType("longtext"); + + b.Property("Position") + .HasColumnType("longtext"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RequestDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestInsigniaId") + .HasColumnType("char(36)"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("Salary") + .HasColumnType("double"); + + b.Property("Section") + .HasColumnType("longtext") + .HasComment("ตอนที่"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะตำแหน่งที่ยื่นขอ"); + + b.Property("TypePayment") + .HasColumnType("longtext") + .HasComment("รูปแบบการจ่าย"); + + b.Property("VolumeNo") + .HasColumnType("longtext") + .HasComment("เล่มที่"); + + b.HasKey("Id"); + + b.HasIndex("DocReceiveInsigniaId"); + + b.HasIndex("DocReturnInsigniaId"); + + b.HasIndex("InsigniaNoteId"); + + b.HasIndex("RequestInsigniaId"); + + b.ToTable("InsigniaNoteProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasMaxLength(50) + .HasColumnType("int") + .HasComment("จำนวนวันแจ้งเตือนล่วงหน้า"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุด"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("IsLock") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการ Freez ข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ชื่อรอบเสนอขอเครื่องราชฯ"); + + b.Property("ReliefDocId") + .HasColumnType("char(36)"); + + b.Property("RevisionId") + .HasColumnType("char(36)"); + + b.Property("Round") + .HasColumnType("int") + .HasComment("ราบการยื่นขอ"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่ม"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("ประเภทการขอ"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปี"); + + b.HasKey("Id"); + + b.HasIndex("ReliefDocId"); + + b.ToTable("InsigniaPeriods"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaReclaimProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaNoteProfileId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ReclaimDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เรียกคืน"); + + b.Property("ReclaimOrganization") + .HasColumnType("longtext"); + + b.Property("ReclaimOrganizationId") + .HasColumnType("char(36)") + .HasComment("Fk Table OrganizationOrganization Borrow"); + + b.Property("ReclaimReason") + .HasColumnType("longtext") + .HasComment("เหตุผลในการเรียกคืน"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaNoteProfileId"); + + b.ToTable("InsigniaReclaimProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("PeriodId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RequestNote") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PeriodId"); + + b.ToTable("InsigniaRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequestProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("APR1") + .HasColumnType("longtext"); + + b.Property("APR2") + .HasColumnType("longtext"); + + b.Property("APR3") + .HasColumnType("longtext"); + + b.Property("APR4") + .HasColumnType("longtext"); + + b.Property("APR5") + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsApprove") + .HasColumnType("tinyint(1)"); + + b.Property("LastInsigniaName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MarkDiscipline") + .HasColumnType("tinyint(1)") + .HasComment("แจ้งเตือน มีโทษทางวินัย"); + + b.Property("MarkInsignia") + .HasColumnType("tinyint(1)"); + + b.Property("MarkLeave") + .HasColumnType("tinyint(1)") + .HasComment("แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน"); + + b.Property("MarkRate") + .HasColumnType("tinyint(1)") + .HasComment("แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)"); + + b.Property("MatchingConditions") + .HasColumnType("text") + .HasComment("รายละเอียดเครื่องราชฯที่ขอ"); + + b.Property("OCT1") + .HasColumnType("longtext"); + + b.Property("OCT2") + .HasColumnType("longtext"); + + b.Property("OCT3") + .HasColumnType("longtext"); + + b.Property("OCT4") + .HasColumnType("longtext"); + + b.Property("OCT5") + .HasColumnType("longtext"); + + b.Property("PosLevelName") + .HasColumnType("longtext"); + + b.Property("PosNo") + .HasColumnType("longtext"); + + b.Property("PosTypeName") + .HasColumnType("longtext"); + + b.Property("Position") + .HasColumnType("longtext"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลการได้รับเครื่องราชฯ"); + + b.Property("ReasonReject") + .HasColumnType("longtext") + .HasComment("เหตุผลไม่ยื่นขอ"); + + b.Property("RequestDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestId") + .HasColumnType("char(36)"); + + b.Property("RequestInsigniaId") + .HasColumnType("char(36)"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("Salary") + .HasColumnType("double"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะตำแหน่งที่ยื่นขอ"); + + b.HasKey("Id"); + + b.HasIndex("RequestId"); + + b.HasIndex("RequestInsigniaId"); + + b.ToTable("InsigniaRequestProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.BloodGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("varchar(2)") + .HasColumnOrder(1) + .HasComment("ชื่อหมู่โลหิต"); + + b.HasKey("Id"); + + b.ToTable("BloodGroups"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.District", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)") + .HasColumnOrder(1) + .HasComment("เขต/อำเภอ"); + + b.Property("ProvinceId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ProvinceId"); + + b.ToTable("Districts"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.EducationLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ระดับการศึกษา"); + + b.HasKey("Id"); + + b.ToTable("EducationLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Gender", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnOrder(1) + .HasComment("เพศ"); + + b.HasKey("Id"); + + b.ToTable("Genders"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Holiday", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Category") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(6) + .HasComment("ประเภทของวันหยุดสำหรับ ทำงาน 5 วัน=`NORMAL`,ทำงาน 6 วัน=`6DAYS`"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("HolidayDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(2) + .HasComment("วันหยุด"); + + b.Property("IsSpecial") + .HasColumnType("tinyint(1)") + .HasColumnOrder(5) + .HasComment("เป็นวันหยุดพิเศษหรือไม่"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("varchar(250)") + .HasColumnOrder(4) + .HasComment("ชื่อวันหยุด"); + + b.Property("OriginalDate") + .HasColumnType("datetime(6)") + .HasColumnOrder(3) + .HasComment("วันหยุด(Original)"); + + b.Property("Year") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ประจำปี"); + + b.HasKey("Id"); + + b.ToTable("Holidays"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Insignia", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("InsigniaTypeId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Level") + .HasColumnType("int") + .HasColumnOrder(4) + .HasComment("ลำดับชั้นของเครื่องราช เอาไว้ตรวจสอบเวลาขอว่าต้องได้ชั้นที่สูงกว่าที่เคยได้รับแล้วเท่านั้น"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อเครื่องราช"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(5) + .HasComment("หมายเหตุ"); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnOrder(2) + .HasComment("ชื่อย่อเครื่องราช"); + + b.HasKey("Id"); + + b.HasIndex("InsigniaTypeId"); + + b.ToTable("Insignias"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.InsigniaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(1) + .HasComment("ชื่อประเภทเครื่องราช"); + + b.HasKey("Id"); + + b.ToTable("InsigniaTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationAgency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ หน่วยงานต้นสังกัด"); + + b.HasKey("Id"); + + b.ToTable("OrganizationAgencys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationFax", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ เบอร์โทรสาร"); + + b.HasKey("Id"); + + b.ToTable("OrganizationFaxs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationGovernmentAgency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ ส่วนราชการต้นสังกัด"); + + b.HasKey("Id"); + + b.ToTable("OrganizationGovernmentAgencys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ ระดับ"); + + b.HasKey("Id"); + + b.ToTable("OrganizationLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ หน่วยงาน"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("OrganizationOrganizations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationShortName", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AgencyCode") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ รหัสหน่วยงาน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("GovernmentCode") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(2) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ รหัสส่วนราชการ"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(4) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(3) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ ตัวย่อหน่วยงาน"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(5) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("OrganizationShortNames"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ สถานะ"); + + b.HasKey("Id"); + + b.ToTable("OrganizationStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationTelExternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ เบอร์ติดต่อภายนอก"); + + b.HasKey("Id"); + + b.ToTable("OrganizationTelExternals"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationTelInternal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ เบอร์ติดต่อภายใน"); + + b.HasKey("Id"); + + b.ToTable("OrganizationTelInternals"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.OrganizationType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ข้อมูลโครงสร้างหน่วยงานชื่อ ประเภท"); + + b.HasKey("Id"); + + b.ToTable("OrganizationTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PhysicalStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("สถานภาพทางกาย"); + + b.HasKey("Id"); + + b.ToTable("PhysicalStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Position", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExecutiveName") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("varchar(300)") + .HasColumnOrder(3) + .HasComment("ชื่อตำแหน่งทางการบริหาร"); + + b.Property("ExecutiveSideId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(9) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("varchar(300)") + .HasColumnOrder(1) + .HasComment("ชื่อตำแหน่ง"); + + b.Property("PathSideId") + .HasColumnType("char(36)"); + + b.Property("PositionCategory") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(8) + .HasComment("ตำแหน่งสำหรับข้าราชการหรือลูกจ้าง officer/employee"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionPathId") + .HasColumnType("char(36)"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("ExecutiveSideId"); + + b.HasIndex("PathSideId"); + + b.HasIndex("PositionLevelId"); + + b.HasIndex("PositionPathId"); + + b.HasIndex("PositionTypeId"); + + b.ToTable("Positions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeeGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อกลุ่มงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeeGroups"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(2) + .HasComment("ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.Property("Order") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ลำดับ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeeLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อสายงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeeLines"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeePosition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อตำแหน่งข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeePositions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeePositionSide", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อด้านของตำแหน่งข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeePositionSides"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionEmployeeStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อสถานะของตำแหน่งข้อมูลตำแหน่งของลูกจ้างกรุงเทพ"); + + b.HasKey("Id"); + + b.ToTable("PositionEmployeeStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionExecutive", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อตำแหน่งทางการบริหารของข้อมูลตำแหน่งของข้าราชการ"); + + b.HasKey("Id"); + + b.ToTable("PositionExecutives"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionExecutiveSide", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อด้านทางการบริหาร"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("PositionExecutiveSides"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(5) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Level") + .HasColumnType("int") + .HasColumnOrder(4) + .HasComment("ลำดับชั้นของระดับตำแหน่ง"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(2) + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("Order") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ลำดับ"); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(3) + .HasComment("ชื่อย่อระดับตำแหน่ง"); + + b.HasKey("Id"); + + b.ToTable("PositionLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อสายงานของข้อมูลตำแหน่งของข้าราชการ"); + + b.HasKey("Id"); + + b.ToTable("PositionLines"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionPath", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อสายงาน"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("PositionPaths"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionPathSide", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อด้าน/สาขา"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("หมายเหตุ"); + + b.HasKey("Id"); + + b.ToTable("PositionPathSides"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อสถานะของตำแหน่งของข้อมูลตำแหน่งของข้าราชการ"); + + b.HasKey("Id"); + + b.ToTable("PositionStatuss"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.PositionType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(2) + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("Order") + .HasColumnType("int") + .HasColumnOrder(1) + .HasComment("ลำดับ"); + + b.HasKey("Id"); + + b.ToTable("PositionTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Prefix", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(2) + .HasComment("รายละเอียดคำนำหน้า"); + + b.HasKey("Id"); + + b.ToTable("Prefixes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Province", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)") + .HasColumnOrder(1) + .HasComment("จังหวัด"); + + b.HasKey("Id"); + + b.ToTable("Provinces"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnOrder(1) + .HasComment("ชื่อความสัมพันธ์"); + + b.HasKey("Id"); + + b.ToTable("Relationships"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Religion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ศาสนา"); + + b.HasKey("Id"); + + b.ToTable("Religions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Royal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อประเภทข้อมูลเหรียญตรา"); + + b.Property("ShortName") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasColumnOrder(2) + .HasComment("ชื่อย่อเหรียญตรา"); + + b.HasKey("Id"); + + b.ToTable("Royals"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.RoyalHierarchy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อลำดับชั้นข้อมูลเครื่องราชฯ"); + + b.HasKey("Id"); + + b.ToTable("RoyalHierarchys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.RoyalType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(2) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnOrder(1) + .HasComment("ชื่อประเภทข้อมูลเครื่องราชฯ"); + + b.HasKey("Id"); + + b.ToTable("RoyalTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.SubDistrict", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DistrictId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)") + .HasColumnOrder(1) + .HasComment("เขต/อำเภอ"); + + b.Property("ZipCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasColumnOrder(2) + .HasComment("รหัสไปรษณีย์"); + + b.HasKey("Id"); + + b.HasIndex("DistrictId"); + + b.ToTable("SubDistricts"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.Inbox", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasComment("รายละเอียดข้อความ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DeleteDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ลบข้อมูล"); + + b.Property("IsOpen") + .HasColumnType("tinyint(1)") + .HasComment("เปิดอ่านแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OpenDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เปิดอ่าน"); + + b.Property("Payload") + .IsRequired() + .HasColumnType("text") + .HasComment("สิงที่แนบมาด้วย"); + + b.Property("ReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("ReceiverUserId") + .HasColumnType("char(36)") + .HasComment("รหัสผู้รับข้อความ"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หัวเรื่อง"); + + b.HasKey("Id"); + + b.ToTable("Inboxes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.MessageQueueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsSend") + .HasColumnType("tinyint(1)") + .HasComment("ทำการส่งข้อความแล้วหรือยัง?"); + + b.Property("IsSendEmail") + .HasColumnType("tinyint(1)") + .HasComment("ส่งอีเมลล์หรือไม่?"); + + b.Property("IsSendInbox") + .HasColumnType("tinyint(1)") + .HasComment("ส่งไปที่กล่องข้อความหรือไม่?"); + + b.Property("IsSendNotification") + .HasColumnType("tinyint(1)") + .HasComment("ส่งการแจ้งเตือนหรือไม่?"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("MessageContent") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดข้อความ"); + + b.Property("MessagePayLoad") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สิ่งที่แนบมาด้วย"); + + b.Property("ReceiverEmailAddress") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)") + .HasComment("อีเมล์ของผู้รับ"); + + b.Property("ReceiverUserId") + .HasColumnType("char(36)") + .HasComment("รหัสของผู้รับข้อความ"); + + b.Property("SenderSystem") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("ส่งจากระบบงาน"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หัวเรื่อง"); + + b.HasKey("Id"); + + b.ToTable("MessageQueues"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasComment("รายละเอียดข้อความ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DeleteDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ลบข้อมูล"); + + b.Property("IsOpen") + .HasColumnType("tinyint(1)") + .HasComment("เปิดอ่านแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OpenDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เปิดอ่าน"); + + b.Property("Payload") + .IsRequired() + .HasColumnType("text") + .HasComment("สิงที่แนบมาด้วย"); + + b.Property("ReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("ReceiverUserId") + .HasColumnType("char(36)") + .HasComment("รหัสผู้รับข้อความ"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทการแจ้งเตือน"); + + b.HasKey("Id"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Agency") + .HasColumnType("longtext"); + + b.Property("ConditionNote") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Department") + .HasColumnType("longtext"); + + b.Property("Government") + .HasColumnType("longtext"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsCondition") + .HasColumnType("tinyint(1)"); + + b.Property("IsDirector") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationAgencyId") + .HasColumnType("char(36)"); + + b.Property("OrganizationFaxId") + .HasColumnType("char(36)"); + + b.Property("OrganizationGovernmentAgencyId") + .HasColumnType("char(36)"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("OrganizationLevelId") + .HasColumnType("char(36)"); + + b.Property("OrganizationOrder") + .HasColumnType("longtext"); + + b.Property("OrganizationOrganizationId") + .HasColumnType("char(36)"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTelExternalId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTelInternalId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTypeId") + .HasColumnType("char(36)"); + + b.Property("OrganizationUserNote") + .HasColumnType("longtext"); + + b.Property("Pile") + .HasColumnType("longtext"); + + b.Property("PosNo") + .HasColumnType("longtext"); + + b.Property("PositionCondition") + .HasColumnType("longtext"); + + b.Property("PositionEmployeeLineId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeePositionId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeeStatusId") + .HasColumnType("char(36)"); + + b.Property("PositionMasterUserNote") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Qualification") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationAgencyId"); + + b.HasIndex("OrganizationFaxId"); + + b.HasIndex("OrganizationGovernmentAgencyId"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("OrganizationLevelId"); + + b.HasIndex("OrganizationOrganizationId"); + + b.HasIndex("OrganizationShortNameId"); + + b.HasIndex("OrganizationTelExternalId"); + + b.HasIndex("OrganizationTelInternalId"); + + b.HasIndex("OrganizationTypeId"); + + b.HasIndex("PositionEmployeeLineId"); + + b.HasIndex("PositionEmployeePositionId"); + + b.HasIndex("PositionEmployeeStatusId"); + + b.HasIndex("ProfileId"); + + b.ToTable("OrganizationEmployees"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationEmployeeProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrgEmployeeId") + .HasColumnType("char(36)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("OrgEmployeeId"); + + b.HasIndex("ProfileId"); + + b.ToTable("OrganizationEmployeeProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeeLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationEmployeeId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeeLevelId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationEmployeeId"); + + b.HasIndex("PositionEmployeeLevelId"); + + b.ToTable("OrganizationPositionEmployeeLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeePositionSide", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationEmployeeId") + .HasColumnType("char(36)"); + + b.Property("PositionEmployeePositionSideId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationEmployeeId"); + + b.HasIndex("PositionEmployeePositionSideId"); + + b.ToTable("OrganizationPositionEmployeePositionSides"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.AvailablePositionLevelEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionMasterId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PositionLevelId"); + + b.HasIndex("PositionMasterId"); + + b.ToTable("AvailablePositionLevels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Agency") + .HasColumnType("longtext") + .HasColumnOrder(14) + .HasComment("หน่วยงาน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Department") + .HasColumnType("longtext") + .HasColumnOrder(16) + .HasComment("ฝ่าย/ส่วน"); + + b.Property("Government") + .HasColumnType("longtext") + .HasColumnOrder(15) + .HasComment("ส่วนราชการ"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationAgencyId") + .HasColumnType("char(36)") + .HasColumnOrder(10) + .HasComment("OrganizationAgencyId"); + + b.Property("OrganizationFaxId") + .HasColumnType("char(36)"); + + b.Property("OrganizationGovernmentAgencyId") + .HasColumnType("char(36)") + .HasColumnOrder(11) + .HasComment("OrganizationGovernmentAgencyId"); + + b.Property("OrganizationLevelId") + .HasColumnType("char(36)"); + + b.Property("OrganizationOrder") + .HasColumnType("int") + .HasColumnOrder(12) + .HasComment("OrganizationOrder"); + + b.Property("OrganizationOrganizationId") + .HasColumnType("char(36)"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)"); + + b.Property("OrganizationStatusId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTelExternalId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTelInternalId") + .HasColumnType("char(36)"); + + b.Property("OrganizationTypeId") + .HasColumnType("char(36)"); + + b.Property("OrganizationUserNote") + .HasColumnType("longtext") + .HasColumnOrder(13) + .HasComment("OrganizationUserNote"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Pile") + .HasColumnType("longtext") + .HasColumnOrder(17) + .HasComment("กอง"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationFaxId"); + + b.HasIndex("OrganizationLevelId"); + + b.HasIndex("OrganizationOrganizationId"); + + b.HasIndex("OrganizationShortNameId"); + + b.HasIndex("OrganizationStatusId"); + + b.HasIndex("OrganizationTelExternalId"); + + b.HasIndex("OrganizationTelInternalId"); + + b.HasIndex("OrganizationTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Organizations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationPositionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsDirector") + .HasColumnType("tinyint(1)") + .HasColumnOrder(3) + .HasComment("Is Director"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationId") + .HasColumnType("char(36)"); + + b.Property("PositionMasterId") + .HasColumnType("char(36)"); + + b.Property("PositionNumberId") + .HasColumnType("char(36)"); + + b.Property("PositionUserNote") + .HasColumnType("longtext") + .HasColumnOrder(4) + .HasComment("positionUserNote"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationId"); + + b.HasIndex("PositionMasterId"); + + b.HasIndex("PositionNumberId"); + + b.ToTable("OrganizationPositions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationPublishHistoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(1) + .HasComment("รายละเอียดการแก้ไข"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ObjectValue") + .IsRequired() + .HasColumnType("longtext") + .HasColumnOrder(2) + .HasComment("เก็บ Object ที่มีการอัพเดตในระบบ"); + + b.HasKey("Id"); + + b.ToTable("OrganizationPublishHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsDirector") + .HasColumnType("tinyint(1)") + .HasColumnOrder(14) + .HasComment("IsDirector"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PositionCondition") + .HasColumnType("longtext") + .HasColumnOrder(11) + .HasComment("PositionCondition"); + + b.Property("PositionExecutiveId") + .HasColumnType("char(36)"); + + b.Property("PositionExecutiveSideId") + .HasColumnType("char(36)"); + + b.Property("PositionExecutiveSideObject") + .HasColumnType("longtext"); + + b.Property("PositionId") + .HasColumnType("char(36)") + .HasColumnOrder(2) + .HasComment("PositionId"); + + b.Property("PositionLineId") + .HasColumnType("char(36)"); + + b.Property("PositionMasterUserNote") + .HasColumnType("longtext") + .HasColumnOrder(13) + .HasComment("PositionMasterUserNote"); + + b.Property("PositionPathId") + .HasColumnType("char(36)"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)"); + + b.Property("PositionPathSideObject") + .HasColumnType("longtext"); + + b.Property("PositionStatusId") + .HasColumnType("char(36)"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)"); + + b.Property("Qualification") + .HasColumnType("longtext") + .HasColumnOrder(15) + .HasComment("คุณวุฒิ"); + + b.HasKey("Id"); + + b.HasIndex("PositionExecutiveId"); + + b.HasIndex("PositionExecutiveSideId"); + + b.HasIndex("PositionLineId"); + + b.HasIndex("PositionPathId"); + + b.HasIndex("PositionPathSideId"); + + b.HasIndex("PositionStatusId"); + + b.HasIndex("PositionTypeId"); + + b.ToTable("PositionMasters"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionMasterHistoryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsDirector") + .HasColumnType("tinyint(1)") + .HasColumnOrder(14) + .HasComment("IsDirector"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Position") + .HasColumnType("longtext") + .HasColumnOrder(2) + .HasComment("Position"); + + b.Property("PositionCondition") + .HasColumnType("longtext") + .HasColumnOrder(11) + .HasComment("PositionCondition"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasColumnOrder(5) + .HasComment("PositionExecutive"); + + b.Property("PositionExecutiveSide") + .HasColumnType("longtext") + .HasColumnOrder(6) + .HasComment("PositionExecutiveSide"); + + b.Property("PositionExecutiveSideObject") + .HasColumnType("longtext"); + + b.Property("PositionLevel") + .HasColumnType("longtext") + .HasColumnOrder(12) + .HasComment("PositionLevel"); + + b.Property("PositionLine") + .HasColumnType("longtext") + .HasColumnOrder(8) + .HasComment("PositionLine"); + + b.Property("PositionMasterEntityId") + .HasColumnType("char(36)"); + + b.Property("PositionMasterUserNote") + .HasColumnType("longtext") + .HasColumnOrder(13) + .HasComment("PositionMasterUserNote"); + + b.Property("PositionPath") + .HasColumnType("longtext") + .HasColumnOrder(3) + .HasComment("PositionPath"); + + b.Property("PositionPathSide") + .HasColumnType("longtext") + .HasColumnOrder(7) + .HasComment("PositionPathSide"); + + b.Property("PositionPathSideObject") + .HasColumnType("longtext"); + + b.Property("PositionStatus") + .HasColumnType("longtext") + .HasColumnOrder(10) + .HasComment("PositionStatus"); + + b.Property("PositionType") + .HasColumnType("longtext") + .HasColumnOrder(4) + .HasComment("PositionType"); + + b.Property("Qualification") + .HasColumnType("longtext") + .HasColumnOrder(15) + .HasComment("คุณวุฒิ"); + + b.HasKey("Id"); + + b.HasIndex("PositionMasterEntityId"); + + b.ToTable("PositionMasterHistoryEntity"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .HasMaxLength(300) + .HasColumnType("varchar(300)") + .HasColumnOrder(2) + .HasComment("ชื่อ"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationShortNameId"); + + b.ToTable("PositionNumbers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.ProfilePosition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublished") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationPositionId") + .HasColumnType("char(36)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OrganizationPositionId"); + + b.HasIndex("ProfileId"); + + b.ToTable("ProfilePositions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.Report2.Report2", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("GovernmentCode") + .HasColumnType("longtext"); + + b.Property("GovernmentCodeOld") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationOrganization") + .HasColumnType("longtext"); + + b.Property("OrganizationOrganizationId") + .HasColumnType("char(36)") + .HasComment("ชื่อหน่วยงาน"); + + b.Property("OrganizationOrganizationOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงานเดิม"); + + b.Property("OrganizationPositionId") + .HasColumnType("char(36)"); + + b.Property("OrganizationShortName") + .HasColumnType("longtext"); + + b.Property("OrganizationShortNameId") + .HasColumnType("char(36)") + .HasComment("รหัสส่วนราชการ"); + + b.Property("OrganizationShortNameOld") + .HasColumnType("longtext") + .HasComment("รหัสส่วนราชการเดิม"); + + b.Property("PositionExecutive") + .HasColumnType("longtext"); + + b.Property("PositionExecutiveId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionExecutiveSide") + .HasColumnType("longtext"); + + b.Property("PositionExecutiveSideId") + .HasColumnType("char(36)") + .HasComment("ด้านทางบริหาร"); + + b.Property("PositionExecutiveSideOld") + .HasColumnType("longtext") + .HasComment("ด้านทางบริหารเดิม"); + + b.Property("PositionLevel") + .HasColumnType("longtext"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)") + .HasComment("ระดับตำแหน่ง"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ระดับตำแหน่งเดิม"); + + b.Property("PositionNum") + .HasColumnType("longtext"); + + b.Property("PositionNumId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งเลขที่"); + + b.Property("PositionNumOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเลขที่เดิม"); + + b.Property("PositionPath") + .HasColumnType("longtext"); + + b.Property("PositionPathId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งในสายงาน"); + + b.Property("PositionPathOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งในสายงานเดิม"); + + b.Property("PositionPathSide") + .HasColumnType("longtext"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)") + .HasComment("ด้าน/สาขา"); + + b.Property("PositionPathSideOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขาเดิม"); + + b.Property("PositionType") + .HasColumnType("longtext"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)") + .HasComment("ประเภทตำแหน่ง"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่งเดิม"); + + b.Property("ProfilePositionId") + .HasColumnType("char(36)") + .HasComment("สังกัดที่ถือครอง"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะการเปลี่ยนแปลง"); + + b.HasKey("Id"); + + b.ToTable("Report2s"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.Report2.Report2DetailHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.HasKey("Id"); + + b.ToTable("Report2DetailHistories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.Report2.Report2History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Education") + .HasColumnType("longtext") + .HasComment("คุณวุฒิ"); + + b.Property("FullName") + .HasColumnType("longtext") + .HasComment("ชื่อ-สกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("NewGovernmentCode") + .HasColumnType("longtext"); + + b.Property("NewOrganizationOrganization") + .HasColumnType("longtext"); + + b.Property("NewOrganizationOrganizationId") + .HasColumnType("char(36)") + .HasComment("ชื่อหน่วยงาน กำหนดใหม่"); + + b.Property("NewOrganizationShortName") + .HasColumnType("longtext"); + + b.Property("NewOrganizationShortNameId") + .HasColumnType("char(36)") + .HasComment("รหัสส่วนราชการ กำหนดใหม่"); + + b.Property("NewPositionExecutive") + .HasColumnType("longtext"); + + b.Property("NewPositionExecutiveId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งทางการบริหาร กำหนดใหม่"); + + b.Property("NewPositionExecutiveSide") + .HasColumnType("longtext"); + + b.Property("NewPositionExecutiveSideId") + .HasColumnType("char(36)") + .HasComment("ด้านทางบริหาร กำหนดใหม่"); + + b.Property("NewPositionLevel") + .HasColumnType("longtext"); + + b.Property("NewPositionLevelId") + .HasColumnType("char(36)") + .HasComment("ระดับตำแหน่ง กำหนดใหม่"); + + b.Property("NewPositionNum") + .HasColumnType("longtext"); + + b.Property("NewPositionNumId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งเลขที่ กำหนดใหม่"); + + b.Property("NewPositionPath") + .HasColumnType("longtext"); + + b.Property("NewPositionPathId") + .HasColumnType("char(36)") + .HasComment("ตำแหน่งในสายงาน กำหนดใหม่"); + + b.Property("NewPositionPathSide") + .HasColumnType("longtext"); + + b.Property("NewPositionPathSideId") + .HasColumnType("char(36)") + .HasComment("ด้าน/สาขา กำหนดใหม่"); + + b.Property("NewPositionType") + .HasColumnType("longtext"); + + b.Property("NewPositionTypeId") + .HasColumnType("char(36)") + .HasComment("ประเภทตำแหน่ง กำหนดใหม่"); + + b.Property("OldGovernmentCode") + .HasColumnType("longtext"); + + b.Property("OldOrganizationOrganization") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน กำหนดเดิม"); + + b.Property("OldOrganizationShortName") + .HasColumnType("longtext") + .HasComment("รหัสส่วนราชการ กำหนดเดิม"); + + b.Property("OldPositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร กำหนดเดิม"); + + b.Property("OldPositionExecutiveSide") + .HasColumnType("longtext") + .HasComment("ด้านทางบริหาร กำหนดเดิม"); + + b.Property("OldPositionLevel") + .HasColumnType("longtext") + .HasComment("ระดับตำแหน่ง กำหนดเดิม"); + + b.Property("OldPositionNum") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเลขที่ กำหนดเดิม"); + + b.Property("OldPositionPath") + .HasColumnType("longtext") + .HasComment("ตำแหน่งในสายงาน กำหนดเดิม"); + + b.Property("OldPositionPathSide") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา กำหนดเดิม"); + + b.Property("OldPositionType") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่ง กำหนดเดิม"); + + b.Property("OrganizationPositionId") + .HasColumnType("char(36)"); + + b.Property("ProfilePositionId") + .HasColumnType("char(36)") + .HasComment("สังกัดที่ถือครอง"); + + b.Property("Report2DetailHistoryId") + .HasColumnType("char(36)"); + + b.Property("Salary") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("SalaryMonth") + .HasColumnType("double") + .HasComment("เงินตอบแทนรายเดือน"); + + b.Property("SalaryPosition") + .HasColumnType("double") + .HasComment("เงินประจำตำแหน่ง"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะการเปลี่ยนแปลง"); + + b.HasKey("Id"); + + b.HasIndex("Report2DetailHistoryId"); + + b.ToTable("Report2Histories"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.Placement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สิ้นสุดบัญชี"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รอบการสอบ"); + + b.Property("Number") + .HasMaxLength(10) + .HasColumnType("int") + .HasComment("จำนวนผู้สอบได้"); + + b.Property("PlacementTypeId") + .HasColumnType("char(36)"); + + b.Property("RefId") + .HasColumnType("char(36)") + .HasComment("Id การสอบ"); + + b.Property("Round") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ครั้งที่"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่เริ่มบัญชีบัญชี"); + + b.Property("Year") + .HasMaxLength(5) + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.HasKey("Id"); + + b.HasIndex("PlacementTypeId"); + + b.ToTable("Placements"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementAppointment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("EducationOld") + .HasColumnType("longtext") + .HasComment("วุฒิ/สาขาเดิม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด/ตำแหน่งเเดิม"); + + b.Property("PositionDate") + .HasColumnType("datetime(6)") + .HasComment("ดำรงตำแหน่งในระดับปัจจุบันเมื่อ"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่รับย้ายราชการ"); + + b.Property("ReportingDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่รายงานตัว"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna"); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna"); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna"); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna"); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("node") + .HasColumnType("int") + .HasComment("ระดับโครงสร้าง"); + + b.Property("nodeId") + .HasColumnType("char(36)") + .HasComment("id โครงสร้าง"); + + b.Property("orgRevisionId") + .HasColumnType("longtext") + .HasComment("id revision"); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("positionField") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("positionId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่ง"); + + b.Property("positionOld") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน old"); + + b.Property("posmasterId") + .HasColumnType("longtext") + .HasComment("id อัตรากำลัง"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.Property("type") + .HasColumnType("longtext") + .HasComment("ประเภทราชการ"); + + b.Property("typeCommand") + .HasColumnType("longtext") + .HasComment("ประเภทคำสั่ง"); + + b.HasKey("Id"); + + b.ToTable("PlacementAppointments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementAppointmentDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementAppointmentId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PlacementAppointmentId"); + + b.ToTable("PlacementAppointmentDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementAppointmentEmployee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้าง โครงสร้างใหม่ที่ทำสำเนากับโครงสร้างเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขโครงสร้างย้อนหลังได้"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.HasKey("Id"); + + b.ToTable("PlacementAppointmentEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CertificateNo") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขที่ใบอนุญาต"); + + b.Property("CertificateType") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อใบอนุญาต"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExpireDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่หมดอายุ"); + + b.Property("IssueDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกใบอนุญาต"); + + b.Property("Issuer") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หน่วยงานผู้ออกใบอนุญาต"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("PlacementProfileId"); + + b.ToTable("PlacementCertificates"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementEducation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Country") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ประเทศ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Degree") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("วุฒิการศึกษา"); + + b.Property("Duration") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ระยะเวลา"); + + b.Property("DurationYear") + .HasColumnType("int") + .HasComment("ระยะเวลาหลักสูตร"); + + b.Property("EducationLevelId") + .HasColumnType("char(36)") + .HasComment("Idวุฒิที่ได้รับ"); + + b.Property("EducationLevelName") + .HasColumnType("longtext") + .HasComment("วุฒิที่ได้รับ"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("ถึง"); + + b.Property("Field") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("สาขาวิชา/ทาง"); + + b.Property("FinishDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่สำเร็จการศึกษา"); + + b.Property("FundName") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ทุน"); + + b.Property("Gpa") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เกรดเฉลี่ย"); + + b.Property("Institute") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("สถานศึกษา"); + + b.Property("IsDate") + .HasColumnType("tinyint(1)") + .HasComment("ประเภทช่วงเวลาการศึกษา"); + + b.Property("IsEducation") + .HasColumnType("tinyint(1)") + .HasComment("เป็นวุฒิศึกษาในตำแหน่ง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Other") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasComment("ข้อมูลการติดต่อ"); + + b.Property("PlacementProfileId") + .HasColumnType("char(36)"); + + b.Property("PositionPathId") + .HasColumnType("char(36)"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่"); + + b.HasKey("Id"); + + b.HasIndex("PlacementProfileId"); + + b.HasIndex("PositionPathId"); + + b.ToTable("PlacementEducations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementIsProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อคุณสมบัติ"); + + b.HasKey("Id"); + + b.ToTable("PlacementIsProperties"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementOfficer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateEnd") + .HasColumnType("datetime(6)") + .HasComment("ถึงวันที่"); + + b.Property("DateStart") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ช่วยราชการไป"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("commandNo") + .HasColumnType("longtext") + .HasComment("เลขที่คำสั่ง"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("PlacementOfficers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("BloodGroup") + .HasColumnType("longtext") + .HasComment("Id กลุ่มเลือด"); + + b.Property("CitizenDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกบัตร"); + + b.Property("CitizenDistrictId") + .HasColumnType("longtext") + .HasComment("Id เขตที่ออกบัตรประชาชน"); + + b.Property("CitizenId") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CitizenProvinceId") + .HasColumnType("longtext") + .HasComment("Id จังหวัดที่ออกบัตรประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("CurrentAddress") + .HasColumnType("longtext") + .HasComment("ที่อยู่ปัจจุบัน"); + + b.Property("CurrentDistrictId") + .HasColumnType("longtext") + .HasComment("Id อำเภอที่อยู่ปัจจุบัน"); + + b.Property("CurrentProvinceId") + .HasColumnType("longtext") + .HasComment("Id จังหวัดที่อยู่ปัจจุบัน"); + + b.Property("CurrentSubDistrictId") + .HasColumnType("longtext") + .HasComment("Id ตำบลที่อยู่ปัจจุบัน"); + + b.Property("CurrentZipCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("รหัสไปรษณีย์ที่อยู่ปัจจุบัน"); + + b.Property("DateOfBirth") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("Draft") + .HasColumnType("tinyint(1)") + .HasComment("ข้อมูลตำแหน่ง Draft"); + + b.Property("Email") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อีเมล"); + + b.Property("ExamNumber") + .HasColumnType("int") + .HasComment("ลำดับที่สอบได้"); + + b.Property("ExamRound") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่สมัครสอบ"); + + b.Property("FatherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงบิดา"); + + b.Property("FatherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลบิดา"); + + b.Property("FatherNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติบิดา"); + + b.Property("FatherOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพบิดา"); + + b.Property("FatherPrefix") + .HasColumnType("longtext") + .HasComment("Id คำนำหน้าชื่อบิดา"); + + b.Property("Firstname") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("Gender") + .HasColumnType("longtext") + .HasComment("Id เพศ"); + + b.Property("IsOfficer") + .HasColumnType("tinyint(1)") + .HasComment("ข้าราชการฯ กทม."); + + b.Property("IsOld") + .HasColumnType("tinyint(1)") + .HasComment("ข้อมูลเก่า"); + + b.Property("IsProperty") + .HasColumnType("longtext") + .HasComment("การคัดกรองคุณสมบัติ"); + + b.Property("IsRelief") + .HasColumnType("tinyint(1)") + .HasComment("ผ่อนผัน"); + + b.Property("Knowledge") + .HasColumnType("longtext") + .HasComment("ความสามารถพิเศษ"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Lastname") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("Marry") + .HasColumnType("tinyint(1)") + .HasComment("คู่สมรส"); + + b.Property("MarryFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงคู่สมรส"); + + b.Property("MarryLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลคู่สมรส"); + + b.Property("MarryNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติคู่สมรส"); + + b.Property("MarryOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพคู่สมรส"); + + b.Property("MarryPrefix") + .HasColumnType("longtext") + .HasComment("Id คำนำหน้าชื่อคู่สมรส"); + + b.Property("MobilePhone") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("MotherFirstName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อจริงมารดา"); + + b.Property("MotherLastName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุลมารดา"); + + b.Property("MotherNationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติมารดา"); + + b.Property("MotherOccupation") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("อาชีพมารดา"); + + b.Property("MotherPrefix") + .HasColumnType("longtext") + .HasComment("Id คำนำหน้าชื่อมารดา"); + + b.Property("MouthSalaryAmount") + .HasColumnType("double") + .HasComment("เงินค่าตอบแทนรายเดือน"); + + b.Property("Nationality") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasComment("สัญชาติ"); + + b.Property("OccupationGroup") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน กลุ่ม/ฝ่าย"); + + b.Property("OccupationOrg") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน ชื่อตำแหน่ง"); + + b.Property("OccupationPile") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน กอง"); + + b.Property("OccupationPosition") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน สังกัด"); + + b.Property("OccupationPositionType") + .HasColumnType("longtext") + .HasComment("ตำแหน่งปัจจุบัน ประเภทราชการ"); + + b.Property("OccupationSalary") + .HasColumnType("double") + .HasComment("ตำแหน่งปัจจุบัน เงินเดือน"); + + b.Property("OccupationTelephone") + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("โทรศัพท์ บริษัท"); + + b.Property("Pass") + .HasColumnType("longtext") + .HasComment("ผลสมัครสอบ"); + + b.Property("PlacementId") + .HasColumnType("char(36)"); + + b.Property("PlacementStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการบรรจุ"); + + b.Property("PointA") + .HasColumnType("double") + .HasComment("คะแนนภาค ก"); + + b.Property("PointB") + .HasColumnType("double") + .HasComment("คะแนนภาค ข"); + + b.Property("PointC") + .HasColumnType("double") + .HasComment("คะแนนภาค ค"); + + b.Property("PointTotalA") + .HasColumnType("double") + .HasComment("คะแนนเต็มภาค ก"); + + b.Property("PointTotalB") + .HasColumnType("double") + .HasComment("คะแนนเต็มภาค ข"); + + b.Property("PointTotalC") + .HasColumnType("double") + .HasComment("คะแนนเต็มภาค ค"); + + b.Property("PosNumber") + .HasColumnType("int") + .HasComment("ชื่อตำแหน่งเลขที่"); + + b.Property("PosPath") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่ง"); + + b.Property("PositionCandidate") + .HasColumnType("longtext") + .HasComment("ตำแหน่งสอบ"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevel") + .HasColumnType("longtext") + .HasComment("ระดับ"); + + b.Property("PositionSalaryAmount") + .HasColumnType("double") + .HasComment("เงินประจำตำแหน่ง"); + + b.Property("PositionType") + .HasColumnType("longtext") + .HasComment("ประเภทตำแหน่ง"); + + b.Property("Prefix") + .HasColumnType("longtext") + .HasComment("Id คำนำหน้า"); + + b.Property("ProfileImgId") + .HasColumnType("char(36)"); + + b.Property("Race") + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasComment("เชื้อชาติ"); + + b.Property("RecruitDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่บรรจุ"); + + b.Property("RegistAddress") + .HasColumnType("longtext") + .HasComment("ที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistDistrictId") + .HasColumnType("longtext") + .HasComment("Id อำเภอที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistProvinceId") + .HasColumnType("longtext") + .HasComment("Id จังหวัดที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistSame") + .HasColumnType("tinyint(1)") + .HasComment("ที่อยู่ปัจจุบันเหมือนที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistSubDistrictId") + .HasColumnType("longtext") + .HasComment("Id ตำบลที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RegistZipCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)") + .HasComment("รหัสไปรษณีย์ที่อยู่ตามทะเบียนบ้าน"); + + b.Property("RejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลสละสิทธิ์"); + + b.Property("Relationship") + .HasColumnType("longtext") + .HasComment("Id สถานภาพ"); + + b.Property("ReliefDocId") + .HasColumnType("char(36)"); + + b.Property("ReliefReason") + .HasColumnType("longtext") + .HasComment("เหตุผลผ่อนผัน"); + + b.Property("Religion") + .HasColumnType("longtext") + .HasComment("Id ศาสนา"); + + b.Property("RemarkHorizontal") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("RemarkVertical") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวตั้ง"); + + b.Property("ReportingDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่รายงานตัว"); + + b.Property("SalaryClass") + .HasColumnType("longtext") + .HasComment("ตำแหน่ง (รายละเอียด)"); + + b.Property("SalaryRef") + .HasColumnType("longtext") + .HasComment("เอกสารอ้างอิง"); + + b.Property("Telephone") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna"); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1IdOld") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna"); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2IdOld") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna"); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3IdOld") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna"); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4IdOld") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("commandId") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("node") + .HasColumnType("int") + .HasComment("ระดับโครงสร้าง"); + + b.Property("nodeId") + .HasColumnType("char(36)") + .HasComment("id โครงสร้าง"); + + b.Property("nodeIdOld") + .HasColumnType("longtext") + .HasComment("id โครงสร้าง"); + + b.Property("nodeOld") + .HasColumnType("longtext") + .HasComment("ระดับโครงสร้าง"); + + b.Property("orgRevisionId") + .HasColumnType("longtext") + .HasComment("id revision"); + + b.Property("orgRevisionIdOld") + .HasColumnType("longtext") + .HasComment("id revision"); + + b.Property("orgTreeShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน"); + + b.Property("organizationName") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน"); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelIdOld") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeIdOld") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("positionField") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("positionFieldOld") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("positionId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่ง"); + + b.Property("positionIdOld") + .HasColumnType("longtext") + .HasComment("id ตำแหน่ง"); + + b.Property("positionName") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("positionNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("posmasterId") + .HasColumnType("longtext") + .HasComment("id อัตรากำลัง"); + + b.Property("posmasterIdOld") + .HasColumnType("longtext") + .HasComment("id อัตรากำลัง"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profileId"); + + b.Property("refCommandCode") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("refCommandDate") + .HasMaxLength(200) + .HasColumnType("datetime(6)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("refCommandName") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("refCommandNo") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootIdOld") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.Property("templateDoc") + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("โทรศัพท์มือถือ"); + + b.Property("typeCommand") + .HasColumnType("longtext") + .HasComment("ประเภทคำสั่ง"); + + b.HasKey("Id"); + + b.HasIndex("PlacementId"); + + b.HasIndex("ProfileImgId"); + + b.HasIndex("ReliefDocId"); + + b.ToTable("PlacementProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfileDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementProfileId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PlacementProfileId"); + + b.ToTable("PlacementProfileDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("AvatarId") + .HasColumnType("char(36)"); + + b.Property("BloodGroup") + .HasColumnType("longtext") + .HasComment("Id กลุ่มเลือด"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("EducationOld") + .HasColumnType("longtext") + .HasComment("วุฒิ/สาขาเดิม"); + + b.Property("Gender") + .HasColumnType("longtext") + .HasComment("Id เพศ"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Nationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติ"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Race") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("เชื้อชาติ"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่รับโอนราชการ"); + + b.Property("Relationship") + .HasColumnType("longtext") + .HasComment("Id สถานะภาพ"); + + b.Property("Religion") + .HasColumnType("longtext") + .HasComment("Id ศาสนา"); + + b.Property("ReportingDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่บรรจุ"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("TelephoneNumber") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("เบอร์โทร"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna"); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna"); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna"); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna"); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("node") + .HasColumnType("int") + .HasComment("ระดับโครงสร้าง"); + + b.Property("nodeId") + .HasColumnType("char(36)") + .HasComment("id โครงสร้าง"); + + b.Property("orgRevisionId") + .HasColumnType("longtext") + .HasComment("id revision"); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("positionField") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("positionId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่ง"); + + b.Property("posmasterId") + .HasColumnType("longtext") + .HasComment("id อัตรากำลัง"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rank") + .HasColumnType("longtext") + .HasComment("ยศ"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.HasIndex("AvatarId"); + + b.ToTable("PlacementReceives"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceiveDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementReceiveId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PlacementReceiveId"); + + b.ToTable("PlacementReceiveDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRelocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("BloodGroupId") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateOfBirth") + .HasMaxLength(40) + .HasColumnType("datetime(6)") + .HasComment("วันเกิด"); + + b.Property("EducationOld") + .HasColumnType("longtext") + .HasComment("วุฒิ/สาขาเดิม"); + + b.Property("Firstname") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("GenderId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Lastname") + .IsRequired() + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("Nationality") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("สัญชาติ"); + + b.Property("OrganizationPositionId") + .HasColumnType("char(36)"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("PositionLevelId") + .HasColumnType("char(36)"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionLineId") + .HasColumnType("char(36)"); + + b.Property("PositionNumberId") + .HasColumnType("char(36)"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionPathId") + .HasColumnType("char(36)"); + + b.Property("PositionPathSideId") + .HasColumnType("char(36)"); + + b.Property("PositionTypeId") + .HasColumnType("char(36)"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("PrefixId") + .HasColumnType("char(36)"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Race") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("เชื้อชาติ"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ย้ายราชการ"); + + b.Property("RecruitDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่บรรจุ"); + + b.Property("RelationshipId") + .HasColumnType("char(36)"); + + b.Property("ReligionId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("TelephoneNumber") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("เบอร์โทร"); + + b.HasKey("Id"); + + b.HasIndex("BloodGroupId"); + + b.HasIndex("GenderId"); + + b.HasIndex("OrganizationPositionId"); + + b.HasIndex("PositionLevelId"); + + b.HasIndex("PositionLineId"); + + b.HasIndex("PositionNumberId"); + + b.HasIndex("PositionPathId"); + + b.HasIndex("PositionPathSideId"); + + b.HasIndex("PositionTypeId"); + + b.HasIndex("PrefixId"); + + b.HasIndex("ProfileId"); + + b.HasIndex("RelationshipId"); + + b.HasIndex("ReligionId"); + + b.ToTable("PlacementRelocations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRelocationDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementRelocationId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PlacementRelocationId"); + + b.ToTable("PlacementRelocationDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRepatriation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("DateRepatriation") + .HasColumnType("datetime(6)") + .HasComment("ส่งตัวกลับตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ส่งตัวกลับไป"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("refId") + .HasColumnType("char(36)") + .HasComment("Id อ้างอิงช่วยราช"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("PlacementRepatriations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ส่งตัวกลับไป"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("PlacementTransfers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransferDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("PlacementTransferId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("PlacementTransferId"); + + b.ToTable("PlacementTransferDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทบรรจุ"); + + b.HasKey("Id"); + + b.ToTable("PlacementTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Probation.CronjobNotiProbation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasComment("รายละเอียดข้อความ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("IsSendInbox") + .HasColumnType("tinyint(1)") + .HasComment("ส่งกล่องข้อความหรือไม่?"); + + b.Property("IsSendMail") + .HasColumnType("tinyint(1)") + .HasComment("ส่งอีเมล์หรือไม่?"); + + b.Property("IsSendNoti") + .HasColumnType("tinyint(1)") + .HasComment("ส่งการแจ้งเตือนหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Payload") + .IsRequired() + .HasColumnType("text") + .HasComment("สิงที่แนบมาด้วย"); + + b.Property("ReceiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ได้รับ"); + + b.Property("ReceiverUserId") + .HasColumnType("char(36)") + .HasComment("รหัสผู้รับข้อความ"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasComment("หัวเรื่อง"); + + b.HasKey("Id"); + + b.ToTable("CronjobNotiProbations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("วันที่เสียชีวิต"); + + b.Property("DocumentForwardId") + .HasColumnType("char(36)"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Location") + .HasColumnType("longtext") + .HasComment("สถานที่ออกใบมรณบัตร"); + + b.Property("Number") + .HasColumnType("longtext") + .HasComment("เลขที่ใบมรณบัตร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลการเสียชีวิต"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("profileType") + .HasColumnType("longtext") + .HasComment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.HasKey("Id"); + + b.HasIndex("DocumentForwardId"); + + b.HasIndex("DocumentId"); + + b.ToTable("RetirementDeceaseds"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceasedNoti", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CitizenId") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("varchar(13)") + .HasComment("เลขประจำตัวประชาชน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("ชื่อ"); + + b.Property("IsSendInbox") + .HasColumnType("tinyint(1)") + .HasComment("ส่งกล่องข้อความหรือไม่?"); + + b.Property("IsSendMail") + .HasColumnType("tinyint(1)") + .HasComment("ส่งอีเมล์หรือไม่?"); + + b.Property("IsSendNotification") + .HasColumnType("tinyint(1)") + .HasComment("ส่งแจ้งเตือนหรือไม่?"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasComment("นามสกุล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง"); + + b.Property("Prefix") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasComment("คำนำหน้านาม"); + + b.Property("RetirementDeceasedId") + .HasColumnType("char(36)"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementDeceasedId"); + + b.ToTable("RetirementDeceasedNotis"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDischarge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ปลดออกไป"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("RetirementDischarges"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementEmployeeQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Adjust") + .HasColumnType("longtext") + .HasComment("อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง"); + + b.Property("AdjustOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง"); + + b.Property("AppointDate") + .HasColumnType("datetime(6)") + .HasComment("กําหนดวันนัดหมายเพื่อทําการสัมภาษณ์การลาออก"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("ความคิดเห็น"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExitFactor") + .HasColumnType("longtext") + .HasComment("ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ"); + + b.Property("ExitFactorOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ"); + + b.Property("FutureWork") + .HasColumnType("tinyint(1)") + .HasComment("หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("FutureWorkReason") + .HasColumnType("longtext") + .HasComment("เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("Havejob") + .HasColumnType("tinyint(1)") + .HasComment("ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("HavejobReason") + .HasColumnType("longtext") + .HasComment("เหตุผลท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("NotExitFactor") + .HasColumnType("longtext") + .HasComment("ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("RealReason") + .HasColumnType("longtext") + .HasComment("โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("ReasonWork") + .HasColumnType("longtext") + .HasComment("เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร"); + + b.Property("ReasonWorkOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร"); + + b.Property("RetirementResignEmployeeId") + .HasColumnType("char(36)"); + + b.Property("Score1") + .HasColumnType("int") + .HasComment("คะแนนข้อ 1"); + + b.Property("Score10") + .HasColumnType("int") + .HasComment("คะแนนข้อ 10"); + + b.Property("Score2") + .HasColumnType("int") + .HasComment("คะแนนข้อ 2"); + + b.Property("Score3") + .HasColumnType("int") + .HasComment("คะแนนข้อ 3"); + + b.Property("Score4") + .HasColumnType("int") + .HasComment("คะแนนข้อ 4"); + + b.Property("Score5") + .HasColumnType("int") + .HasComment("คะแนนข้อ 5"); + + b.Property("Score6") + .HasColumnType("int") + .HasComment("คะแนนข้อ 6"); + + b.Property("Score7") + .HasColumnType("int") + .HasComment("คะแนนข้อ 7"); + + b.Property("Score8") + .HasColumnType("int") + .HasComment("คะแนนข้อ 8"); + + b.Property("Score9") + .HasColumnType("int") + .HasComment("คะแนนข้อ 9"); + + b.Property("ScoreTotal") + .HasColumnType("int") + .HasComment("คะแนนรวม"); + + b.Property("SuggestFriends") + .HasColumnType("tinyint(1)") + .HasComment("ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("SuggestFriendsReason") + .HasColumnType("longtext") + .HasComment("เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("Suggestion") + .HasColumnType("longtext") + .HasComment("ความคิดเห็นและข้อเสนอแนะอื่น ๆ "); + + b.Property("TimeThink") + .HasColumnType("int") + .HasComment("สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 "); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 "); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 "); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 "); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root "); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignEmployeeId"); + + b.ToTable("RetirementEmployeeQuestions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementExpulsion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ไล่ออกไป"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.HasKey("Id"); + + b.HasIndex("ProfileId"); + + b.ToTable("RetirementExpulsions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOther", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Amount") + .HasColumnType("double") + .HasComment("เงินเดือน"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CommandTypeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EducationOld") + .HasColumnType("longtext") + .HasComment("วุฒิ/สาขาเดิม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ออกราชการเมื่อ"); + + b.Property("MilitaryDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่พ้นจากราชการทหาร"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("PositionDate") + .HasColumnType("datetime(6)") + .HasComment("ดำรงตำแหน่งในระดับปัจจุบันเมื่อ"); + + b.Property("PositionExecutive") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่รับย้ายราชการ"); + + b.Property("RecruitDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่บรรจุ"); + + b.Property("ReportingDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่รายงานตัว"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1"); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1Dna old"); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2"); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2Dna old"); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3"); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3Dna old"); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4"); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4Dna old"); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("node") + .HasColumnType("int") + .HasComment("ระดับโครงสร้าง"); + + b.Property("nodeId") + .HasColumnType("char(36)") + .HasComment("id โครงสร้าง"); + + b.Property("orgRevisionId") + .HasColumnType("longtext") + .HasComment("id revision"); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง"); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง"); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("positionField") + .HasColumnType("longtext") + .HasComment("สายงาน"); + + b.Property("positionId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่ง"); + + b.Property("posmasterId") + .HasColumnType("longtext") + .HasComment("id อัตรากำลัง"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root"); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน rootDna old"); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.HasIndex("CommandTypeId"); + + b.ToTable("RetirementOthers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOtherDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RetirementOtherId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementOtherId"); + + b.ToTable("RetirementOtherDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOut", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Date") + .HasColumnType("datetime(6)") + .HasComment("ตั้งแต่วันที่"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Organization") + .HasColumnType("longtext") + .HasComment("หน่วยงานที่ให้ออกไป"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะคำขอ"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("profileType") + .HasColumnType("longtext") + .HasComment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("RetirementOuts"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดมติ อกก"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Round") + .HasColumnType("int") + .HasComment("ครั้งที่"); + + b.Property("SignDate") + .HasColumnType("datetime(6)") + .HasComment("ประกาศ ณ วันที่"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภท"); + + b.Property("TypeReport") + .HasColumnType("longtext") + .HasComment("ประเภทคำสั่ง"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.ToTable("RetirementPeriods"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดมติ อกก"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileFile") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายชื่อเกษียญ"); + + b.Property("RetirementPeriodId") + .HasColumnType("char(36)"); + + b.Property("Round") + .HasColumnType("int") + .HasComment("ครั้งที่"); + + b.Property("SignDate") + .HasColumnType("datetime(6)") + .HasComment("ประกาศ ณ วันที่"); + + b.Property("Total") + .HasColumnType("int") + .HasComment("จำนวนคน"); + + b.Property("Type") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภท"); + + b.Property("TypeReport") + .HasColumnType("longtext") + .HasComment("ประเภทคำสั่ง"); + + b.Property("Year") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementPeriodId"); + + b.ToTable("RetirementPeriodHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Order") + .HasColumnType("int") + .HasComment("ลำดับที่"); + + b.Property("Reason") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Remove") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ลบออกจากเกษียญ"); + + b.Property("RetirementPeriodId") + .HasColumnType("char(36)"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 "); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 "); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 "); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 "); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 "); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 "); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 "); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 "); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posExecutiveId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่งทางการบริหาร "); + + b.Property("posExecutiveName") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งทางการบริหาร "); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง "); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง "); + + b.Property("posLevelRank") + .HasColumnType("int") + .HasComment("ลำดับระดับตำแหน่ง "); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง "); + + b.Property("posNo") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่ง "); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง "); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง "); + + b.Property("posTypeRank") + .HasColumnType("int") + .HasComment("ลำดับประเภทตำแหน่ง "); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน "); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root "); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root "); + + b.HasKey("Id"); + + b.HasIndex("RetirementPeriodId"); + + b.ToTable("RetirementProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Adjust") + .HasColumnType("longtext") + .HasComment("อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง"); + + b.Property("AdjustOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง"); + + b.Property("AppointDate") + .HasColumnType("datetime(6)") + .HasComment("กําหนดวันนัดหมายเพื่อทําการสัมภาษณ์การลาออก"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("ความคิดเห็น"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ExitFactor") + .HasColumnType("longtext") + .HasComment("ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ"); + + b.Property("ExitFactorOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ"); + + b.Property("FutureWork") + .HasColumnType("tinyint(1)") + .HasComment("หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("FutureWorkReason") + .HasColumnType("longtext") + .HasComment("เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("Havejob") + .HasColumnType("tinyint(1)") + .HasComment("ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("HavejobReason") + .HasColumnType("longtext") + .HasComment("เหตุผลท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("NotExitFactor") + .HasColumnType("longtext") + .HasComment("ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("RealReason") + .HasColumnType("longtext") + .HasComment("โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร"); + + b.Property("ReasonWork") + .HasColumnType("longtext") + .HasComment("เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร"); + + b.Property("ReasonWorkOther") + .HasColumnType("longtext") + .HasComment("อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร"); + + b.Property("RetirementResignId") + .HasColumnType("char(36)"); + + b.Property("Score1") + .HasColumnType("int") + .HasComment("คะแนนข้อ 1"); + + b.Property("Score10") + .HasColumnType("int") + .HasComment("คะแนนข้อ 10"); + + b.Property("Score2") + .HasColumnType("int") + .HasComment("คะแนนข้อ 2"); + + b.Property("Score3") + .HasColumnType("int") + .HasComment("คะแนนข้อ 3"); + + b.Property("Score4") + .HasColumnType("int") + .HasComment("คะแนนข้อ 4"); + + b.Property("Score5") + .HasColumnType("int") + .HasComment("คะแนนข้อ 5"); + + b.Property("Score6") + .HasColumnType("int") + .HasComment("คะแนนข้อ 6"); + + b.Property("Score7") + .HasColumnType("int") + .HasComment("คะแนนข้อ 7"); + + b.Property("Score8") + .HasColumnType("int") + .HasComment("คะแนนข้อ 8"); + + b.Property("Score9") + .HasColumnType("int") + .HasComment("คะแนนข้อ 9"); + + b.Property("ScoreTotal") + .HasColumnType("int") + .HasComment("คะแนนรวม"); + + b.Property("SuggestFriends") + .HasColumnType("tinyint(1)") + .HasComment("ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("SuggestFriendsReason") + .HasColumnType("longtext") + .HasComment("เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่"); + + b.Property("Suggestion") + .HasColumnType("longtext") + .HasComment("ความคิดเห็นและข้อเสนอแนะอื่น ๆ "); + + b.Property("TimeThink") + .HasColumnType("int") + .HasComment("สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 "); + + b.Property("child1DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 "); + + b.Property("child2DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 "); + + b.Property("child3DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 "); + + b.Property("child4DnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root "); + + b.Property("rootDnaId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignId"); + + b.ToTable("RetirementQuestions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementQuestionnaireQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Question10Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 10"); + + b.Property("Question10Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 10"); + + b.Property("Question10Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 10"); + + b.Property("Question1Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 1"); + + b.Property("Question1Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 1"); + + b.Property("Question1Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 1"); + + b.Property("Question2Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 2"); + + b.Property("Question2Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 2"); + + b.Property("Question2Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 2"); + + b.Property("Question3Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 3"); + + b.Property("Question3Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 3"); + + b.Property("Question3Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 3"); + + b.Property("Question4Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 4"); + + b.Property("Question4Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 4"); + + b.Property("Question4Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 4"); + + b.Property("Question5Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 5"); + + b.Property("Question5Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 5"); + + b.Property("Question5Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 5"); + + b.Property("Question6Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 6"); + + b.Property("Question6Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 6"); + + b.Property("Question6Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 6"); + + b.Property("Question7Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 7"); + + b.Property("Question7Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 7"); + + b.Property("Question7Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 7"); + + b.Property("Question8Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 8"); + + b.Property("Question8Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 8"); + + b.Property("Question8Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 8"); + + b.Property("Question9Answer") + .HasColumnType("longtext") + .HasComment("กรอกคะแนน 9"); + + b.Property("Question9Desc") + .HasColumnType("longtext") + .HasComment("คำถามข้อที่ 9"); + + b.Property("Question9Score") + .HasColumnType("longtext") + .HasComment("คำตอบข้อที่ 9"); + + b.HasKey("Id"); + + b.ToTable("RetirementQuestionnaireQuestions"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementRawProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Order") + .HasColumnType("int") + .HasComment("ลำดับที่"); + + b.Property("Reason") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เหตุผล"); + + b.Property("Remove") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ลบออกจากเกษียญ"); + + b.Property("RetirementPeriodId") + .HasColumnType("char(36)"); + + b.Property("child1") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 "); + + b.Property("child1Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 "); + + b.Property("child1ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 "); + + b.Property("child2") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 "); + + b.Property("child2Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 "); + + b.Property("child2ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 "); + + b.Property("child3") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 "); + + b.Property("child3Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 "); + + b.Property("child3ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 "); + + b.Property("child4") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 "); + + b.Property("child4Id") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 "); + + b.Property("child4ShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 "); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posExecutiveId") + .HasColumnType("longtext") + .HasComment("id ตำแหน่งทางการบริหาร "); + + b.Property("posExecutiveName") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งทางการบริหาร "); + + b.Property("posLevelId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง "); + + b.Property("posLevelName") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง "); + + b.Property("posLevelRank") + .HasColumnType("int") + .HasComment("ลำดับระดับตำแหน่ง "); + + b.Property("posMasterNo") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง "); + + b.Property("posNo") + .HasColumnType("longtext") + .HasComment("เลขที่ตำแหน่ง "); + + b.Property("posTypeId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง "); + + b.Property("posTypeName") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง "); + + b.Property("posTypeRank") + .HasColumnType("int") + .HasComment("ลำดับประเภทตำแหน่ง "); + + b.Property("position") + .HasColumnType("longtext") + .HasComment("ชื่อตำแหน่งในสายงาน "); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("root") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root "); + + b.Property("rootId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root "); + + b.Property("rootShortName") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root "); + + b.HasKey("Id"); + + b.HasIndex("RetirementPeriodId"); + + b.ToTable("RetirementRawProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ActiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ขอออกราชการ"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("ApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติ"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("CancelReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยกเลิก"); + + b.Property("CommanderApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้บังคับบัญชา"); + + b.Property("CommanderReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้บังคับบัญชา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Group") + .HasColumnType("longtext") + .HasComment("คนยื่นมาอยู่ในกลุ่ม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("IsCancel") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยกเลิก"); + + b.Property("IsDiscipline") + .HasColumnType("tinyint(1)") + .HasComment("สถานะพฤติการณ์ทางวินัย"); + + b.Property("IsNoBurden") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่มีภาระผูกพันค้ำประกันทุนการศึกษา"); + + b.Property("IsNoDebt") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่เป็นหนี้สหกรณ์"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Location") + .HasColumnType("longtext") + .HasComment("สถานที่ยื่นขอลาออกราชการ"); + + b.Property("OfficerApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติการเจ้าหน้าที่"); + + b.Property("OfficerReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งการเจ้าหน้าที่"); + + b.Property("OligarchApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้ดูแล"); + + b.Property("OligarchReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้ดูแล"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("ReasonResign") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("RejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลไม่อนุมัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)"); + + b.Property("RemarkHorizontal") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("SendDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยื่นขอออกราชการ"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะลาออก"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("RetirementResigns"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Org") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionExecutiveName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RejectDate") + .HasColumnType("datetime(6)"); + + b.Property("RetirementResignId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignId"); + + b.ToTable("RetirementResignApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ActiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ขอออกราชการ"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("ApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติ"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("CancelReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยกเลิก"); + + b.Property("CommanderApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้บังคับบัญชา"); + + b.Property("CommanderReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้บังคับบัญชา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Group") + .HasColumnType("longtext") + .HasComment("คนยื่นมาอยู่ในกลุ่ม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("IsDiscipline") + .HasColumnType("tinyint(1)") + .HasComment("สถานะพฤติการณ์ทางวินัย"); + + b.Property("IsNoBurden") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่มีภาระผูกพันค้ำประกันทุนการศึกษา"); + + b.Property("IsNoDebt") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่เป็นหนี้สหกรณ์"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Location") + .HasColumnType("longtext") + .HasComment("สถานที่ยื่นขอลาออกราชการ"); + + b.Property("OfficerApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติการเจ้าหน้าที่"); + + b.Property("OfficerReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งการเจ้าหน้าที่"); + + b.Property("OligarchApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้ดูแล"); + + b.Property("OligarchReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้ดูแล"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionExecutiveOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหารเดิม"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("RejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลไม่อนุมัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)"); + + b.Property("RemarkHorizontal") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("RetirementResignId") + .HasColumnType("char(36)"); + + b.Property("SendDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยื่นขอออกราชการ"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะลาออก"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("positionArea") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา"); + + b.Property("positionAreaOld") + .HasColumnType("longtext") + .HasComment("ด้าน/สาขา (เก่า)"); + + b.Property("positionExecutiveField") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร"); + + b.Property("positionExecutiveFieldOld") + .HasColumnType("longtext") + .HasComment("ด้านทางการบริหาร (เก่า)"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignId"); + + b.ToTable("RetirementResignCancels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancelApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Org") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RejectDate") + .HasColumnType("datetime(6)"); + + b.Property("RetirementResignCancelId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignCancelId"); + + b.ToTable("RetirementResignCancelApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDebtDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RetirementResignId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementResignId"); + + b.ToTable("RetirementResignDebtDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RetirementResignId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementResignId"); + + b.ToTable("RetirementResignDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ActiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ขอออกราชการ"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("ApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติ"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("CancelReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยกเลิก"); + + b.Property("CommanderApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้บังคับบัญชา"); + + b.Property("CommanderReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้บังคับบัญชา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Group") + .HasColumnType("longtext") + .HasComment("คนยื่นมาอยู่ในกลุ่ม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("IsCancel") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยกเลิก"); + + b.Property("IsDiscipline") + .HasColumnType("tinyint(1)") + .HasComment("สถานะพฤติการณ์ทางวินัย"); + + b.Property("IsNoBurden") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่มีภาระผูกพันค้ำประกันทุนการศึกษา"); + + b.Property("IsNoDebt") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่เป็นหนี้สหกรณ์"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Location") + .HasColumnType("longtext") + .HasComment("สถานที่ยื่นขอลาออกราชการ"); + + b.Property("OfficerApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติการเจ้าหน้าที่"); + + b.Property("OfficerReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งการเจ้าหน้าที่"); + + b.Property("OligarchApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้ดูแล"); + + b.Property("OligarchReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้ดูแล"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("ReasonResign") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("RejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลไม่อนุมัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)"); + + b.Property("RemarkHorizontal") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("SendDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยื่นขอออกราชการ"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะลาออก"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.ToTable("RetirementResignEmployees"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Org") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionExecutiveName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RejectDate") + .HasColumnType("datetime(6)"); + + b.Property("RetirementResignEmployeeId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignEmployeeId"); + + b.ToTable("RetirementResignEmployeeApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ActiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ขอออกราชการ"); + + b.Property("AmountOld") + .HasColumnType("double") + .HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน"); + + b.Property("ApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติ"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("CancelReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยกเลิก"); + + b.Property("CommanderApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้บังคับบัญชา"); + + b.Property("CommanderReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้บังคับบัญชา"); + + b.Property("CommanderRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้บังคับบัญชา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Group") + .HasColumnType("longtext") + .HasComment("คนยื่นมาอยู่ในกลุ่ม"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการใช้งาน"); + + b.Property("IsDiscipline") + .HasColumnType("tinyint(1)") + .HasComment("สถานะพฤติการณ์ทางวินัย"); + + b.Property("IsNoBurden") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่มีภาระผูกพันค้ำประกันทุนการศึกษา"); + + b.Property("IsNoDebt") + .HasColumnType("tinyint(1)") + .HasComment("สถานะไม่เป็นหนี้สหกรณ์"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Location") + .HasColumnType("longtext") + .HasComment("สถานที่ยื่นขอลาออกราชการ"); + + b.Property("OfficerApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติการเจ้าหน้าที่"); + + b.Property("OfficerReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งการเจ้าหน้าที่"); + + b.Property("OfficerRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งการเจ้าหน้าที่"); + + b.Property("OligarchApproveReason") + .HasColumnType("longtext") + .HasComment("เหตุผลอนุมัติผู้ดูแล"); + + b.Property("OligarchReject") + .HasColumnType("tinyint(1)") + .HasComment("สถานะยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยับยั้งผู้ดูแล"); + + b.Property("OligarchRejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลยับยั้งผู้ดูแล"); + + b.Property("OrganizationOld") + .HasColumnType("longtext") + .HasComment("สังกัดเดิม"); + + b.Property("OrganizationPositionOld") + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PositionLevelOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ระดับ"); + + b.Property("PositionNumberOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม เลขที่"); + + b.Property("PositionOld") + .HasColumnType("longtext") + .HasComment("ตำแหน่งเดิม"); + + b.Property("PositionTypeOld") + .HasColumnType("longtext") + .HasComment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท"); + + b.Property("Reason") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ"); + + b.Property("RejectReason") + .HasColumnType("longtext") + .HasComment("เหตุผลไม่อนุมัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)"); + + b.Property("RemarkHorizontal") + .HasColumnType("longtext") + .HasComment("หมายเหตุแนวนอน"); + + b.Property("RetirementResignEmployeeId") + .HasColumnType("char(36)"); + + b.Property("SendDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่ยื่นขอออกราชการ"); + + b.Property("Status") + .HasColumnType("longtext") + .HasComment("สถานะลาออก"); + + b.Property("child1DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child1 old"); + + b.Property("child1OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child1 old"); + + b.Property("child1ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child1 old"); + + b.Property("child2DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child2 old"); + + b.Property("child2OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child2 old"); + + b.Property("child2ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child2 old"); + + b.Property("child3DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child3 old"); + + b.Property("child3OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child3 old"); + + b.Property("child3ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child3 old"); + + b.Property("child4DnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4Old") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน child4 old"); + + b.Property("child4OldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน child4 old"); + + b.Property("child4ShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน child4 old"); + + b.Property("citizenId") + .HasColumnType("longtext") + .HasComment("เลขบัตรประชาชน"); + + b.Property("firstName") + .HasColumnType("longtext") + .HasComment("ชื่อ"); + + b.Property("lastName") + .HasColumnType("longtext") + .HasComment("นามสกุล"); + + b.Property("posLevelNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อระดับตำแหน่ง old"); + + b.Property("posLevelOldId") + .HasColumnType("longtext") + .HasComment("id ระดับตำแหน่ง old"); + + b.Property("posMasterNoOld") + .HasColumnType("int") + .HasComment("เลขที่ตำแหน่ง old"); + + b.Property("posTypeNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อประเภทตำแหน่ง old"); + + b.Property("posTypeOldId") + .HasColumnType("longtext") + .HasComment("id ประเภทตำแหน่ง old"); + + b.Property("prefix") + .HasColumnType("longtext") + .HasComment("คำนำหน้า"); + + b.Property("profileId") + .HasColumnType("longtext") + .HasComment("profile Id"); + + b.Property("rootDnaOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootOld") + .HasColumnType("longtext") + .HasComment("ชื่อหน่วยงาน root old"); + + b.Property("rootOldId") + .HasColumnType("longtext") + .HasComment("id หน่วยงาน root old"); + + b.Property("rootShortNameOld") + .HasColumnType("longtext") + .HasComment("ชื่อย่อหน่วยงาน root old"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignEmployeeId"); + + b.ToTable("RetirementResignEmployeeCancels"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancelApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Org") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("RejectDate") + .HasColumnType("datetime(6)"); + + b.Property("RetirementResignEmployeeCancelId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RetirementResignEmployeeCancelId"); + + b.ToTable("RetirementResignEmployeeCancelApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDebtDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RetirementResignEmployeeId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementResignEmployeeId"); + + b.ToTable("RetirementResignEmployeeDebtDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDoc", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("RetirementResignEmployeeId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("RetirementResignEmployeeId"); + + b.ToTable("RetirementResignEmployeeDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b => + { + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", "CommandStatus") + .WithMany() + .HasForeignKey("CommandStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandType", "CommandType") + .WithMany() + .HasForeignKey("CommandTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.Placement", "Placement") + .WithMany() + .HasForeignKey("PlacementId"); + + b.Navigation("CommandStatus"); + + b.Navigation("CommandType"); + + b.Navigation("Placement"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b => + { + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command") + .WithMany("Deployments") + .HasForeignKey("CommandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Command"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command") + .WithMany("Documents") + .HasForeignKey("CommandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Command"); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b => + { + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command") + .WithMany("Receivers") + .HasForeignKey("CommandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Command"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitTypeLeave", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.LimitLeave", "LimitLeave") + .WithMany("LimitTypeLeaves") + .HasForeignKey("LimitLeaveId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.TypeLeave", "TypeLeave") + .WithMany("LimitTypeLeaves") + .HasForeignKey("TypeLeaveId"); + + b.Navigation("LimitLeave"); + + b.Navigation("TypeLeave"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.Profile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Avatar") + .WithMany() + .HasForeignKey("AvatarId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Gender", "Gender") + .WithMany() + .HasForeignKey("GenderId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.LimitLeave", "LimitLeave") + .WithMany("Profiles") + .HasForeignKey("LimitLeaveId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", "PosNo") + .WithMany() + .HasForeignKey("PosNoId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeGroup", "PositionEmployeeGroup") + .WithMany() + .HasForeignKey("PositionEmployeeGroupId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLevel", "PositionEmployeeLevel") + .WithMany() + .HasForeignKey("PositionEmployeeLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLine", "PositionEmployeeLine") + .WithMany() + .HasForeignKey("PositionEmployeeLineId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeePosition", "PositionEmployeePosition") + .WithMany() + .HasForeignKey("PositionEmployeePositionId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeePositionSide", "PositionEmployeePositionSide") + .WithMany() + .HasForeignKey("PositionEmployeePositionSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "Position") + .WithMany() + .HasForeignKey("PositionId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel") + .WithMany() + .HasForeignKey("PositionLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType") + .WithMany() + .HasForeignKey("PositionTypeId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Prefix", "Prefix") + .WithMany() + .HasForeignKey("PrefixId"); + + b.Navigation("Avatar"); + + b.Navigation("Gender"); + + b.Navigation("LimitLeave"); + + b.Navigation("PosNo"); + + b.Navigation("Position"); + + b.Navigation("PositionEmployeeGroup"); + + b.Navigation("PositionEmployeeLevel"); + + b.Navigation("PositionEmployeeLine"); + + b.Navigation("PositionEmployeePosition"); + + b.Navigation("PositionEmployeePositionSide"); + + b.Navigation("PositionLevel"); + + b.Navigation("PositionType"); + + b.Navigation("Prefix"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbility", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Abilitys") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbilityHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileAbility", "ProfileAbility") + .WithMany("ProfileAbilityHistorys") + .HasForeignKey("ProfileAbilityId"); + + b.Navigation("ProfileAbility"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAddressHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("AddressHistory") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAssessment", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Assessments") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAssessmentHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileAssessment", "ProfileAssessment") + .WithMany("ProfileAssessmentHistorys") + .HasForeignKey("ProfileAssessmentId"); + + b.Navigation("ProfileAssessment"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAvatarHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "AvatarFile") + .WithMany() + .HasForeignKey("AvatarFileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("AvatarHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AvatarFile"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCertificate", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Certificates") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCertificateHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileCertificate", "ProfileCertificate") + .WithMany("ProfileCertificateHistorys") + .HasForeignKey("ProfileCertificateId"); + + b.Navigation("ProfileCertificate"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChangeName", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("ChangeNames") + .HasForeignKey("ProfileId"); + + b.Navigation("Document"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChangeNameHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileChangeName", "ProfileChangeName") + .WithMany("ProfileChangeNameHistorys") + .HasForeignKey("ProfileChangeNameId"); + + b.Navigation("Document"); + + b.Navigation("ProfileChangeName"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChildren", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Childrens") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChildrenHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileChildren", null) + .WithMany("ProfileChildrenHistorys") + .HasForeignKey("ProfileChildrenId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", null) + .WithMany("Childrens") + .HasForeignKey("ProfileFamilyHistoryId"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCoupleHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("CoupleHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCurrentAddressHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("CurrentAddressHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDiscipline", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Disciplines") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDisciplineHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileDiscipline", "ProfileDiscipline") + .WithMany("ProfileDisciplineHistorys") + .HasForeignKey("ProfileDisciplineId"); + + b.Navigation("ProfileDiscipline"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDuty", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Dutys") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDutyHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileDuty", "ProfileDuty") + .WithMany("ProfileDutyHistorys") + .HasForeignKey("ProfileDutyId"); + + b.Navigation("ProfileDuty"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEducation", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Educations") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEducationHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileEducation", "ProfileEducation") + .WithMany("ProfileEducationHistorys") + .HasForeignKey("ProfileEducationId"); + + b.Navigation("ProfileEducation"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmployment", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Employments") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEmploymentHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileEmployment", "ProfileEmployment") + .WithMany() + .HasForeignKey("ProfileEmploymentId"); + + b.Navigation("ProfileEmployment"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("FamilyHistory") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFatherHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("FatherHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileGovernmentHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("GovernmentHistory") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("ProfileHistory") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHonor", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Honors") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHonorHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileHonor", "ProfileHonor") + .WithMany("ProfileHonorHistorys") + .HasForeignKey("ProfileHonorId"); + + b.Navigation("ProfileHonor"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsignia", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "Insignia") + .WithMany() + .HasForeignKey("InsigniaId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", null) + .WithMany("Insignias") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Insignia"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsigniaHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileInsignia", "ProfileInsignia") + .WithMany("ProfileInsigniaHistorys") + .HasForeignKey("ProfileInsigniaId"); + + b.Navigation("ProfileInsignia"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeave", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", null) + .WithMany("Leaves") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.HR.TypeLeave", "TypeLeave") + .WithMany() + .HasForeignKey("TypeLeaveId"); + + b.Navigation("TypeLeave"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeaveHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileLeave", "ProfileLeave") + .WithMany("ProfileLeaveHistorys") + .HasForeignKey("ProfileLeaveId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.TypeLeave", "TypeLeave") + .WithMany() + .HasForeignKey("TypeLeaveId"); + + b.Navigation("ProfileLeave"); + + b.Navigation("TypeLeave"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeaveSummary", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("LeaveSummary") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileMotherHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("MotherHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileNopaid", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Nopaids") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileNopaidHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileNopaid", "ProfileNopaid") + .WithMany("ProfileNopaidHistorys") + .HasForeignKey("ProfileNopaidId"); + + b.Navigation("ProfileNopaid"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOther", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Others") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOtherHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileOther", "ProfileOther") + .WithMany("ProfileOtherHistorys") + .HasForeignKey("ProfileOtherId"); + + b.Navigation("ProfileOther"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfilePaper", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Papers") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileRegistrationAddressHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("RegistrationAddressHistory") + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalary", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel") + .WithMany() + .HasForeignKey("PositionLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Salaries") + .HasForeignKey("ProfileId"); + + b.Navigation("PositionLevel"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileSalary", "ProfileSalary") + .WithMany("ProfileSalaryHistorys") + .HasForeignKey("ProfileSalaryId"); + + b.Navigation("ProfileSalary"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalaryPosition", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileTraining", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany("Trainings") + .HasForeignKey("ProfileId"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileTrainingHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.ProfileTraining", "ProfileTraining") + .WithMany("ProfileTrainingHistorys") + .HasForeignKey("ProfileTrainingId"); + + b.Navigation("ProfileTraining"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaEmployee", b => + { + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", "InsigniaPeriod") + .WithMany("InsigniaEmployees") + .HasForeignKey("InsigniaPeriodId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InsigniaPeriod"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManage", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "Insignia") + .WithMany() + .HasForeignKey("InsigniaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Insignia"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManageOrganiation", b => + { + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaManage", "InsigniaManage") + .WithMany("InsigniaManageOrganiations") + .HasForeignKey("InsigniaManageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InsigniaManage"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManageProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaManageOrganiation", "InsigniaManageOrganiation") + .WithMany("InsigniaManageProfiles") + .HasForeignKey("InsigniaManageOrganiationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", "InsigniaNoteProfile") + .WithMany() + .HasForeignKey("InsigniaNoteProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InsigniaManageOrganiation"); + + b.Navigation("InsigniaNoteProfile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNote", "InsigniaNote") + .WithMany("InsigniaNoteDocs") + .HasForeignKey("InsigniaNoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("InsigniaNote"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "DocReceiveInsignia") + .WithMany() + .HasForeignKey("DocReceiveInsigniaId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "DocReturnInsignia") + .WithMany() + .HasForeignKey("DocReturnInsigniaId"); + + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNote", "InsigniaNote") + .WithMany("InsigniaNoteProfiles") + .HasForeignKey("InsigniaNoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "RequestInsignia") + .WithMany() + .HasForeignKey("RequestInsigniaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DocReceiveInsignia"); + + b.Navigation("DocReturnInsignia"); + + b.Navigation("InsigniaNote"); + + b.Navigation("RequestInsignia"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "ReliefDoc") + .WithMany() + .HasForeignKey("ReliefDocId"); + + b.Navigation("ReliefDoc"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaReclaimProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", "InsigniaNoteProfile") + .WithMany() + .HasForeignKey("InsigniaNoteProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InsigniaNoteProfile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", "Period") + .WithMany("InsigniaRequests") + .HasForeignKey("PeriodId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("Period"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequestProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", "Request") + .WithMany("RequestProfiles") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "RequestInsignia") + .WithMany() + .HasForeignKey("RequestInsigniaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + + b.Navigation("RequestInsignia"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.District", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.Province", "Province") + .WithMany("Districts") + .HasForeignKey("ProvinceId"); + + b.Navigation("Province"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Insignia", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.InsigniaType", "InsigniaType") + .WithMany() + .HasForeignKey("InsigniaTypeId"); + + b.Navigation("InsigniaType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Position", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionExecutiveSide", "ExecutiveSide") + .WithMany() + .HasForeignKey("ExecutiveSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPathSide", "PathSide") + .WithMany() + .HasForeignKey("PathSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel") + .WithMany() + .HasForeignKey("PositionLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionPath") + .WithMany() + .HasForeignKey("PositionPathId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType") + .WithMany() + .HasForeignKey("PositionTypeId"); + + b.Navigation("ExecutiveSide"); + + b.Navigation("PathSide"); + + b.Navigation("PositionLevel"); + + b.Navigation("PositionPath"); + + b.Navigation("PositionType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.SubDistrict", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.District", "District") + .WithMany("SubDistricts") + .HasForeignKey("DistrictId"); + + b.Navigation("District"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", b => + { + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "OrganizationAgency") + .WithMany() + .HasForeignKey("OrganizationAgencyId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationFax", "OrganizationFax") + .WithMany() + .HasForeignKey("OrganizationFaxId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "OrganizationGovernmentAgency") + .WithMany() + .HasForeignKey("OrganizationGovernmentAgencyId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "Organization") + .WithMany() + .HasForeignKey("OrganizationId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationLevel", "OrganizationLevel") + .WithMany() + .HasForeignKey("OrganizationLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganization") + .WithMany() + .HasForeignKey("OrganizationOrganizationId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationShortName", "OrganizationShortName") + .WithMany() + .HasForeignKey("OrganizationShortNameId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationTelExternal", "OrganizationTelExternal") + .WithMany() + .HasForeignKey("OrganizationTelExternalId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationTelInternal", "OrganizationTelInternal") + .WithMany() + .HasForeignKey("OrganizationTelInternalId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationType", "OrganizationType") + .WithMany() + .HasForeignKey("OrganizationTypeId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLine", "PositionEmployeeLine") + .WithMany() + .HasForeignKey("PositionEmployeeLineId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeePosition", "PositionEmployeePosition") + .WithMany() + .HasForeignKey("PositionEmployeePositionId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeStatus", "PositionEmployeeStatus") + .WithMany() + .HasForeignKey("PositionEmployeeStatusId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId"); + + b.Navigation("Organization"); + + b.Navigation("OrganizationAgency"); + + b.Navigation("OrganizationFax"); + + b.Navigation("OrganizationGovernmentAgency"); + + b.Navigation("OrganizationLevel"); + + b.Navigation("OrganizationOrganization"); + + b.Navigation("OrganizationShortName"); + + b.Navigation("OrganizationTelExternal"); + + b.Navigation("OrganizationTelInternal"); + + b.Navigation("OrganizationType"); + + b.Navigation("PositionEmployeeLine"); + + b.Navigation("PositionEmployeePosition"); + + b.Navigation("PositionEmployeeStatus"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationEmployeeProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", "OrgEmployee") + .WithMany("OrganizationEmployeeProfiles") + .HasForeignKey("OrgEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrgEmployee"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeeLevel", b => + { + b.HasOne("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", "OrganizationEmployee") + .WithMany("OrganizationPositionEmployeeLevels") + .HasForeignKey("OrganizationEmployeeId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeeLevel", "PositionEmployeeLevel") + .WithMany() + .HasForeignKey("PositionEmployeeLevelId"); + + b.Navigation("OrganizationEmployee"); + + b.Navigation("PositionEmployeeLevel"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeePositionSide", b => + { + b.HasOne("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", "OrganizationEmployee") + .WithMany("OrganizationPositionEmployeePositionSides") + .HasForeignKey("OrganizationEmployeeId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionEmployeePositionSide", "PositionEmployeePositionSide") + .WithMany() + .HasForeignKey("PositionEmployeePositionSideId"); + + b.Navigation("OrganizationEmployee"); + + b.Navigation("PositionEmployeePositionSide"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.AvailablePositionLevelEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel") + .WithMany() + .HasForeignKey("PositionLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", "PositionMaster") + .WithMany() + .HasForeignKey("PositionMasterId"); + + b.Navigation("PositionLevel"); + + b.Navigation("PositionMaster"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationFax", "OrganizationFax") + .WithMany() + .HasForeignKey("OrganizationFaxId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationLevel", "OrganizationLevel") + .WithMany() + .HasForeignKey("OrganizationLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganization") + .WithMany() + .HasForeignKey("OrganizationOrganizationId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationShortName", "OrganizationShortName") + .WithMany() + .HasForeignKey("OrganizationShortNameId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationStatus", "OrganizationStatus") + .WithMany() + .HasForeignKey("OrganizationStatusId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationTelExternal", "OrganizationTelExternal") + .WithMany() + .HasForeignKey("OrganizationTelExternalId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationTelInternal", "OrganizationTelInternal") + .WithMany() + .HasForeignKey("OrganizationTelInternalId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationType", "OrganizationType") + .WithMany() + .HasForeignKey("OrganizationTypeId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "Parent") + .WithMany("Organizations") + .HasForeignKey("ParentId"); + + b.Navigation("OrganizationFax"); + + b.Navigation("OrganizationLevel"); + + b.Navigation("OrganizationOrganization"); + + b.Navigation("OrganizationShortName"); + + b.Navigation("OrganizationStatus"); + + b.Navigation("OrganizationTelExternal"); + + b.Navigation("OrganizationTelInternal"); + + b.Navigation("OrganizationType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationPositionEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "Organization") + .WithMany() + .HasForeignKey("OrganizationId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", "PositionMaster") + .WithMany() + .HasForeignKey("PositionMasterId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", "PositionNumber") + .WithMany() + .HasForeignKey("PositionNumberId"); + + b.Navigation("Organization"); + + b.Navigation("PositionMaster"); + + b.Navigation("PositionNumber"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionExecutive", "PositionExecutive") + .WithMany() + .HasForeignKey("PositionExecutiveId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionExecutiveSide", "PositionExecutiveSide") + .WithMany() + .HasForeignKey("PositionExecutiveSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLine", "PositionLine") + .WithMany() + .HasForeignKey("PositionLineId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionPath") + .WithMany() + .HasForeignKey("PositionPathId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPathSide", "PositionPathSide") + .WithMany() + .HasForeignKey("PositionPathSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionStatus", "PositionStatus") + .WithMany() + .HasForeignKey("PositionStatusId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType") + .WithMany() + .HasForeignKey("PositionTypeId"); + + b.Navigation("PositionExecutive"); + + b.Navigation("PositionExecutiveSide"); + + b.Navigation("PositionLine"); + + b.Navigation("PositionPath"); + + b.Navigation("PositionPathSide"); + + b.Navigation("PositionStatus"); + + b.Navigation("PositionType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionMasterHistoryEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", "PositionMasterEntity") + .WithMany("PositionMasterHistorys") + .HasForeignKey("PositionMasterEntityId"); + + b.Navigation("PositionMasterEntity"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationShortName", "OrganizationShortName") + .WithMany() + .HasForeignKey("OrganizationShortNameId"); + + b.Navigation("OrganizationShortName"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.ProfilePosition", b => + { + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationPositionEntity", "OrganizationPosition") + .WithMany() + .HasForeignKey("OrganizationPositionId"); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId"); + + b.Navigation("OrganizationPosition"); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.Report2.Report2History", b => + { + b.HasOne("BMA.EHR.Domain.Models.Organizations.Report2.Report2DetailHistory", "Report2DetailHistory") + .WithMany() + .HasForeignKey("Report2DetailHistoryId"); + + b.Navigation("Report2DetailHistory"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.Placement", b => + { + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementType", "PlacementType") + .WithMany() + .HasForeignKey("PlacementTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlacementType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementAppointmentDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementAppointment", "PlacementAppointment") + .WithMany("PlacementAppointmentDocs") + .HasForeignKey("PlacementAppointmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PlacementAppointment"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b => + { + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementProfile", "PlacementProfile") + .WithMany("PlacementCertificates") + .HasForeignKey("PlacementProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PlacementProfile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementEducation", b => + { + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementProfile", "PlacementProfile") + .WithMany("PlacementEducations") + .HasForeignKey("PlacementProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionPath") + .WithMany() + .HasForeignKey("PositionPathId"); + + b.Navigation("PlacementProfile"); + + b.Navigation("PositionPath"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Placement.Placement", "Placement") + .WithMany("PlacementProfiles") + .HasForeignKey("PlacementId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "ProfileImg") + .WithMany() + .HasForeignKey("ProfileImgId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "ReliefDoc") + .WithMany() + .HasForeignKey("ReliefDocId"); + + b.Navigation("Placement"); + + b.Navigation("ProfileImg"); + + b.Navigation("ReliefDoc"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfileDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementProfile", "PlacementProfile") + .WithMany("PlacementProfileDocs") + .HasForeignKey("PlacementProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PlacementProfile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Avatar") + .WithMany() + .HasForeignKey("AvatarId"); + + b.Navigation("Avatar"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceiveDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementReceive", "PlacementReceive") + .WithMany("PlacementReceiveDocs") + .HasForeignKey("PlacementReceiveId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PlacementReceive"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRelocation", b => + { + b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup") + .WithMany() + .HasForeignKey("BloodGroupId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Gender", "Gender") + .WithMany() + .HasForeignKey("GenderId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationPositionEntity", "OrganizationPosition") + .WithMany() + .HasForeignKey("OrganizationPositionId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel") + .WithMany() + .HasForeignKey("PositionLevelId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLine", "PositionLine") + .WithMany() + .HasForeignKey("PositionLineId"); + + b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", "PositionNumber") + .WithMany() + .HasForeignKey("PositionNumberId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionPath") + .WithMany() + .HasForeignKey("PositionPathId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPathSide", "PositionPathSide") + .WithMany() + .HasForeignKey("PositionPathSideId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType") + .WithMany() + .HasForeignKey("PositionTypeId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Prefix", "Prefix") + .WithMany() + .HasForeignKey("PrefixId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Relationship", "Relationship") + .WithMany() + .HasForeignKey("RelationshipId"); + + b.HasOne("BMA.EHR.Domain.Models.MetaData.Religion", "Religion") + .WithMany() + .HasForeignKey("ReligionId"); + + b.Navigation("BloodGroup"); + + b.Navigation("Gender"); + + b.Navigation("OrganizationPosition"); + + b.Navigation("PositionLevel"); + + b.Navigation("PositionLine"); + + b.Navigation("PositionNumber"); + + b.Navigation("PositionPath"); + + b.Navigation("PositionPathSide"); + + b.Navigation("PositionType"); + + b.Navigation("Prefix"); + + b.Navigation("Profile"); + + b.Navigation("Relationship"); + + b.Navigation("Religion"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRelocationDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementRelocation", "PlacementRelocation") + .WithMany("PlacementRelocationDocs") + .HasForeignKey("PlacementRelocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PlacementRelocation"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransferDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementTransfer", "PlacementTransfer") + .WithMany("PlacementTransferDocs") + .HasForeignKey("PlacementTransferId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("PlacementTransfer"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "DocumentForward") + .WithMany() + .HasForeignKey("DocumentForwardId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.Navigation("Document"); + + b.Navigation("DocumentForward"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceasedNoti", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", "RetirementDeceased") + .WithMany("RetirementDeceasedNotis") + .HasForeignKey("RetirementDeceasedId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementDeceased"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDischarge", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementEmployeeQuestion", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee") + .WithMany() + .HasForeignKey("RetirementResignEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResignEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementExpulsion", b => + { + b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") + .WithMany() + .HasForeignKey("ProfileId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Profile"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOther", b => + { + b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandType", "CommandType") + .WithMany() + .HasForeignKey("CommandTypeId"); + + b.Navigation("CommandType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOtherDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementOther", "RetirementOther") + .WithMany("RetirementOtherDocs") + .HasForeignKey("RetirementOtherId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementOther"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod") + .WithMany("RetirementPeriodHistorys") + .HasForeignKey("RetirementPeriodId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementPeriod"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod") + .WithMany("RetirementProfiles") + .HasForeignKey("RetirementPeriodId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementPeriod"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementQuestion", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign") + .WithMany() + .HasForeignKey("RetirementResignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResign"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementRawProfile", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod") + .WithMany("RetirementRawProfiles") + .HasForeignKey("RetirementPeriodId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementPeriod"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign") + .WithMany("Approvers") + .HasForeignKey("RetirementResignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResign"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign") + .WithMany("RetirementResignCancels") + .HasForeignKey("RetirementResignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResign"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancelApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", "RetirementResignCancel") + .WithMany("Approvers") + .HasForeignKey("RetirementResignCancelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResignCancel"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDebtDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign") + .WithMany("RetirementResignDebtDocs") + .HasForeignKey("RetirementResignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementResign"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign") + .WithMany("RetirementResignDocs") + .HasForeignKey("RetirementResignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementResign"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee") + .WithMany("Approvers") + .HasForeignKey("RetirementResignEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResignEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee") + .WithMany("RetirementResignEmployeeCancels") + .HasForeignKey("RetirementResignEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResignEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancelApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", "RetirementResignEmployeeCancel") + .WithMany("Approvers") + .HasForeignKey("RetirementResignEmployeeCancelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RetirementResignEmployeeCancel"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDebtDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee") + .WithMany("RetirementResignEmployeeDebtDocs") + .HasForeignKey("RetirementResignEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementResignEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeDoc", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", "RetirementResignEmployee") + .WithMany("RetirementResignEmployeeDocs") + .HasForeignKey("RetirementResignEmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("RetirementResignEmployee"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b => + { + b.Navigation("Deployments"); + + b.Navigation("Documents"); + + b.Navigation("Receivers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b => + { + b.Navigation("LimitTypeLeaves"); + + b.Navigation("Profiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.Profile", b => + { + b.Navigation("Abilitys"); + + b.Navigation("AddressHistory"); + + b.Navigation("Assessments"); + + b.Navigation("AvatarHistory"); + + b.Navigation("Certificates"); + + b.Navigation("ChangeNames"); + + b.Navigation("Childrens"); + + b.Navigation("CoupleHistory"); + + b.Navigation("CurrentAddressHistory"); + + b.Navigation("Disciplines"); + + b.Navigation("Dutys"); + + b.Navigation("Educations"); + + b.Navigation("Employments"); + + b.Navigation("FamilyHistory"); + + b.Navigation("FatherHistory"); + + b.Navigation("GovernmentHistory"); + + b.Navigation("Honors"); + + b.Navigation("Insignias"); + + b.Navigation("LeaveSummary"); + + b.Navigation("Leaves"); + + b.Navigation("MotherHistory"); + + b.Navigation("Nopaids"); + + b.Navigation("Others"); + + b.Navigation("Papers"); + + b.Navigation("ProfileHistory"); + + b.Navigation("RegistrationAddressHistory"); + + b.Navigation("Salaries"); + + b.Navigation("Trainings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbility", b => + { + b.Navigation("ProfileAbilityHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAssessment", b => + { + b.Navigation("ProfileAssessmentHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileCertificate", b => + { + b.Navigation("ProfileCertificateHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChangeName", b => + { + b.Navigation("ProfileChangeNameHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileChildren", b => + { + b.Navigation("ProfileChildrenHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDiscipline", b => + { + b.Navigation("ProfileDisciplineHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileDuty", b => + { + b.Navigation("ProfileDutyHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileEducation", b => + { + b.Navigation("ProfileEducationHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileFamilyHistory", b => + { + b.Navigation("Childrens"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileHonor", b => + { + b.Navigation("ProfileHonorHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsignia", b => + { + b.Navigation("ProfileInsigniaHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileLeave", b => + { + b.Navigation("ProfileLeaveHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileNopaid", b => + { + b.Navigation("ProfileNopaidHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileOther", b => + { + b.Navigation("ProfileOtherHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalary", b => + { + b.Navigation("ProfileSalaryHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileTraining", b => + { + b.Navigation("ProfileTrainingHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.HR.TypeLeave", b => + { + b.Navigation("LimitTypeLeaves"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManage", b => + { + b.Navigation("InsigniaManageOrganiations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManageOrganiation", b => + { + b.Navigation("InsigniaManageProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNote", b => + { + b.Navigation("InsigniaNoteDocs"); + + b.Navigation("InsigniaNoteProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b => + { + b.Navigation("InsigniaEmployees"); + + b.Navigation("InsigniaRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b => + { + b.Navigation("RequestProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.District", b => + { + b.Navigation("SubDistricts"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.MetaData.Province", b => + { + b.Navigation("Districts"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", b => + { + b.Navigation("OrganizationEmployeeProfiles"); + + b.Navigation("OrganizationPositionEmployeeLevels"); + + b.Navigation("OrganizationPositionEmployeePositionSides"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", b => + { + b.Navigation("Organizations"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.PositionMasterEntity", b => + { + b.Navigation("PositionMasterHistorys"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.Placement", b => + { + b.Navigation("PlacementProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementAppointment", b => + { + b.Navigation("PlacementAppointmentDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b => + { + b.Navigation("PlacementCertificates"); + + b.Navigation("PlacementEducations"); + + b.Navigation("PlacementProfileDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b => + { + b.Navigation("PlacementReceiveDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementRelocation", b => + { + b.Navigation("PlacementRelocationDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransfer", b => + { + b.Navigation("PlacementTransferDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", b => + { + b.Navigation("RetirementDeceasedNotis"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementOther", b => + { + b.Navigation("RetirementOtherDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b => + { + b.Navigation("RetirementPeriodHistorys"); + + b.Navigation("RetirementProfiles"); + + b.Navigation("RetirementRawProfiles"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b => + { + b.Navigation("Approvers"); + + b.Navigation("RetirementResignCancels"); + + b.Navigation("RetirementResignDebtDocs"); + + b.Navigation("RetirementResignDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignCancel", b => + { + b.Navigation("Approvers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployee", b => + { + b.Navigation("Approvers"); + + b.Navigation("RetirementResignEmployeeCancels"); + + b.Navigation("RetirementResignEmployeeDebtDocs"); + + b.Navigation("RetirementResignEmployeeDocs"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignEmployeeCancel", b => + { + b.Navigation("Approvers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.cs b/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.cs new file mode 100644 index 00000000..1a258f42 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/20260512073417_update_PlacementReceives_add_rank.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations +{ + /// + public partial class update_PlacementReceives_add_rank : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "rank", + table: "PlacementReceives", + type: "longtext", + nullable: true, + comment: "ยศ") + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "rank", + table: "PlacementReceives"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs b/BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs index 56218ff2..b0a92489 100644 --- a/BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs +++ b/BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs @@ -13693,6 +13693,10 @@ namespace BMA.EHR.Infrastructure.Migrations .HasColumnType("longtext") .HasComment("profile Id"); + b.Property("rank") + .HasColumnType("longtext") + .HasComment("ยศ"); + b.Property("root") .HasColumnType("longtext") .HasComment("ชื่อหน่วยงาน root"); diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.Designer.cs new file mode 100644 index 00000000..8a505bde --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.Designer.cs @@ -0,0 +1,1612 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260115140500_add_fields_table_eaveequestpprover")] + partial class add_fields_table_eaveequestpprover + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.cs new file mode 100644 index 00000000..02aee038 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260115140500_add_fields_table_eaveequestpprover.cs @@ -0,0 +1,54 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class add_fields_table_eaveequestpprover : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OrganizationName", + table: "LeaveRequestApprovers", + type: "longtext", + nullable: false, + comment: "สังกัด") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "PosExecutiveName", + table: "LeaveRequestApprovers", + type: "longtext", + nullable: false, + comment: "ตำแหน่งทางการบริหาร") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "PositionLevelName", + table: "LeaveRequestApprovers", + type: "longtext", + nullable: false, + comment: "ประเภทระดับตำแหน่ง") + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "OrganizationName", + table: "LeaveRequestApprovers"); + + migrationBuilder.DropColumn( + name: "PosExecutiveName", + table: "LeaveRequestApprovers"); + + migrationBuilder.DropColumn( + name: "PositionLevelName", + table: "LeaveRequestApprovers"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.Designer.cs new file mode 100644 index 00000000..a7f4e1fb --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.Designer.cs @@ -0,0 +1,1705 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260120032158_Add RMQ Task Control")] + partial class AddRMQTaskControl + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.cs new file mode 100644 index 00000000..f8d2090b --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260120032158_Add RMQ Task Control.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddRMQTaskControl : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CheckInJobStatuses", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"), + CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล") + .Annotation("MySql:CharSet", "utf8mb4"), + LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"), + LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด") + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล") + .Annotation("MySql:CharSet", "utf8mb4"), + LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด") + .Annotation("MySql:CharSet", "utf8mb4"), + TaskId = table.Column(type: "char(36)", nullable: false, comment: "Task ID สำหรับติดตามสถานะงาน", collation: "ascii_general_ci"), + KeycloakUserId = table.Column(type: "char(36)", nullable: false, comment: "รหัส User ของ Keycloak", collation: "ascii_general_ci"), + CreatedDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันเวลาที่สร้างงาน"), + ProcessingDate = table.Column(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เริ่มประมวลผล"), + CompletedDate = table.Column(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เสร็จสิ้นการประมวลผล"), + Status = table.Column(type: "longtext", nullable: false, comment: "สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED") + .Annotation("MySql:CharSet", "utf8mb4"), + CheckType = table.Column(type: "longtext", nullable: true, comment: "ประเภทการลงเวลา: CHECK_IN, CHECK_OUT") + .Annotation("MySql:CharSet", "utf8mb4"), + CheckInId = table.Column(type: "char(36)", nullable: true, comment: "CheckInId สำหรับ Check-Out", collation: "ascii_general_ci"), + ErrorMessage = table.Column(type: "longtext", nullable: true, comment: "ข้อความแสดงข้อผิดพลาด") + .Annotation("MySql:CharSet", "utf8mb4"), + AdditionalData = table.Column(type: "longtext", nullable: true, comment: "ข้อมูลเพิ่มเติม (JSON)") + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_CheckInJobStatuses", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CheckInJobStatuses"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.Designer.cs new file mode 100644 index 00000000..acd7320f --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.Designer.cs @@ -0,0 +1,1709 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260205034753_Add LeaveCount to LeaveBeginning")] + partial class AddLeaveCounttoLeaveBeginning + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.cs new file mode 100644 index 00000000..35fecaea --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260205034753_Add LeaveCount to LeaveBeginning.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddLeaveCounttoLeaveBeginning : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LeaveCount", + table: "LeaveBeginnings", + type: "int", + nullable: false, + defaultValue: 0, + comment: "จำนวนครั้งที่ลาสะสม"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LeaveCount", + table: "LeaveBeginnings"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.Designer.cs new file mode 100644 index 00000000..934ba1a9 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.Designer.cs @@ -0,0 +1,1717 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning")] + partial class AddBeginningLeaveandLeaveCounttoLeaveBeginning + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลาทั้งหมด"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.cs new file mode 100644 index 00000000..a54ad519 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260210091134_Add BeginningLeave and LeaveCount to LeaveBeginning.cs @@ -0,0 +1,62 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddBeginningLeaveandLeaveCounttoLeaveBeginning : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "LeaveDays", + table: "LeaveBeginnings", + type: "double", + nullable: false, + comment: "จำนวนวันลาทั้งหมด", + oldClrType: typeof(double), + oldType: "double", + oldComment: "จำนวนวันลายกมา"); + + migrationBuilder.AddColumn( + name: "BeginningLeaveCount", + table: "LeaveBeginnings", + type: "int", + nullable: false, + defaultValue: 0, + comment: "จำนวนครั้งที่ลายกมา"); + + migrationBuilder.AddColumn( + name: "BeginningLeaveDays", + table: "LeaveBeginnings", + type: "double", + nullable: false, + defaultValue: 0.0, + comment: "จำนวนวันลายกมา"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "BeginningLeaveCount", + table: "LeaveBeginnings"); + + migrationBuilder.DropColumn( + name: "BeginningLeaveDays", + table: "LeaveBeginnings"); + + migrationBuilder.AlterColumn( + name: "LeaveDays", + table: "LeaveBeginnings", + type: "double", + nullable: false, + comment: "จำนวนวันลายกมา", + oldClrType: typeof(double), + oldType: "double", + oldComment: "จำนวนวันลาทั้งหมด"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.Designer.cs new file mode 100644 index 00000000..815f8188 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.Designer.cs @@ -0,0 +1,1802 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260330020909_Add Leave Process Job Status")] + partial class AddLeaveProcessJobStatus + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลาทั้งหมด"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุด"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("RootDnaId") + .HasColumnType("char(36)") + .HasComment("รหัส Root DNA Id"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้น"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.HasKey("Id"); + + b.ToTable("LeaveProcessJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.cs new file mode 100644 index 00000000..1567dc5e --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260330020909_Add Leave Process Job Status.cs @@ -0,0 +1,54 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddLeaveProcessJobStatus : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "LeaveProcessJobStatuses", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"), + CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล") + .Annotation("MySql:CharSet", "utf8mb4"), + LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"), + LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด") + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล") + .Annotation("MySql:CharSet", "utf8mb4"), + LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด") + .Annotation("MySql:CharSet", "utf8mb4"), + StartDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันเริ่มต้น"), + EndDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันสิ้นสุด"), + RootDnaId = table.Column(type: "char(36)", nullable: false, comment: "รหัส Root DNA Id", collation: "ascii_general_ci"), + CreatedDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันเวลาที่สร้างงาน"), + ProcessingDate = table.Column(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เริ่มประมวลผล"), + CompletedDate = table.Column(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เสร็จสิ้นการประมวลผล"), + Status = table.Column(type: "longtext", nullable: false, comment: "สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED") + .Annotation("MySql:CharSet", "utf8mb4"), + ErrorMessage = table.Column(type: "longtext", nullable: true, comment: "ข้อความแสดงข้อผิดพลาด") + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_LeaveProcessJobStatuses", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "LeaveProcessJobStatuses"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.Designer.cs new file mode 100644 index 00000000..8e79c20b --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.Designer.cs @@ -0,0 +1,1805 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260423083625_Add DateSendLeave")] + partial class AddDateSendLeave + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลาทั้งหมด"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("DateSendLeave") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุด"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("RootDnaId") + .HasColumnType("char(36)") + .HasComment("รหัส Root DNA Id"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้น"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.HasKey("Id"); + + b.ToTable("LeaveProcessJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.cs new file mode 100644 index 00000000..02d58933 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260423083625_Add DateSendLeave.cs @@ -0,0 +1,29 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddDateSendLeave : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DateSendLeave", + table: "LeaveRequests", + type: "datetime(6)", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateSendLeave", + table: "LeaveRequests"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.Designer.cs new file mode 100644 index 00000000..f95eab33 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.Designer.cs @@ -0,0 +1,1805 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260505035145_Change Field")] + partial class ChangeField + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลาทั้งหมด"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("DateSendLeave") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุด"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("RootDnaId") + .HasColumnType("char(36)") + .HasComment("รหัส Root DNA Id"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้น"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.HasKey("Id"); + + b.ToTable("LeaveProcessJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.cs new file mode 100644 index 00000000..a6ffb9e4 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260505035145_Change Field.cs @@ -0,0 +1,62 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class ChangeField : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "LeaveDaysUsed", + table: "LeaveBeginnings", + type: "double", + nullable: true, + comment: "จำนวนวันลาที่ใช้ไป", + oldClrType: typeof(double), + oldType: "double", + oldComment: "จำนวนวันลาที่ใช้ไป"); + + migrationBuilder.AlterColumn( + name: "LeaveCount", + table: "LeaveBeginnings", + type: "int", + nullable: true, + comment: "จำนวนครั้งที่ลาสะสม", + oldClrType: typeof(int), + oldType: "int", + oldComment: "จำนวนครั้งที่ลาสะสม"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "LeaveDaysUsed", + table: "LeaveBeginnings", + type: "double", + nullable: false, + defaultValue: 0.0, + comment: "จำนวนวันลาที่ใช้ไป", + oldClrType: typeof(double), + oldType: "double", + oldNullable: true, + oldComment: "จำนวนวันลาที่ใช้ไป"); + + migrationBuilder.AlterColumn( + name: "LeaveCount", + table: "LeaveBeginnings", + type: "int", + nullable: false, + defaultValue: 0, + comment: "จำนวนครั้งที่ลาสะสม", + oldClrType: typeof(int), + oldType: "int", + oldNullable: true, + oldComment: "จำนวนครั้งที่ลาสะสม"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.Designer.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.Designer.cs new file mode 100644 index 00000000..165b8195 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.Designer.cs @@ -0,0 +1,1812 @@ +// +using System; +using BMA.EHR.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + [DbContext(typeof(LeaveDbContext))] + [Migration("20260511075931_Add Approver Field")] + partial class AddApproverField + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectRefId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Code") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รหัสประเภทการลา"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Limit") + .HasColumnType("int") + .HasComment("จำนวนวันลาสูงสุดประจำปี"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อประเภทการลา"); + + b.HasKey("Id"); + + b.ToTable("LeaveTypes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + + b.Property("LeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลาทั้งหมด"); + + b.Property("LeaveDaysUsed") + .HasColumnType("double") + .HasComment("จำนวนวันลาที่ใช้ไป"); + + b.Property("LeaveTypeId") + .HasColumnType("char(36)") + .HasComment("รหัสประเภทการลา"); + + b.Property("LeaveYear") + .HasColumnType("int") + .HasComment("ปีงบประมาณ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("LeaveTypeId"); + + b.ToTable("LeaveBeginnings"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DocumentId") + .HasColumnType("char(36)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveDocuments"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AbsentDayAt") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayGetIn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AbsentDayRegistorDate") + .HasColumnType("datetime(6)"); + + b.Property("AbsentDaySummon") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Amount") + .HasColumnType("double"); + + b.Property("ApproveStep") + .HasColumnType("longtext") + .HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ "); + + b.Property("BirthDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelLeaveWrote") + .HasColumnType("longtext") + .HasComment("เขียนที่ (ขอยกเลิก)"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CommanderPosition") + .HasColumnType("longtext"); + + b.Property("CoupleDayCountryHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayEndDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDayLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayLevelCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayPosition") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CoupleDayStartDateHistory") + .HasColumnType("datetime(6)"); + + b.Property("CoupleDaySumTotalHistory") + .HasColumnType("longtext"); + + b.Property("CoupleDayTotalHistory") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DateAppoint") + .HasColumnType("datetime(6)"); + + b.Property("DateSendLeave") + .HasColumnType("datetime(6)"); + + b.Property("Dear") + .HasColumnType("longtext") + .HasComment("เรียนใคร"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("HajjDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveAddress") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานที่ติดต่อขณะลา"); + + b.Property("LeaveBirthDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveCancelComment") + .HasColumnType("longtext") + .HasComment("เหตุผลในการขอยกเลิก"); + + b.Property("LeaveCancelDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveCancelStatus") + .HasColumnType("longtext") + .HasComment("สถานะของคำขอยกเลิก"); + + b.Property("LeaveComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้บังคับบัญชา"); + + b.Property("LeaveDetail") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รายละเอียดการลา"); + + b.Property("LeaveDirectorComment") + .HasColumnType("longtext") + .HasComment("ความเห็นของผู้อำนวยการสำนัก"); + + b.Property("LeaveDraftDocumentId") + .HasColumnType("char(36)"); + + b.Property("LeaveEndDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีสิ้นสุดลา"); + + b.Property("LeaveGovernmentDate") + .HasColumnType("datetime(6)"); + + b.Property("LeaveLast") + .HasColumnType("datetime(6)"); + + b.Property("LeaveNumber") + .IsRequired() + .HasColumnType("longtext") + .HasComment("หมายเลขที่ติดต่อขณะลา"); + + b.Property("LeaveRange") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันเริ่ม เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveRangeEnd") + .HasColumnType("longtext") + .HasComment("ช่วงของการลาของวันสิ้นสุด เช่น ลาทั้งวัน ครึ่งวันเช้า ครึ่งวันบ่าย"); + + b.Property("LeaveSalary") + .HasColumnType("int"); + + b.Property("LeaveSalaryText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LeaveStartDate") + .HasColumnType("datetime(6)") + .HasComment("วัน เดือน ปีเริ่มต้นลา"); + + b.Property("LeaveStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะของคำร้อง"); + + b.Property("LeaveSubTypeName") + .HasColumnType("longtext"); + + b.Property("LeaveTotal") + .HasColumnType("double"); + + b.Property("LeaveTypeCode") + .HasColumnType("longtext") + .HasComment("code ของประเภทการลา"); + + b.Property("LeaveWrote") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เขียนที่"); + + b.Property("OrdainDayBuddhistLentAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayBuddhistLentName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayLocationNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrdainDayOrdination") + .HasColumnType("datetime(6)"); + + b.Property("OrdainDayStatus") + .HasColumnType("tinyint(1)"); + + b.Property("OrganizationName") + .HasColumnType("longtext") + .HasComment("สังกัดผู้ยื่นขอ"); + + b.Property("PositionLevelName") + .HasColumnType("longtext") + .HasComment("ระดับผู้ยื่นขอ"); + + b.Property("PositionName") + .HasColumnType("longtext") + .HasComment("ตำแหน่งผู้ยื่นขอ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("RestDayCurrentTotal") + .HasColumnType("double"); + + b.Property("RestDayOldTotal") + .HasColumnType("double"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.Property("StudyDayCountry") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayDegreeLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayScholarship") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDaySubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayTrainingSubject") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("StudyDayUniversityName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TypeId") + .HasColumnType("char(36)"); + + b.Property("WifeDayDateBorn") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WifeDayName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("LeaveCancelDocumentId"); + + b.HasIndex("LeaveDraftDocumentId"); + + b.HasIndex("TypeId"); + + b.ToTable("LeaveRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("ApproveStatus") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ApproveType") + .HasColumnType("longtext"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsAct") + .HasColumnType("tinyint(1)"); + + b.Property("KeyId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("KeycloakId") + .HasColumnType("char(36)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("LeaveRequestId") + .HasColumnType("char(36)"); + + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + + b.Property("PositionName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PositionSign") + .HasColumnType("longtext") + .HasComment("ตำแหน่งใต้ลายเช็นต์"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("Seq") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LeaveRequestId"); + + b.ToTable("LeaveRequestApprovers"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckDate") + .HasColumnType("datetime(6)") + .HasComment("*วันที่ลงเวลา"); + + b.Property("CheckInEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงเช้า"); + + b.Property("CheckOutEdit") + .HasColumnType("tinyint(1)") + .HasComment("*ขอลงเวลาช่วงบ่าย"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasColumnType("longtext") + .HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("*หมายเหตุขอลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak ที่ร้องขอ"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Latitude") + .HasColumnType("double"); + + b.Property("Longitude") + .HasColumnType("double"); + + b.Property("POI") + .HasColumnType("longtext"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะการอนุมัติ"); + + b.HasKey("Id"); + + b.ToTable("AdditionalCheckRequests"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext") + .HasComment("คำอธิบาย"); + + b.Property("EndTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงบ่าย"); + + b.Property("EndTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาออกงานช่วงเช้า"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)") + .HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)") + .HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("StartTimeAfternoon") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงบ่าย"); + + b.Property("StartTimeMorning") + .IsRequired() + .HasColumnType("longtext") + .HasComment("เวลาเข้างานช่วงเช้า"); + + b.HasKey("Id"); + + b.ToTable("DutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุด"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("RootDnaId") + .HasColumnType("char(36)") + .HasComment("รหัส Root DNA Id"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้น"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.HasKey("Id"); + + b.ToTable("LeaveProcessJobStatuses"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckInStatus") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะ Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("CheckOutStatus") + .HasColumnType("longtext") + .HasComment("สถานะ Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EditReason") + .HasColumnType("longtext") + .HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ"); + + b.Property("EditStatus") + .HasColumnType("longtext") + .HasComment("สถานะการของลงเวลาพิเศษ"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("ProcessUserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Calendar") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ปฏิทินการทำงานของ ขรก ปกติ หรือ 6 วันต่อสัปดาห์"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.HasKey("Id"); + + b.ToTable("UserCalendars"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("DutyTimeId") + .HasColumnType("char(36)") + .HasComment("รหัสรอบการลงเวลา"); + + b.Property("EffectiveDate") + .HasColumnType("datetime(6)") + .HasComment("วันที่มีผล"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("ทำการประมวลผลแล้วหรือยัง"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProfileId") + .HasColumnType("char(36)") + .HasComment("รหัส Profile ในระบบทะเบียนประวัติ"); + + b.Property("Remark") + .HasColumnType("longtext") + .HasComment("หมายเหตุ"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("DutyTimeId"); + + b.ToTable("UserDutyTimes"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CheckIn") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา เข้างาน"); + + b.Property("CheckInImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-In"); + + b.Property("CheckInLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-In"); + + b.Property("CheckInLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In"); + + b.Property("CheckInLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-In"); + + b.Property("CheckInPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In"); + + b.Property("CheckInRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In"); + + b.Property("CheckOut") + .HasColumnType("datetime(6)") + .HasComment("วัน เวลา ออกงาน"); + + b.Property("CheckOutImageUrl") + .IsRequired() + .HasColumnType("longtext") + .HasComment("รูปถ่ายสถานที่ Check-Out"); + + b.Property("CheckOutLat") + .HasColumnType("double") + .HasComment("พิกัดละติจูด Check-Out"); + + b.Property("CheckOutLocationName") + .HasColumnType("longtext") + .HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out"); + + b.Property("CheckOutLon") + .HasColumnType("double") + .HasComment("พิกัดลองจิจูด Check-Out"); + + b.Property("CheckOutPOI") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out"); + + b.Property("CheckOutRemark") + .HasColumnType("longtext") + .HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out"); + + b.Property("Child1") + .HasColumnType("longtext"); + + b.Property("Child1DnaId") + .HasColumnType("char(36)"); + + b.Property("Child1Id") + .HasColumnType("char(36)"); + + b.Property("Child2") + .HasColumnType("longtext"); + + b.Property("Child2DnaId") + .HasColumnType("char(36)"); + + b.Property("Child2Id") + .HasColumnType("char(36)"); + + b.Property("Child3") + .HasColumnType("longtext"); + + b.Property("Child3DnaId") + .HasColumnType("char(36)"); + + b.Property("Child3Id") + .HasColumnType("char(36)"); + + b.Property("Child4") + .HasColumnType("longtext"); + + b.Property("Child4DnaId") + .HasColumnType("char(36)"); + + b.Property("Child4Id") + .HasColumnType("char(36)"); + + b.Property("CitizenId") + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("FirstName") + .HasColumnType("longtext"); + + b.Property("Gender") + .HasColumnType("longtext"); + + b.Property("IsLocationCheckIn") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In"); + + b.Property("IsLocationCheckOut") + .HasColumnType("tinyint(1)") + .HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out"); + + b.Property("IsProcess") + .HasColumnType("tinyint(1)") + .HasComment("นำไปประมวลผลแล้วหรือยัง"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastName") + .HasColumnType("longtext"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("Prefix") + .HasColumnType("longtext"); + + b.Property("ProfileId") + .HasColumnType("char(36)"); + + b.Property("ProfileType") + .HasColumnType("longtext"); + + b.Property("Root") + .HasColumnType("longtext"); + + b.Property("RootDnaId") + .HasColumnType("char(36)"); + + b.Property("RootId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.ToTable("UserTimeStamps"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType") + .WithMany() + .HasForeignKey("LeaveTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveType"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("LeaveDocument") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument") + .WithMany() + .HasForeignKey("LeaveCancelDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument") + .WithMany() + .HasForeignKey("LeaveDraftDocumentId"); + + b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveCancelDocument"); + + b.Navigation("LeaveDraftDocument"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", "LeaveRequest") + .WithMany("Approvers") + .HasForeignKey("LeaveRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LeaveRequest"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b => + { + b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime") + .WithMany() + .HasForeignKey("DutyTimeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DutyTime"); + }); + + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b => + { + b.Navigation("Approvers"); + + b.Navigation("LeaveDocument"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.cs new file mode 100644 index 00000000..83d313b0 --- /dev/null +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/20260511075931_Add Approver Field.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BMA.EHR.Infrastructure.Migrations.LeaveDb +{ + /// + public partial class AddApproverField : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsAct", + table: "LeaveRequestApprovers", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "KeyId", + table: "LeaveRequestApprovers", + type: "longtext", + nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsAct", + table: "LeaveRequestApprovers"); + + migrationBuilder.DropColumn( + name: "KeyId", + table: "LeaveRequestApprovers"); + } + } +} diff --git a/BMA.EHR.Infrastructure/Migrations/LeaveDb/LeaveDbContextModelSnapshot.cs b/BMA.EHR.Infrastructure/Migrations/LeaveDb/LeaveDbContextModelSnapshot.cs index c0a77c10..99694a78 100644 --- a/BMA.EHR.Infrastructure/Migrations/LeaveDb/LeaveDbContextModelSnapshot.cs +++ b/BMA.EHR.Infrastructure/Migrations/LeaveDb/LeaveDbContextModelSnapshot.cs @@ -128,6 +128,14 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb .HasComment("PrimaryKey") .HasAnnotation("Relational:JsonPropertyName", "id"); + b.Property("BeginningLeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลายกมา"); + + b.Property("BeginningLeaveDays") + .HasColumnType("double") + .HasComment("จำนวนวันลายกมา"); + b.Property("Child1DnaId") .HasColumnType("char(36)"); @@ -184,11 +192,15 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb .HasColumnOrder(102) .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + b.Property("LeaveCount") + .HasColumnType("int") + .HasComment("จำนวนครั้งที่ลาสะสม"); + b.Property("LeaveDays") .HasColumnType("double") - .HasComment("จำนวนวันลายกมา"); + .HasComment("จำนวนวันลาทั้งหมด"); - b.Property("LeaveDaysUsed") + b.Property("LeaveDaysUsed") .HasColumnType("double") .HasComment("จำนวนวันลาที่ใช้ไป"); @@ -416,6 +428,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb b.Property("DateAppoint") .HasColumnType("datetime(6)"); + b.Property("DateSendLeave") + .HasColumnType("datetime(6)"); + b.Property("Dear") .HasColumnType("longtext") .HasComment("เรียนใคร"); @@ -698,6 +713,13 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb .IsRequired() .HasColumnType("longtext"); + b.Property("IsAct") + .HasColumnType("tinyint(1)"); + + b.Property("KeyId") + .IsRequired() + .HasColumnType("longtext"); + b.Property("KeycloakId") .HasColumnType("char(36)"); @@ -727,6 +749,21 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb b.Property("LeaveRequestId") .HasColumnType("char(36)"); + b.Property("OrganizationName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สังกัด"); + + b.Property("PosExecutiveName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ตำแหน่งทางการบริหาร"); + + b.Property("PositionLevelName") + .IsRequired() + .HasColumnType("longtext") + .HasComment("ประเภทระดับตำแหน่ง"); + b.Property("PositionName") .IsRequired() .HasColumnType("longtext"); @@ -867,6 +904,99 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb b.ToTable("AdditionalCheckRequests"); }); + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("AdditionalData") + .HasColumnType("longtext") + .HasComment("ข้อมูลเพิ่มเติม (JSON)"); + + b.Property("CheckInId") + .HasColumnType("char(36)") + .HasComment("CheckInId สำหรับ Check-Out"); + + b.Property("CheckType") + .HasColumnType("longtext") + .HasComment("ประเภทการลงเวลา: CHECK_IN, CHECK_OUT"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("KeycloakUserId") + .HasColumnType("char(36)") + .HasComment("รหัส User ของ Keycloak"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.Property("TaskId") + .HasColumnType("char(36)") + .HasComment("Task ID สำหรับติดตามสถานะงาน"); + + b.HasKey("Id"); + + b.ToTable("CheckInJobStatuses"); + }); + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b => { b.Property("Id") @@ -952,6 +1082,91 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb b.ToTable("DutyTimes"); }); + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)") + .HasColumnOrder(0) + .HasComment("PrimaryKey") + .HasAnnotation("Relational:JsonPropertyName", "id"); + + b.Property("CompletedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(100) + .HasComment("สร้างข้อมูลเมื่อ"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่สร้างงาน"); + + b.Property("CreatedFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(104) + .HasComment("ชื่อ User ที่สร้างข้อมูล"); + + b.Property("CreatedUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(101) + .HasComment("User Id ที่สร้างข้อมูล"); + + b.Property("EndDate") + .HasColumnType("datetime(6)") + .HasComment("วันสิ้นสุด"); + + b.Property("ErrorMessage") + .HasColumnType("longtext") + .HasComment("ข้อความแสดงข้อผิดพลาด"); + + b.Property("LastUpdateFullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)") + .HasColumnOrder(105) + .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdateUserId") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnOrder(103) + .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด"); + + b.Property("LastUpdatedAt") + .HasColumnType("datetime(6)") + .HasColumnOrder(102) + .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); + + b.Property("ProcessingDate") + .HasColumnType("datetime(6)") + .HasComment("วันเวลาที่เริ่มประมวลผล"); + + b.Property("RootDnaId") + .HasColumnType("char(36)") + .HasComment("รหัส Root DNA Id"); + + b.Property("StartDate") + .HasColumnType("datetime(6)") + .HasComment("วันเริ่มต้น"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext") + .HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED"); + + b.HasKey("Id"); + + b.ToTable("LeaveProcessJobStatuses"); + }); + modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b => { b.Property("Id") diff --git a/BMA.EHR.Infrastructure/Persistence/LeaveDbContext.cs b/BMA.EHR.Infrastructure/Persistence/LeaveDbContext.cs index c6d37b7a..10064197 100644 --- a/BMA.EHR.Infrastructure/Persistence/LeaveDbContext.cs +++ b/BMA.EHR.Infrastructure/Persistence/LeaveDbContext.cs @@ -22,6 +22,8 @@ namespace BMA.EHR.Infrastructure.Persistence public DbSet UserCalendars { get; set; } + public DbSet CheckInJobStatuses { get; set; } + #endregion #region " Leave System " @@ -38,6 +40,8 @@ namespace BMA.EHR.Infrastructure.Persistence #endregion + public DbSet LeaveProcessJobStatuses { get; set; } + public LeaveDbContext(DbContextOptions options) : base(options) { diff --git a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs index 80a8ef31..6c0b809f 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaManageController.cs @@ -331,7 +331,7 @@ namespace BMA.EHR.Insignia.Service.Controllers if (req.Total + total > insigniaManage.Total) return Error(GlobalMessages.InsigniaManageOrgLimit); - var ocData = _userProfileRepository.GetOc(req.OrganizationOrganizationId, 0, AccessToken); + var ocData = _userProfileRepository.GetOcByNodeId(req.OrganizationOrganizationId, 0, AccessToken); var root = ocData?.Root ?? null; var rootDnaId = ocData?.RootDnaId ?? null; await _context.InsigniaManageOrganiations.AddAsync( @@ -407,6 +407,10 @@ namespace BMA.EHR.Insignia.Service.Controllers if (uppdated == null) return Error(GlobalMessages.InsigniaManageNotFound); + var ocData = _userProfileRepository.GetOcByNodeId(uppdated.OrganizationId, 0, AccessToken); + var root = ocData?.Root ?? null; + var rootDnaId = ocData?.RootDnaId ?? null; + var insigniaManage = await _context.InsigniaManages.AsQueryable() .Include(x => x.InsigniaManageOrganiations) .FirstOrDefaultAsync(x => x.Id == uppdated.InsigniaManage.Id); @@ -416,6 +420,9 @@ namespace BMA.EHR.Insignia.Service.Controllers if (req.Total + total > insigniaManage.Total) return Error(GlobalMessages.InsigniaManageOrgLimit); + uppdated.Organization = root; + uppdated.RootDnaId = rootDnaId; + uppdated.Total = req.Total; uppdated.LastUpdateFullName = FullName ?? "System Administrator"; uppdated.LastUpdateUserId = UserId ?? ""; @@ -639,7 +646,7 @@ namespace BMA.EHR.Insignia.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -724,11 +731,11 @@ namespace BMA.EHR.Insignia.Service.Controllers rawData = rawData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList(); } - else if (role == "PARENT") - { - rawData = rawData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // rawData = rawData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { rawData = rawData.Where(x => @@ -943,7 +950,7 @@ namespace BMA.EHR.Insignia.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -1026,11 +1033,11 @@ namespace BMA.EHR.Insignia.Service.Controllers rawData = rawData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList(); } - else if (role == "PARENT") - { - rawData = rawData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // rawData = rawData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { rawData = rawData.Where(x => diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 005f9882..415a0de2 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2641,6 +2641,8 @@ namespace BMA.EHR.Insignia.Service.Controllers { if (item.CitizanId == null) continue; var _profile = await _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken); + if (_profile == null) + continue; var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == _profile.Id); if (profile == null) { @@ -3096,7 +3098,7 @@ namespace BMA.EHR.Insignia.Service.Controllers var doc = await _documentService.UploadFileAsync(file, file.FileName); insigniaNoteProfile.DocReturnInsignia = doc; } - var root = _userProfileRepository.GetOc(req.OrgId, 0, AccessToken)?.Root ?? null; + var root = _userProfileRepository.GetOcByNodeId(req.OrgId, 0, AccessToken)?.Root ?? null; if (req.OrgId != Guid.Parse("00000000-0000-0000-0000-000000000000")) { if (root == null) @@ -3146,7 +3148,10 @@ namespace BMA.EHR.Insignia.Service.Controllers var doc = await _documentService.UploadFileAsync(file, file.FileName); insigniaNoteProfile.DocReceiveInsignia = doc; } - var root = _userProfileRepository.GetOc(req.OrgId, 0, AccessToken)?.Root ?? null; + + var orgData = _userProfileRepository.GetOcByNodeId(req.OrgId,0, AccessToken); + var root = orgData?.Root ?? null; + var rootDnaId = orgData?.RootDnaId ?? null; if (req.OrgId != Guid.Parse("00000000-0000-0000-0000-000000000000")) { if (root == null) @@ -3157,6 +3162,7 @@ namespace BMA.EHR.Insignia.Service.Controllers root = "สำนักนายกรัฐมนตรี"; } insigniaNoteProfile.OrgReceiveInsignia = root; + insigniaNoteProfile.RootDnaId = rootDnaId; insigniaNoteProfile.OrgReceiveInsigniaId = req.OrgId; insigniaNoteProfile.DateReceiveInsignia = req.Date; insigniaNoteProfile.LastUpdateFullName = FullName ?? "System Administrator"; diff --git a/BMA.EHR.Insignia/Program.cs b/BMA.EHR.Insignia/Program.cs index a4dd716a..88c1c2ac 100644 --- a/BMA.EHR.Insignia/Program.cs +++ b/BMA.EHR.Insignia/Program.cs @@ -131,7 +131,7 @@ var builder = WebApplication.CreateBuilder(args); { options.ServerName = "Insignia-Server"; // ← ระบุชื่อ server options.WorkerCount = 5; // ← - options.Queues = new[] { "insignia" }; // ← worker จะรันเฉพาะ queue "insignia" + options.Queues = new[] { "insignia","default" }; // ← worker จะรันเฉพาะ queue "insignia" }); diff --git a/BMA.EHR.Insignia/appsettings.json b/BMA.EHR.Insignia/appsettings.json index 3d74b2ae..4e160482 100644 --- a/BMA.EHR.Insignia/appsettings.json +++ b/BMA.EHR.Insignia/appsettings.json @@ -9,8 +9,8 @@ } }, "ElasticConfiguration": { - "Uri": "http://192.168.1.40:9200", - "IndexFormat": "bma-ehr-log-index", + "Uri": "http://192.168.1.63:9200", + "IndexFormat": "hrms-log-index", "SystemName": "insignia" }, "AllowedHosts": "*", @@ -31,10 +31,11 @@ //"DisciplineConnection": "server=hrms.chin.in.th;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=53636;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { - //"Key": "j7C9RO_p4nRtuwCH4z9Db_A_6We42tkD_p4lZtDrezc", - //"Issuer": "https://hrms-id.chin.in.th/realms/hrms" - "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", - "Issuer": "https://id.frappet.synology.me/realms/hrms" + //"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", + "Key": "j7C9RO_p4nRtuwCH4z9Db_A_6We42tkD_p4lZtDrezc", + "Issuer": "https://hrmsbkk-id.case-collection.com/realms/hrms" + //"Key": "xY2VR-EFvvNPsMs39u8ooVBWQL6mPwrNJOh3koJFTgU", + //"Issuer": "https://hrms-id.bangkok.go.th/realms/hrms" }, "EPPlus": { "ExcelPackage": { @@ -55,11 +56,17 @@ "Node": { "API": "https://bma-ehr.frappet.synology.me/api/v1/probation" }, - "API": "https://bma-ehr.frappet.synology.me/api/v1", "RabbitMQ": { "URL": "localhost", "UserName": "frappet", "Password": "FPTadmin2357" }, + "Domain": "https://hrmsbkk.case-collection.com", + "APIPROBATION": "https://hrmsbkk.case-collection.com/api/v1/probation", + "API": "https://hrmsbkk.case-collection.com/api/v1", + "APIV2": "https://hrmsbkk.case-collection.com/api/v2", + "VITE_URL_MGT": "https://hrmsbkk-mgt.case-collection.com", + //"API": "https://bma-ehr.frappet.synology.me/api/v1", + //"API": "https://bma-hrms.bangkok.go.th/api/v1", "API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz" } diff --git a/BMA.EHR.Leave/BMA.EHR.Leave.csproj b/BMA.EHR.Leave/BMA.EHR.Leave.csproj index 83132dd1..28f42590 100644 --- a/BMA.EHR.Leave/BMA.EHR.Leave.csproj +++ b/BMA.EHR.Leave/BMA.EHR.Leave.csproj @@ -45,6 +45,7 @@ + diff --git a/BMA.EHR.Leave/Controllers/LeaveBeginningController.cs b/BMA.EHR.Leave/Controllers/LeaveBeginningController.cs index 4c37f19d..2aa4988f 100644 --- a/BMA.EHR.Leave/Controllers/LeaveBeginningController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveBeginningController.cs @@ -33,6 +33,7 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly IConfiguration _configuration; private readonly UserProfileRepository _userProfileRepository; private readonly PermissionRepository _permission; + private readonly LeaveRequestRepository _leaveRequestRepository; #endregion @@ -44,7 +45,8 @@ namespace BMA.EHR.Leave.Service.Controllers IWebHostEnvironment hostingEnvironment, IConfiguration configuration, UserProfileRepository userProfileRepository, - PermissionRepository permission) + PermissionRepository permission, + LeaveRequestRepository leaveRequestRepository) { _leaveBeginningRepository = leaveBeginningRepository; _context = context; @@ -53,6 +55,7 @@ namespace BMA.EHR.Leave.Service.Controllers _configuration = configuration; _userProfileRepository = userProfileRepository; _permission = permission; + _leaveRequestRepository = leaveRequestRepository; } #endregion @@ -141,7 +144,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -166,11 +169,11 @@ namespace BMA.EHR.Leave.Service.Controllers resData = resData .Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList(); } - else if (role == "PARENT") - { - resData = resData - .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // resData = resData + // .Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { resData = resData @@ -201,6 +204,9 @@ namespace BMA.EHR.Leave.Service.Controllers item.LeaveYear, item.LeaveDays, item.LeaveDaysUsed, + item.LeaveCount, + item.BeginningLeaveDays, + item.BeginningLeaveCount, item.CreatedAt, item.CreatedFullName, item.LastUpdatedAt, @@ -372,6 +378,15 @@ namespace BMA.EHR.Leave.Service.Controllers try { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + // var profileId = ProfileId ?? Guid.Empty; + // var prefix = Prefix ?? ""; + // var firstName = FirstName ?? ""; + // var lastName = LastName ?? ""; + // var rootDnaId = OrgRootDnaId ?? Guid.Empty; + // var child1DnaId = OrgChild1DnaId ?? Guid.Empty; + // var child2DnaId = OrgChild2DnaId ?? Guid.Empty; + // var child3DnaId = OrgChild3DnaId ?? Guid.Empty; + // var child4DnaId = OrgChild4DnaId ?? Guid.Empty; var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_LEAVE_HISTORY"); var jsonData = JsonConvert.DeserializeObject(getPermission); @@ -383,17 +398,41 @@ namespace BMA.EHR.Leave.Service.Controllers if (leaveBeginning == null) return Error("ไม่พบข้อมูลที่ต้องการแก้ไข", StatusCodes.Status404NotFound); - var profile = await _userProfileRepository.GetProfileByProfileIdAsync(req.ProfileId, AccessToken); if (profile == null) { return Error("ไม่พบข้อมูลข้าราชการหรือลูกจ้าง", StatusCodes.Status404NotFound); } + + var startFiscalDate = new DateTime(DateTime.Now.Year - 1, 10, 1); + var endFiscalDate = new DateTime(DateTime.Now.Year, 9, 30); + + + if (req.LeaveDaysUsed is null || req.LeaveCount is null) + { + var systemLeaveDays = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate); + var systemLeaveCount = await _leaveRequestRepository.GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate); + + leaveBeginning.LeaveDaysUsed = req.BeginningLeaveDays + systemLeaveDays; + leaveBeginning.LeaveCount = req.BeginningLeaveCount + systemLeaveCount; + + leaveBeginning.BeginningLeaveDays = req.BeginningLeaveDays; + leaveBeginning.BeginningLeaveCount = req.BeginningLeaveCount; + } + else + { + leaveBeginning.LeaveDaysUsed = req.LeaveDaysUsed; + leaveBeginning.LeaveCount = req.LeaveCount; + leaveBeginning.BeginningLeaveDays = req.BeginningLeaveDays; + leaveBeginning.BeginningLeaveCount = req.BeginningLeaveCount; + //var systemLeaveDays = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(profile.Keycloak ?? Guid.Empty, req.LeaveTypeId, startFiscalDate, endFiscalDate); + //var systemLeaveCount = await _leaveRequestRepository.GetSumApproveLeaveCountByTypeAndRangeForUser2(profile.Keycloak ?? Guid.Empty, req.LeaveTypeId, startFiscalDate, endFiscalDate); + } leaveBeginning.LeaveTypeId = req.LeaveTypeId; leaveBeginning.LeaveYear = req.LeaveYear; leaveBeginning.LeaveDays = req.LeaveDays; - leaveBeginning.LeaveDaysUsed = req.LeaveDaysUsed; + leaveBeginning.ProfileId = req.ProfileId; leaveBeginning.Prefix = profile.Prefix; @@ -434,6 +473,17 @@ namespace BMA.EHR.Leave.Service.Controllers try { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + + // var profileId = ProfileId ?? Guid.Empty; + // var prefix = Prefix ?? ""; + // var firstName = FirstName ?? ""; + // var lastName = LastName ?? ""; + // var rootDnaId = OrgRootDnaId ?? Guid.Empty; + // var child1DnaId = OrgChild1DnaId ?? Guid.Empty; + // var child2DnaId = OrgChild2DnaId ?? Guid.Empty; + // var child3DnaId = OrgChild3DnaId ?? Guid.Empty; + // var child4DnaId = OrgChild4DnaId ?? Guid.Empty; + var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_LEAVE_HISTORY"); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") @@ -458,10 +508,26 @@ namespace BMA.EHR.Leave.Service.Controllers } var leaveBeginning = new LeaveBeginning(); + + if (req.LeaveDaysUsed is null || req.LeaveCount is null) + { + leaveBeginning.LeaveDaysUsed = req.BeginningLeaveDays; + leaveBeginning.LeaveCount = req.BeginningLeaveCount; + leaveBeginning.BeginningLeaveDays = req.BeginningLeaveDays; + leaveBeginning.BeginningLeaveCount = req.BeginningLeaveCount; + } + else + { + leaveBeginning.LeaveDaysUsed = req.LeaveDaysUsed; + leaveBeginning.LeaveCount = req.LeaveCount; + leaveBeginning.BeginningLeaveDays = req.BeginningLeaveDays; + leaveBeginning.BeginningLeaveCount = req.BeginningLeaveCount; + } + leaveBeginning.LeaveTypeId = req.LeaveTypeId; leaveBeginning.LeaveYear = req.LeaveYear; leaveBeginning.LeaveDays = req.LeaveDays; - leaveBeginning.LeaveDaysUsed = req.LeaveDaysUsed; + leaveBeginning.ProfileId = req.ProfileId; leaveBeginning.Prefix = profile.Prefix; @@ -489,6 +555,126 @@ namespace BMA.EHR.Leave.Service.Controllers } } + [HttpPut("schedule")] + [AllowAnonymous] + public async Task> ScheduleUpdateLeaveBeginningAsync([FromBody] ScheduleEditLeaveBeginningDto req) + { + try + { + var profile = await _userProfileRepository.GetProfileByProfileIdNoAuthAsync(req.ProfileId, AccessToken); + if(profile == null) + { + return Error("ไม่พบข้อมูลข้าราชการหรือลูกจ้าง", StatusCodes.Status404NotFound); + } + // check duplicate + var oldData = await _context.LeaveBeginnings.FirstOrDefaultAsync(x => x.ProfileId == req.ProfileId + && x.LeaveTypeId == req.LeaveTypeId + && x.LeaveYear == req.LeaveYear); + + if (oldData is not null) + { + //return Error("ไม่สามารถบันทึกข้อมูล เนื่องจากมีข้อมูลในระบบแล้ว"); + oldData.LeaveTypeId = req.LeaveTypeId; + oldData.LeaveYear = req.LeaveYear; + oldData.LeaveDays = req.LeaveDays; + // oldData.LeaveDaysUsed = req.LeaveDaysUsed; + // oldData.LeaveCount = req.LeaveCount; + // oldData.BeginningLeaveDays = req.BeginningLeaveDays; + // oldData.BeginningLeaveCount = req.BeginningLeaveCount; + + oldData.ProfileId = req.ProfileId; + oldData.Prefix = profile.Prefix; + oldData.FirstName = profile.FirstName; + oldData.LastName = profile.LastName; + oldData.RootDnaId = profile.RootDnaId; + oldData.Child1DnaId = profile.Child1DnaId; + oldData.Child2DnaId = profile.Child2DnaId; + oldData.Child3DnaId = profile.Child3DnaId; + oldData.Child4DnaId = profile.Child4DnaId; + + oldData.LastUpdateUserId = ""; + oldData.LastUpdateFullName = "System"; + oldData.LastUpdatedAt = DateTime.Now; + + await _leaveBeginningRepository.UpdateAsync(oldData); + } + else + { + var leaveBeginning = new LeaveBeginning(); + leaveBeginning.LeaveTypeId = req.LeaveTypeId; + leaveBeginning.LeaveYear = req.LeaveYear; + leaveBeginning.LeaveDays = req.LeaveDays; + leaveBeginning.LeaveDaysUsed = 0; + leaveBeginning.LeaveCount = 0; + leaveBeginning.BeginningLeaveDays = 0; + leaveBeginning.BeginningLeaveCount = 0; + + leaveBeginning.ProfileId = req.ProfileId; + leaveBeginning.Prefix = profile.Prefix; + leaveBeginning.FirstName = profile.FirstName; + leaveBeginning.LastName = profile.LastName; + + leaveBeginning.RootDnaId = profile.RootDnaId; + leaveBeginning.Child1DnaId = profile.Child1DnaId; + leaveBeginning.Child2DnaId = profile.Child2DnaId; + leaveBeginning.Child3DnaId = profile.Child3DnaId; + leaveBeginning.Child4DnaId = profile.Child4DnaId; + + leaveBeginning.CreatedUserId = ""; + leaveBeginning.CreatedFullName = "System"; + leaveBeginning.CreatedAt = DateTime.Now; + + await _leaveBeginningRepository.AddAsync(leaveBeginning); + } + return Success(); + } + catch (Exception ex) + { + return Error(ex); + } + } + + + [HttpPut("schedule/update-dna")] + [AllowAnonymous] + public async Task> ScheduleUpdateDnaAsync([FromBody] List req) + { + try + { + foreach(var item in req) + { + // var profile = await _userProfileRepository.GetProfileByProfileIdNoAuthAsync(item.ProfileId, AccessToken); + // if(profile == null) + // { + // return Error("ไม่พบข้อมูลข้าราชการหรือลูกจ้าง", StatusCodes.Status404NotFound); + // } + // check duplicate + var oldData = await _context.LeaveBeginnings.Where(x => x.ProfileId == item.ProfileId).ToListAsync(); + + foreach(var o in oldData) + { + o.RootDnaId = item.RootDnaId; + o.Child1DnaId = item.Child1DnaId; + o.Child2DnaId = item.Child2DnaId; + o.Child3DnaId = item.Child3DnaId; + o.Child4DnaId = item.Child4DnaId; + + o.LastUpdateUserId = ""; + o.LastUpdateFullName = "System"; + o.LastUpdatedAt = DateTime.Now; + + await _leaveBeginningRepository.UpdateAsync(o); + } + } + + + return Success(); + } + catch (Exception ex) + { + return Error(ex); + } + } #endregion } diff --git a/BMA.EHR.Leave/Controllers/LeaveController.cs b/BMA.EHR.Leave/Controllers/LeaveController.cs index d4edffb2..3b1ec5b7 100644 --- a/BMA.EHR.Leave/Controllers/LeaveController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveController.cs @@ -3,9 +3,12 @@ using BMA.EHR.Application.Repositories.Commands; using BMA.EHR.Application.Repositories.Leaves.LeaveRequests; using BMA.EHR.Application.Repositories.Leaves.TimeAttendants; using BMA.EHR.Application.Repositories.MessageQueue; +using BMA.EHR.Application.Responses.Leaves; using BMA.EHR.Application.Responses.Profiles; using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Leave.TimeAttendants; +using BMA.EHR.Domain.Models.Notifications; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; using BMA.EHR.Leave.Service.DTOs.AdditionalCheck; @@ -30,6 +33,7 @@ using System.Diagnostics; using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using BMA.EHR.Leave.Services; using SearchProfileResultDto = BMA.EHR.Leave.Service.DTOs.ChangeRound.SearchProfileResultDto; namespace BMA.EHR.Leave.Service.Controllers @@ -46,6 +50,7 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly DutyTimeRepository _dutyTimeRepository; private readonly LeaveDbContext _context; + private readonly ApplicationDBContext _appDbContext; private readonly IHttpContextAccessor _httpContextAccessor; private readonly IWebHostEnvironment _hostingEnvironment; private readonly IConfiguration _configuration; @@ -58,6 +63,8 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly LeaveRequestRepository _leaveRequestRepository; private readonly UserCalendarRepository _userCalendarRepository; private readonly PermissionRepository _permission; + private readonly CheckInJobStatusRepository _checkInJobStatusRepository; + private readonly NotificationService _notificationService; private readonly CommandRepository _commandRepository; @@ -71,6 +78,8 @@ namespace BMA.EHR.Leave.Service.Controllers private readonly HttpClient _httpClient; + private readonly LeaveProcessJobStatusRepository _leaveProcessJobStatusRepository; + #endregion #region " Constuctor and Destructor " @@ -92,10 +101,15 @@ namespace BMA.EHR.Leave.Service.Controllers ObjectPool objectPool, PermissionRepository permission, NotificationRepository notificationRepository, - HttpClient httpClient) + CheckInJobStatusRepository checkInJobStatusRepository, + HttpClient httpClient, + ApplicationDBContext appDbContext, + LeaveProcessJobStatusRepository leaveProcessJobStatusRepository, + NotificationService notificationService) { _dutyTimeRepository = dutyTimeRepository; _context = context; + _appDbContext = appDbContext; _httpContextAccessor = httpContextAccessor; _hostingEnvironment = hostingEnvironment; _configuration = configuration; @@ -109,7 +123,9 @@ namespace BMA.EHR.Leave.Service.Controllers _commandRepository = commandRepository; _leaveRequestRepository = leaveRequestRepository; _notificationRepository = notificationRepository; - + _checkInJobStatusRepository = checkInJobStatusRepository; + _leaveProcessJobStatusRepository = leaveProcessJobStatusRepository; + _notificationService = notificationService; _objectPool = objectPool; _permission = permission; @@ -137,7 +153,13 @@ namespace BMA.EHR.Leave.Service.Controllers { get { - if (UserId != null || UserId != "") + // First try to get from claims + var ocIdFromClaims = OrgRootDnaId; + if (ocIdFromClaims.HasValue && ocIdFromClaims.Value != Guid.Empty) + return ocIdFromClaims.Value; + + // Fallback to API call for backward compatibility + if (UserId != null && UserId != "") return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken); else return Guid.Empty; @@ -425,88 +447,75 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> CheckTimeAsync() + public async Task> CheckTimeAsync(CancellationToken cancellationToken = default) { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var data = await _userTimeStampRepository.GetLastRecord(userId); + var profileId = ProfileId ?? Guid.Empty; + + // Get user's last check-in record and profile in parallel + var dataTask = _userTimeStampRepository.GetLastRecord(userId); + //var profileTask = _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); + var defaultRoundTask = _dutyTimeRepository.GetDefaultAsync(); + + await Task.WhenAll(dataTask, defaultRoundTask); + + var data = await dataTask; + //var profile = await profileTask; + var getDefaultRound = await defaultRoundTask; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); - if (profile == null) - { - throw new Exception(GlobalMessages.DataNotFound); - } + // if (profile == null) + // { + // throw new Exception(GlobalMessages.DataNotFound); + // } - var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); if (getDefaultRound == null) { return Error("ไม่พบรอบลงเวลา Default", StatusCodes.Status404NotFound); } - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id); + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profileId); var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); var duty = userRound ?? getDefaultRound; - // TODO : รอดุึงรอบที่ผูกกับ user - //var duty = await _dutyTimeRepository.GetDefaultAsync(); - CheckInResultDto ret; - - if (data == null) - { - ret = new CheckInResultDto - { - StartTimeMorning = duty == null ? "00:00" : duty.StartTimeMorning, - EndTimeMorning = duty == null ? "00:00" : duty.EndTimeMorning, - StartTimeAfternoon = duty == null ? "00:00" : duty.StartTimeAfternoon, - EndTimeAfternoon = duty == null ? "00:00" : duty.EndTimeAfternoon, - Description = duty == null ? "-" : duty.Description, - CheckInTime = null, - CheckInId = null, - }; - } - else + // Determine check-in status and data + DateTime? checkInTime = null; + Guid? checkInId = null; + + if (data != null) { if (data.CheckOut != null) { // fix issue SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 - var cur_date = DateTime.Now.Date; - // ถ้า check-in + check-out ไปแล้ว - if (data.CheckIn.Date == cur_date && data.CheckOut.Value.Date == cur_date) + var currentDate = DateTime.Now.Date; + // ถ้า check-in + check-out ไปแล้วในวันเดียวกัน + if (data.CheckIn.Date == currentDate && data.CheckOut.Value.Date == currentDate) { return Error("คุณได้ทำการลงเวลาเข้าและออกเรียบร้อยแล้ว คุณจะสามารถลงเวลาได้อีกครั้งในวันถัดไป"); } - else - { - ret = new CheckInResultDto - { - StartTimeMorning = duty == null ? "00:00" : duty.StartTimeMorning, - EndTimeMorning = duty == null ? "00:00" : duty.EndTimeMorning, - StartTimeAfternoon = duty == null ? "00:00" : duty.StartTimeAfternoon, - EndTimeAfternoon = duty == null ? "00:00" : duty.EndTimeAfternoon, - Description = duty == null ? "-" : duty.Description, - CheckInTime = null, - CheckInId = null, - }; - } + // ถ้า check-out คนละวัน ให้แสดงว่ายังไม่ได้ check-in วันนี้ } else { - ret = new CheckInResultDto - { - StartTimeMorning = duty == null ? "00:00" : duty.StartTimeMorning, - EndTimeMorning = duty == null ? "00:00" : duty.EndTimeMorning, - StartTimeAfternoon = duty == null ? "00:00" : duty.StartTimeAfternoon, - EndTimeAfternoon = duty == null ? "00:00" : duty.EndTimeAfternoon, - Description = duty == null ? "-" : duty.Description, - CheckInTime = data.CheckIn, - CheckInId = data.Id, - }; + // มี check-in แต่ยังไม่ check-out + checkInTime = data.CheckIn; + checkInId = data.Id; } - - } + // Create response DTO (duty is never null here due to fallback logic) + var ret = new CheckInResultDto + { + StartTimeMorning = duty.StartTimeMorning, + EndTimeMorning = duty.EndTimeMorning, + StartTimeAfternoon = duty.StartTimeAfternoon, + EndTimeAfternoon = duty.EndTimeAfternoon, + Description = duty.Description, + CheckInTime = checkInTime, + CheckInId = checkInId, + }; + return Success(ret); } @@ -527,6 +536,27 @@ namespace BMA.EHR.Leave.Service.Controllers // prepare data and convert request body and send to queue var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var currentDate = DateTime.Now; + + // ตรวจสอบว่ามีงานที่กำลัง pending หรือ processing อยู่หรือไม่ + var existingJobs = await _checkInJobStatusRepository.GetPendingOrProcessingJobsAsync(userId); + if (existingJobs != null && existingJobs.Count > 0) + { + // กรองเฉพาะงานที่เป็นประเภทเดียวกัน (CHECK_IN หรือ CHECK_OUT) + var checkType = data.CheckInId == null ? "CHECK_IN" : "CHECK_OUT"; + var sameTypeJob = existingJobs.FirstOrDefault(j => j.CheckType == checkType); + + if (sameTypeJob != null) + { + + return Error($"มีงาน {checkType} กำลังดำเนินการอยู่", StatusCodes.Status500InternalServerError); + // var timeDiff = (currentDate - sameTypeJob.CreatedDate).TotalMinutes; + // if (timeDiff < 2) + // { + // return Error($"มีงาน {checkType} กำลังดำเนินการอยู่ กรุณารอสักครู่", StatusCodes.Status409Conflict); + // } + } + } + var checkFileBytes = new byte[0]; // fix issue : ระบบลงเวลาปฏิบัติงาน>>รูปภาพไม่แสดงในฝั่งของ Admin #804 @@ -540,11 +570,15 @@ namespace BMA.EHR.Leave.Service.Controllers } } + // add task id for check in queue + string taskId = Guid.NewGuid().ToString(); + var checkData = new CheckTimeDtoRB { UserId = userId, CurrentDate = currentDate, CheckInId = data.CheckInId, + TaskId = Guid.Parse(taskId), Lat = data.Lat, Lon = data.Lon, POI = data.POI, @@ -557,6 +591,8 @@ namespace BMA.EHR.Leave.Service.Controllers }; var channel = _objectPool.Get(); + CheckInJobStatus? jobStatus = null; + try { var queue = _configuration["Rabbit:Queue"] ?? "basic-queue"; @@ -564,12 +600,31 @@ namespace BMA.EHR.Leave.Service.Controllers var serializedObject = JsonConvert.SerializeObject(checkData); var body = Encoding.UTF8.GetBytes(serializedObject); - // add task id for check in queue - string taskId = Guid.NewGuid().ToString(); var properties = channel.CreateBasicProperties(); properties.Persistent = true; - properties.MessageId = userId.ToString("D");// ระบบลงเวลาต้องมีการเช็คสถานะใน rabbitMQ ด้วยว่ามีการรอรันอยู่ไหม ลงเวลาเข้า/ออกงาน #894 + properties.MessageId = taskId; + // บันทึกสถานะงานก่อนส่งไป RabbitMQ + jobStatus = new CheckInJobStatus + { + TaskId = Guid.Parse(taskId), + KeycloakUserId = userId, + CreatedDate = currentDate, + Status = "PENDING", + CheckType = data.CheckInId == null ? "CHECK_IN" : "CHECK_OUT", + CheckInId = data.CheckInId, + AdditionalData = JsonConvert.SerializeObject(new + { + IsLocation = data.IsLocation, + LocationName = data.LocationName, + POI = data.POI, + KeycloakId = userId, + Token = AccessToken, + }) + }; + await _checkInJobStatusRepository.AddAsync(jobStatus); + + // ส่งไป RabbitMQ channel.BasicPublish(exchange: "", routingKey: queue, basicProperties: properties, @@ -577,12 +632,101 @@ namespace BMA.EHR.Leave.Service.Controllers return Success(new { date = currentDate, taskId = taskId, keycloakId = userId }); } + catch (Exception ex) + { + // ถ้าส่งไป queue ไม่สำเร็จ ให้ลบ job status ที่สร้างไว้ออก + if (jobStatus != null) + { + try + { + await _checkInJobStatusRepository.DeleteAsync(jobStatus); + } + catch + { + // Ignore delete error + } + } + return Error($"ไม่สามารถส่งงานไปยัง Queue ได้: {ex.Message}"); + //throw new Exception($"ไม่สามารถส่งงานไปยัง Queue ได้: {ex.Message}"); + } finally { _objectPool.Return(channel); } } + /// + /// ตรวจสอบสถานะงาน check-in ด้วย Task ID + /// + /// Task ID ที่ได้จากการเรียก CheckInAsync + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// ไม่พบข้อมูลงาน + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("job-status/{taskId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetJobStatusAsync(Guid taskId) + { + var jobStatus = await _checkInJobStatusRepository.GetByTaskIdAsync(taskId); + + if (jobStatus == null) + { + return Error("ไม่พบข้อมูลงาน", StatusCodes.Status404NotFound); + } + + var result = new + { + taskId = jobStatus.TaskId, + keycloakUserId = jobStatus.KeycloakUserId, + status = jobStatus.Status, + checkType = jobStatus.CheckType, + checkInId = jobStatus.CheckInId, + createdDate = jobStatus.CreatedDate, + processingDate = jobStatus.ProcessingDate, + completedDate = jobStatus.CompletedDate, + errorMessage = jobStatus.ErrorMessage, + additionalData = jobStatus.AdditionalData != null ? + JsonConvert.DeserializeObject(jobStatus.AdditionalData) : null + }; + + return Success(result); + } + + /// + /// ดึงรายการงานที่ยัง pending หรือ processing ของผู้ใช้ + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("pending-jobs")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetPendingJobsAsync() + { + var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + var jobs = await _checkInJobStatusRepository.GetPendingOrProcessingJobsAsync(userId); + + var result = jobs.Select(job => new + { + taskId = job.TaskId, + status = job.Status, + checkType = job.CheckType, + checkInId = job.CheckInId, + createdDate = job.CreatedDate, + processingDate = job.ProcessingDate + }).ToList(); + + return Success(new { count = result.Count, jobs = result }); + } + [HttpGet("check-status")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -590,61 +734,62 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> CheckInCheckStatus() { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var currentDate = DateTime.Now; - var channel = _objectPool.Get(); + // var currentDate = DateTime.Now; + // var channel = _objectPool.Get(); try { - var _url = _configuration["Rabbit:URL"] ?? ""; - var _queue = _configuration["Rabbit:Queue"] ?? "basic-queue"; + // var _url = _configuration["Rabbit:URL"] ?? ""; + // var _queue = _configuration["Rabbit:Queue"] ?? "basic-queue"; - // Step 1: ตรวจสอบจำนวน message ทั้งหมดในคิว - string queueUrl = $"{_url}{_queue}"; - var queueResponse = await _httpClient.GetAsync(queueUrl); - if (!queueResponse.IsSuccessStatusCode) - { - return Error("Error accessing RabbitMQ API", (int)queueResponse.StatusCode); - } + // // Step 1: ตรวจสอบจำนวน message ทั้งหมดในคิว + // string queueUrl = $"{_url}{_queue}"; + // var queueResponse = await _httpClient.GetAsync(queueUrl); + // if (!queueResponse.IsSuccessStatusCode) + // { + // return Error("Error accessing RabbitMQ API", (int)queueResponse.StatusCode); + // } - var queueContent = await queueResponse.Content.ReadAsStringAsync(); - var queueData = JObject.Parse(queueContent); - int totalMessages = queueData["messages"]?.Value() ?? 0; + // var queueContent = await queueResponse.Content.ReadAsStringAsync(); + // var queueData = JObject.Parse(queueContent); + // int totalMessages = queueData["messages"]?.Value() ?? 0; - // Step 2: วนลูปดึง message ทีละ 100 งาน - int batchSize = 100; - var allMessages = new List(); - int processedMessages = 0; + // // Step 2: วนลูปดึง message ทีละ 100 งาน + // int batchSize = 100; + // var allMessages = new List(); + // int processedMessages = 0; - while (processedMessages < totalMessages) - { - var requestBody = new StringContent( - $"{{\"count\":{batchSize},\"requeue\":true,\"encoding\":\"auto\",\"ackmode\":\"ack_requeue_true\"}}", - Encoding.UTF8, - "application/json" - ); + // while (processedMessages < totalMessages) + // { + // var requestBody = new StringContent( + // $"{{\"count\":{batchSize},\"requeue\":true,\"encoding\":\"auto\",\"ackmode\":\"ack_requeue_true\"}}", + // Encoding.UTF8, + // "application/json" + // ); - string getMessagesUrl = $"{_url}{_queue}/get"; - var response = await _httpClient.PostAsync(getMessagesUrl, requestBody); - if (!response.IsSuccessStatusCode) - { - return StatusCode((int)response.StatusCode, "Error retrieving messages from RabbitMQ."); - } + // string getMessagesUrl = $"{_url}{_queue}/get"; + // var response = await _httpClient.PostAsync(getMessagesUrl, requestBody); + // if (!response.IsSuccessStatusCode) + // { + // return StatusCode((int)response.StatusCode, "Error retrieving messages from RabbitMQ."); + // } - var content = await response.Content.ReadAsStringAsync(); - var messages = JArray.Parse(content); + // var content = await response.Content.ReadAsStringAsync(); + // var messages = JArray.Parse(content); - if (messages.Count == 0) - { - break; - } + // if (messages.Count == 0) + // { + // break; + // } - processedMessages += messages.Count; - allMessages.AddRange(messages.Select(m => m["properties"].ToString())); - } + // processedMessages += messages.Count; + // allMessages.AddRange(messages.Select(m => m["properties"].ToString())); + // } + var jobs = await _checkInJobStatusRepository.GetPendingOrProcessingJobsAsync(userId); // Step 3: ค้นหา taskIds ที่อยู่ใน messages ทั้งหมด - var foundTasks = allMessages.FirstOrDefault(x => x.Contains(userId.ToString("D"))); + //var foundTasks = allMessages.FirstOrDefault(x => x.Contains(userId.ToString("D"))); - return Success(new { keycloakId = userId, InQueue = foundTasks != null }); + return Success(new { keycloakId = userId, InQueue = (jobs != null && jobs.Count > 0) }); } catch (Exception ex) @@ -653,7 +798,7 @@ namespace BMA.EHR.Leave.Service.Controllers } finally { - _objectPool.Return(channel); + //_objectPool.Return(channel); } } @@ -790,160 +935,484 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> ProcessCheckInAsync([FromBody] CheckTimeDtoRB data) { var userId = data.UserId ?? Guid.Empty; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, data.Token); + var taskId = data.TaskId ?? Guid.Empty; - if (profile == null) - return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); - - if (data.CheckInFileName == "no-file") throw new Exception(GlobalMessages.NoFileToUpload); - var currentDate = data.CurrentDate ?? DateTime.Now; - - var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture"; - - var fileName = $"{_bucketName}/{userId}/{currentDate.ToString("dd-MM-yyyy")}/{check_status}/{data.CheckInFileName}"; - using (var ms = new MemoryStream(data.CheckInFileBytes ?? new byte[0])) + try { - await _minIOService.UploadFileAsync(fileName, ms); - } - - var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); - if (defaultRound == null) - { - return Error("ไม่พบรอบการลงเวลาทำงาน Default", StatusCodes.Status404NotFound); - } - - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id); - var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; - var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); - - // TODO : รอดุึงรอบที่ผูกกับ user - var duty = userRound ?? defaultRound; - - // create check in object - if (data.CheckInId == null) - { - // validate duplicate check in - var currentCheckIn = await _userTimeStampRepository.GetTimestampByDateAsync(userId, currentDate); - - if (currentCheckIn != null) + // อัปเดตสถานะเป็น PROCESSING + if (taskId != Guid.Empty) { - return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest); + await _checkInJobStatusRepository.UpdateToProcessingAsync(taskId); } - var checkin = new UserTimeStamp + var profile = await _userProfileRepository.GetProfileByCheckInAsync(userId, data.Token); + + if (profile == null) { - KeycloakUserId = userId, - CheckInLat = data.Lat, - CheckInLon = data.Lon, - IsLocationCheckIn = data.IsLocation, - CheckInLocationName = data.LocationName, - CheckInPOI = data.POI, - CheckInRemark = data.Remark, - CheckInImageUrl = fileName, - CheckIn = currentDate, - Prefix = profile.Prefix, - FirstName = profile.FirstName, - LastName = profile.LastName, - CitizenId = profile.CitizenId, + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "เกิดข้อผิดพลาดจากการเรียก API [GetProfileByCheckInAsync] : ไม่พบข้อมูลผู้ใช้"); + await _notificationService.SendNotificationAsync(data.Token, true, + $"ลงเวลาไม่สำเร็จ \r\nเนื่องจาก ไม่พบข้อมูลผู้ใช้ \r\nกรุณาลองใหม่อีกครั้ง"); + //var staffList = await _userProfileRepository.GetOCStaffAsync(profile) + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } - Root = profile.Root, - Child1 = profile.Child1, - Child2 = profile.Child2, - Child3 = profile.Child3, - Child4 = profile.Child4, + var currentDate = data.CurrentDate ?? DateTime.Now; - RootId = profile.RootId, - Child1Id = profile.Child1Id, - Child2Id = profile.Child2Id, - Child3Id = profile.Child3Id, - Child4Id = profile.Child4Id, - Gender = profile.Gender, - - ProfileId = profile.Id, - ProfileType = profile.ProfileType, - - RootDnaId = profile.RootDnaId, - Child1DnaId = profile.Child1DnaId, - Child2DnaId = profile.Child2DnaId, - Child3DnaId = profile.Child3DnaId, - Child4DnaId = profile.Child4DnaId, - }; - - var startTime = ""; - if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา") + if (data.CheckInFileName == "no-file") { - startTime = "09:30"; + //throw new Exception(GlobalMessages.NoFileToUpload); + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, GlobalMessages.NoFileToUpload); + await _notificationService.SendNotificationAsync(data.Token, true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจาก {GlobalMessages.NoFileToUpload}\r\nกรุณาลองใหม่อีกครั้ง"); + + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจาก {GlobalMessages.NoFileToUpload}", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + + return Error(GlobalMessages.NoFileToUpload, StatusCodes.Status400BadRequest); + } + + // last check-in record + var lastCheckIn = await _userTimeStampRepository.GetLastRecord(userId); + + var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture"; + var check_out_status = "check-out-picture"; + + var fileName = $"{_bucketName}/{userId}/{currentDate.ToString("dd-MM-yyyy")}/{check_status}/{data.CheckInFileName}"; + var fileNameCheckOut = $"{_bucketName}/{userId}/{currentDate.ToString("dd-MM-yyyy")}/{check_out_status}/{data.CheckInFileName}"; + using (var ms = new MemoryStream(data.CheckInFileBytes ?? new byte[0])) + { + try + { + await _minIOService.UploadFileAsync(fileName, ms); + // if (lastCheckIn != null && lastCheckIn.CheckOut == null) + // { + // // ยังไม่เคย check-out มาก่อน หรือ check-out เป็น null ให้ใช้ชื่อไฟล์แบบ check-out + // await _minIOService.UploadFileAsync(fileNameCheckOut, ms); + // } + } + catch (Exception ex) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, $"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}"); + await _notificationService.SendNotificationAsync(data.Token, true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่สามารถอัปโหลดรูปภาพได้ {ex.Message}\r\nกรุณาลองใหม่อีกครั้ง"); + + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่สามารถอัปโหลดรูปภาพได้ {ex.Message}", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + + + return Error($"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}", StatusCodes.Status500InternalServerError); + } + + } + + if (lastCheckIn != null && lastCheckIn.CheckOut == null) + { + using (var ms2 = new MemoryStream(data.CheckInFileBytes ?? new byte[0])) + { + try + { + await _minIOService.UploadFileAsync(fileNameCheckOut, ms2); + // if (lastCheckIn != null && lastCheckIn.CheckOut == null) + // { + // // ยังไม่เคย check-out มาก่อน หรือ check-out เป็น null ให้ใช้ชื่อไฟล์แบบ check-out + // await _minIOService.UploadFileAsync(fileNameCheckOut, ms); + // } + } + catch (Exception ex) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, $"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}"); + await _notificationService.SendNotificationAsync(data.Token, true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่สามารถอัปโหลดรูปภาพได้ {ex.Message}\r\nกรุณาลองใหม่อีกครั้ง"); + + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่สามารถอัปโหลดรูปภาพได้ {ex.Message}", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + + + return Error($"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}", StatusCodes.Status500InternalServerError); + } + + } + } + + + var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (defaultRound == null) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบรอบการลงเวลาทำงาน Default"); + await _notificationService.SendNotificationAsync(data.Token, true, + $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่พบรอบการลงเวลาทำงาน Default\r\nกรุณาลองใหม่อีกครั้ง"); + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบรอบการลงเวลาทำงาน Default", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + return Error("ไม่พบรอบการลงเวลาทำงาน Default", StatusCodes.Status404NotFound); + } + + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id, currentDate); + var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + + // TODO : รอดุึงรอบที่ผูกกับ user + var duty = userRound ?? defaultRound; + + // create check in object + if (data.CheckInId == null) + { + if (lastCheckIn != null && lastCheckIn.CheckOut == null) + { + var checkout = await _userTimeStampRepository.GetByIdAsync(lastCheckIn!.Id); + if(checkout != null) + { + var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date); + var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess!.Id); + var endTime1 = ""; + var startTime1 = ""; + var endTimeMorning1 = ""; + if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา") + { + startTime1 = "13:00"; + endTime1 = "14:30"; + endTimeMorning1 = "12:00"; + } + else if (!data.IsLocation && data.LocationName == "ปฏิบัติงานในจุดบริการด่วนมหานคร") + { + startTime1 = "13:00"; + endTime1 = "18:30"; + endTimeMorning1 = "12:00"; + } + else + { + endTime1 = duty.EndTimeAfternoon; + startTime1 = duty.StartTimeAfternoon; + endTimeMorning1 = duty.EndTimeMorning; + } + + string checkOutStatus = "NORMAL"; + var leaveReq1 = await _leaveRequestRepository.GetLeavePeriodAsync(userId, currentDate.Date); + if (leaveReq1 != null) + { + var leaveRange = leaveReq1.LeaveRangeEnd == null ? "" : leaveReq1.LeaveRangeEnd.ToUpper(); + if (leaveRange == "AFTERNOON" || leaveRange == "ALL") + { + if(DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning1}")) + checkOutStatus = "ABSENT"; + else + checkOutStatus = "NORMAL"; + } + else + { + // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 + var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")); + var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime1}"); + var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning1}"); + + + if(currentDateTime.Date > checkout.CheckIn.Date) + { + // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ + checkOutStatus = "NORMAL"; + } + else + { + // ถ้า check-out เป็นวันเดียวกับ check-in + // ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่ + if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ + { + checkOutStatus = "ABSENT"; + } + else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ + { + checkOutStatus = "NORMAL"; + } + else + { + checkOutStatus = "ABSENT"; + } + } + } + } + else + { + // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 + var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")); + var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime1}"); + var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning1}"); + + + if(currentDateTime.Date > checkout.CheckIn.Date) + { + // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ + checkOutStatus = "NORMAL"; + } + else + { + // ถ้า check-out เป็นวันเดียวกับ check-in + // ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่ + if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ + { + checkOutStatus = "ABSENT"; + } + else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ + { + checkOutStatus = "NORMAL"; + } + else + { + checkOutStatus = "ABSENT"; + } + } + + } + + if (checkout_process != null) + { + checkout_process.CheckOutLat = data.Lat; + checkout_process.CheckOutLon = data.Lon; + checkout_process.IsLocationCheckOut = data.IsLocation; + checkout_process.CheckOutLocationName = data.LocationName; + checkout_process.CheckOutPOI = data.POI; + checkout_process.CheckOutRemark = data.Remark; + checkout_process.CheckOutImageUrl = fileNameCheckOut; + checkout_process.CheckOut = currentDate; + checkout_process.CheckOutStatus = checkOutStatus; + + await _processUserTimeStampRepository.UpdateAsync(checkout_process); + } + } + } + + // validate duplicate check in + var currentCheckIn = await _userTimeStampRepository.GetTimestampByDateAsync(userId, currentDate); + + if (currentCheckIn != null) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว"); + await _notificationService.SendNotificationAsync(data.Token, true,$"ลงเวลาไม่สำเร็จ \r\nเนื่องจากมีการลงเวลาในวันนี้แล้ว\r\nกรุณาลองใหม่อีกครั้ง"); + + // send notification to user + var noti1 = new Notification + { + Body = $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากมีการลงเวลาในวันนี้แล้ว", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + + return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest); + } + + var checkin = new UserTimeStamp + { + KeycloakUserId = userId, + CheckInLat = data.Lat, + CheckInLon = data.Lon, + IsLocationCheckIn = data.IsLocation, + CheckInLocationName = data.LocationName, + CheckInPOI = data.POI, + CheckInRemark = data.Remark, + CheckInImageUrl = fileName, + CheckIn = currentDate, + Prefix = profile.Prefix, + FirstName = profile.FirstName, + LastName = profile.LastName, + CitizenId = profile.CitizenId, + + Root = profile.Root, + Child1 = profile.Child1, + Child2 = profile.Child2, + Child3 = profile.Child3, + Child4 = profile.Child4, + + RootId = profile.RootId, + Child1Id = profile.Child1Id, + Child2Id = profile.Child2Id, + Child3Id = profile.Child3Id, + Child4Id = profile.Child4Id, + Gender = profile.Gender, + + ProfileId = profile.Id, + ProfileType = profile.ProfileType, + + RootDnaId = profile.RootDnaId, + Child1DnaId = profile.Child1DnaId, + Child2DnaId = profile.Child2DnaId, + Child3DnaId = profile.Child3DnaId, + Child4DnaId = profile.Child4DnaId, + }; + + var startTime = ""; + var endTime = ""; + if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา") + { + //startTime = "09:30"; + startTime = "10:30"; + endTime = "12:00"; + } + else if (!data.IsLocation && data.LocationName == "ปฏิบัติงานในจุดบริการด่วนมหานคร") + { + //startTime = "09:30"; + startTime = "10:30"; + endTime = "12:00"; + } + else + { + startTime = duty.StartTimeMorning; + endTime = duty.EndTimeMorning; + } + + string checkInStatus = "NORMAL"; + var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(userId, currentDate.Date); + if (leaveReq != null) + { + var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper(); + if (leaveRange == "MORNING" || leaveRange == "ALL") + checkInStatus = "NORMAL"; + else + { + checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {startTime}") ? + DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? + "ABSENT" : + "LATE" : + "NORMAL"; + } + } + else + { + checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {startTime}") ? + DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? + "ABSENT" : + "LATE" : + "NORMAL"; + } + + + // process - รอทำใน queue + var checkin_process = new ProcessUserTimeStamp + { + KeycloakUserId = userId, + CheckInLat = data.Lat, + CheckInLon = data.Lon, + IsLocationCheckIn = data.IsLocation, + CheckInLocationName = data.LocationName, + CheckInPOI = data.POI, + CheckInRemark = data.Remark, + CheckInImageUrl = fileName, + CheckIn = currentDate, + CheckInStatus = checkInStatus, + Prefix = profile.Prefix, + FirstName = profile.FirstName, + LastName = profile.LastName, + CitizenId = profile.CitizenId, + + Root = profile.Root, + Child1 = profile.Child1, + Child2 = profile.Child2, + Child3 = profile.Child3, + Child4 = profile.Child4, + + RootId = profile.RootId, + Child1Id = profile.Child1Id, + Child2Id = profile.Child2Id, + Child3Id = profile.Child3Id, + Child4Id = profile.Child4Id, + Gender = profile.Gender, + + ProfileId = profile.Id, + ProfileType = profile.ProfileType, + + + RootDnaId = profile.RootDnaId, + Child1DnaId = profile.Child1DnaId, + Child2DnaId = profile.Child2DnaId, + Child3DnaId = profile.Child3DnaId, + Child4DnaId = profile.Child4DnaId, + }; + + await _userTimeStampRepository.AddAsync(checkin); + await _processUserTimeStampRepository.AddAsync(checkin_process); } else - startTime = duty.StartTimeMorning; - - var checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > - DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {startTime}") ? - - DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) > - DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? - "ABSENT" : - "LATE" : - "NORMAL"; - - // process - รอทำใน queue - var checkin_process = new ProcessUserTimeStamp { - KeycloakUserId = userId, - CheckInLat = data.Lat, - CheckInLon = data.Lon, - IsLocationCheckIn = data.IsLocation, - CheckInLocationName = data.LocationName, - CheckInPOI = data.POI, - CheckInRemark = data.Remark, - CheckInImageUrl = fileName, - CheckIn = currentDate, - CheckInStatus = checkInStatus, - Prefix = profile.Prefix, - FirstName = profile.FirstName, - LastName = profile.LastName, - CitizenId = profile.CitizenId, + var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value); + //var currentCheckIn = await _userTimeStampRepository.GetTimestampByDateAsync(userId, currentDate); + + if (checkout == null) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน"); + await _notificationService.SendNotificationAsync(data.Token,true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการลงเวลาทำงาน\r\nกรุณาลองใหม่อีกครั้ง"); - Root = profile.Root, - Child1 = profile.Child1, - Child2 = profile.Child2, - Child3 = profile.Child3, - Child4 = profile.Child4, + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการลงเวลาทำงาน", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); - RootId = profile.RootId, - Child1Id = profile.Child1Id, - Child2Id = profile.Child2Id, - Child3Id = profile.Child3Id, - Child4Id = profile.Child4Id, - Gender = profile.Gender, + return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); + } - ProfileId = profile.Id, - ProfileType = profile.ProfileType, + var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date); + + if (currentCheckInProcess == null) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)"); + await _notificationService.SendNotificationAsync(data.Token, true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)\r\nกรุณาลองใหม่อีกครั้ง"); + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); - RootDnaId = profile.RootDnaId, - Child1DnaId = profile.Child1DnaId, - Child2DnaId = profile.Child2DnaId, - Child3DnaId = profile.Child3DnaId, - Child4DnaId = profile.Child4DnaId, - }; + return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); + } - await _userTimeStampRepository.AddAsync(checkin); - await _processUserTimeStampRepository.AddAsync(checkin_process); - } - else - { + var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id); - - var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value); - - var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date); - - var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id); - - - if (checkout != null) - { + // Update checkout record checkout.CheckOutLat = data.Lat; checkout.CheckOutLon = data.Lon; checkout.IsLocationCheckOut = data.IsLocation; @@ -954,44 +1423,196 @@ namespace BMA.EHR.Leave.Service.Controllers checkout.CheckOut = currentDate; await _userTimeStampRepository.UpdateAsync(checkout); - } - else - { - return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); - } - // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 - var checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < - DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? - // "ABSENT" : - checkout.CheckIn.Date < currentDate.Date ? "NORMAL" : - "ABSENT" : - DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < - DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ? - "ABSENT" : - "NORMAL"; - if (checkout_process != null) - { - checkout_process.CheckOutLat = data.Lat; - checkout_process.CheckOutLon = data.Lon; - checkout_process.IsLocationCheckOut = data.IsLocation; - checkout_process.CheckOutLocationName = data.LocationName; - checkout_process.CheckOutPOI = data.POI; - checkout_process.CheckOutRemark = data.Remark; - checkout_process.CheckOutImageUrl = fileName; - checkout_process.CheckOut = currentDate; - checkout_process.CheckOutStatus = checkOutStatus; + var endTime = ""; + var startTime = ""; + var endTimeMorning = ""; + if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา") + { + startTime = "13:00"; + endTime = "14:30"; + endTimeMorning = "12:00"; + } + else if (!data.IsLocation && data.LocationName == "ปฏิบัติงานในจุดบริการด่วนมหานคร") + { + startTime = "13:00"; + endTime = "18:30"; + endTimeMorning = "12:00"; + } + else + { + endTime = duty.EndTimeAfternoon; + startTime = duty.StartTimeAfternoon; + endTimeMorning = duty.EndTimeMorning; + } + string checkOutStatus = "NORMAL"; + var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(userId, currentDate.Date); + if (leaveReq != null) + { + var leaveRange = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange == "AFTERNOON" || leaveRange == "ALL") + { + if (checkout.CheckIn.Date < currentDate.Date) + { + // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ + checkOutStatus = "NORMAL"; + } + else + { + if(DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}")) + checkOutStatus = "ABSENT"; + else + checkOutStatus = "NORMAL"; + } + + } + else + { + // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 + var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")); + var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}"); + var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}"); - await _processUserTimeStampRepository.UpdateAsync(checkout_process); + + if(currentDateTime.Date > checkout.CheckIn.Date) + { + // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ + checkOutStatus = "NORMAL"; + } + else + { + // ถ้า check-out เป็นวันเดียวกับ check-in + // ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่ + if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ + { + checkOutStatus = "ABSENT"; + } + else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ + { + checkOutStatus = "NORMAL"; + } + else + { + checkOutStatus = "ABSENT"; + } + } + // checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + // DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? + // // "ABSENT" : + // checkout.CheckIn.Date < currentDate.Date ? "NORMAL" : + // DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >= + // DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}") ? + // "NORMAL" : + // "ABSENT" : + // DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + // DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}") ? + // "ABSENT" : + // "NORMAL"; + } + } + else + { + // fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921 + var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")); + var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}"); + var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}"); + + + if(currentDateTime.Date > checkout.CheckIn.Date) + { + // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ + checkOutStatus = "NORMAL"; + } + else + { + // ถ้า check-out เป็นวันเดียวกับ check-in + // ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่ + if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ + { + checkOutStatus = "ABSENT"; + } + else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ + { + checkOutStatus = "NORMAL"; + } + else + { + checkOutStatus = "ABSENT"; + } + } + // checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + // DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ? + // // "ABSENT" : + // checkout.CheckIn.Date < currentDate.Date ? "NORMAL" : + // DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >= + // DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTime}") ? + // "NORMAL" : + // "ABSENT" : + // DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < + // DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}") ? + // "ABSENT" : + // "NORMAL"; + } + + if (checkout_process != null) + { + checkout_process.CheckOutLat = data.Lat; + checkout_process.CheckOutLon = data.Lon; + checkout_process.IsLocationCheckOut = data.IsLocation; + checkout_process.CheckOutLocationName = data.LocationName; + checkout_process.CheckOutPOI = data.POI; + checkout_process.CheckOutRemark = data.Remark; + checkout_process.CheckOutImageUrl = fileName; + checkout_process.CheckOut = currentDate; + checkout_process.CheckOutStatus = checkOutStatus; + + await _processUserTimeStampRepository.UpdateAsync(checkout_process); + } + else + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน"); + await _notificationService.SendNotificationAsync(data.Token,true, $"ลงเวลาไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน\r\nกรุณาลองใหม่อีกครั้ง"); + // send notification to user + var noti1 = new Notification + { + Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน", + ReceiverUserId = profile.Id, + Type = "", + Payload = "", + }; + _appDbContext.Set().Add(noti1); + await _appDbContext.SaveChangesAsync(); + return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); + } } - else + // อัปเดตสถานะเป็น COMPLETED + if (taskId != Guid.Empty) { - return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound); + var additionalData = JsonConvert.SerializeObject(new + { + CheckInType = data.CheckInId == null ? "check-in" : "check-out", + FileName = fileName, + ProcessedDate = currentDate + }); + await _checkInJobStatusRepository.UpdateToCompletedAsync(taskId, additionalData); + await _notificationService.SendNotificationAsync(data.Token, false, + $"ลงเวลาสำเร็จ"); } + var checkInType = data.CheckInId == null ? "check-in" : "check-out"; + return Success(new { user = $"{profile.FirstName} {profile.LastName}", date = currentDate, type = checkInType }); ; + } + catch (Exception ex) + { + // อัปเดตสถานะเป็น FAILED + if (taskId != Guid.Empty) + { + await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, ex.Message); + await _notificationService.SendNotificationAsync(data.Token, true, ex.Message); + } + return Error(ex); } - var checkInType = data.CheckInId == null ? "check-in" : "check-out"; - return Success(new { user = $"{profile.FirstName} {profile.LastName}", date = currentDate, type = checkInType }); ; } /// @@ -1009,7 +1630,7 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> CheckInOldAsync([FromForm] CheckTimeDto data) { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -1174,7 +1795,7 @@ namespace BMA.EHR.Leave.Service.Controllers { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -1200,7 +1821,7 @@ namespace BMA.EHR.Leave.Service.Controllers // var test = await _processUserTimeStampRepository.GetTimeStampHistoryAsync(userId, year); // return Success(test); - var data = (await _processUserTimeStampRepository.GetTimeStampHistoryAsync(userId, year)) + var data = (await _processUserTimeStampRepository.GetTimeStampHistoryAsync2(userId, year)) .Select(d => new CheckInHistoryDto { CheckInId = d.Id, @@ -1214,7 +1835,7 @@ namespace BMA.EHR.Leave.Service.Controllers "LATE" : "NORMAL", CheckInIsLocation = d.IsLocationCheckIn, - CheckInLocationName = d.CheckInLocationName, + CheckInLocationName = d.CheckInLocationName ?? "", CheckOutDate = d.CheckOut == null ? null : d.CheckOut.Value.Date, CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm:ss"), CheckOutLocation = d.CheckOutPOI ?? "", @@ -1229,7 +1850,7 @@ namespace BMA.EHR.Leave.Service.Controllers "NORMAL", CheckOutIsLocation = d.IsLocationCheckOut, - CheckOutLocationName = d.CheckOutLocationName, + CheckOutLocationName = d.CheckOutLocationName ?? "", IsEdit = _processUserTimeStampRepository.IsEditRequest(userId, d.CheckIn.Date) @@ -1304,7 +1925,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "BROHTER") + else if (role == "BROTHER") { nodeId = profileAdmin?.Node == 4 ? profileAdmin?.Child3DnaId @@ -1316,7 +1937,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -1334,7 +1955,7 @@ namespace BMA.EHR.Leave.Service.Controllers ProfileType = d.ProfileType ?? "", CheckInDate = d.CheckIn.Date, - CheckInTime = d.CheckIn.ToString("HH:mm:ss"), + CheckInTime = d.CheckIn.ToString("HH:mm"), CheckInLocation = d.CheckInPOI, CheckInLat = d.CheckInLat, CheckInLon = d.CheckInLon, @@ -1345,7 +1966,7 @@ namespace BMA.EHR.Leave.Service.Controllers CheckInLocationName = d.CheckInLocationName ?? "", CheckOutDate = d.CheckOut?.Date, - CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm:ss"), + CheckOutTime = d.CheckOut == null ? "" : d.CheckOut.Value.ToString("HH:mm"), CheckOutLocation = d.CheckOut == null ? "" : d.CheckOutPOI, CheckOutLat = d.CheckOut == null ? null : d.CheckOutLat, CheckOutLon = d.CheckOut == null ? null : d.CheckOutLon, @@ -1463,7 +2084,7 @@ namespace BMA.EHR.Leave.Service.Controllers } else { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(d.KeycloakUserId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -1625,7 +2246,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -1871,11 +2492,11 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } - var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", req.Page, req.PageSize, role, nodeId, profileAdmin?.Node); + var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", req.Page, req.PageSize, role, nodeId, profileAdmin?.Node, req.SelectedNodeId == null ? null : req.SelectedNodeId.Value.ToString("D"), req.SelectedNode); // Get default round once var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); @@ -1919,7 +2540,16 @@ namespace BMA.EHR.Leave.Service.Controllers FullName = $"{p.Prefix ?? ""}{p.FirstName ?? ""} {p.LastName ?? ""}", StartTimeMorning = duty.StartTimeMorning, LeaveTimeAfterNoon = duty.EndTimeAfternoon, - EffectiveDate = effectiveDate?.EffectiveDate?.Date + EffectiveDate = effectiveDate?.EffectiveDate?.Date, + Prefix = p.Prefix ?? "", + FirstName = p.FirstName ?? "", + LastName = p.LastName ?? "", + RootDnaId = p.RootDnaId, + Child1DnaId = p.Child1DnaId, + Child2DnaId = p.Child2DnaId, + Child3DnaId = p.Child3DnaId, + Child4DnaId = p.Child4DnaId + }; resultSet.Add(res); } @@ -1986,6 +2616,64 @@ namespace BMA.EHR.Leave.Service.Controllers } + [HttpPost("round/multiple")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> CreateChangeRoundMultipleAsync([FromBody] List reqs) + { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_WORK_ROUND_EDIT"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + var currentDate = DateTime.Now.Date; + + List dataList = new List(); + + foreach(var req in reqs) + { + // var profile = await _userProfileRepository.GetProfileByProfileIdAsync(req.ProfileId, AccessToken); + // if (profile == null) + // { + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + // } + + if (req.EffectiveDate.Date < currentDate) + { + continue; // move to next item if effective date is in the past, not return error + // return Error(new Exception($"กำหนดรอบลงเวลาของ {req.FirstName} {req.LastName} ผิดพลาด เนื่องจากวันที่มีผลต้องมากกว่าหรือเท่ากับวันที่ปัจจุบัน({currentDate.ToString("yyyy-MM-dd")})"), StatusCodes.Status400BadRequest); + } + + var old = await _userDutyTimeRepository.GetExist(req.ProfileId, req.EffectiveDate); + + if (old != null) + { + continue; // move to next item if already exist, not return error + //return Error(new Exception($"กำหนดรอบลงเวลาของ {req.FirstName} {req.LastName} ผิดพลาด เนื่องจากมีการกำหนดรอบการทำงานในวันที่นี้ไว้แล้ว"), StatusCodes.Status400BadRequest); + } + + var data = new UserDutyTime + { + ProfileId = req.ProfileId, + DutyTimeId = req.RoundId, + EffectiveDate = req.EffectiveDate, + Remark = req.Remark, + + RootDnaId = req.RootDnaId, + Child1DnaId = req.Child1DnaId, + Child2DnaId = req.Child2DnaId, + Child3DnaId = req.Child3DnaId, + Child4DnaId = req.Child4DnaId, + }; + dataList.Add(data); + } + + await _userDutyTimeRepository.AddRangeAsync(dataList); + return Success(); + } + /// /// LV1_015 - ประวัติการเปลี่ยนรอบการลงเวลา (ADMIN) /// @@ -2126,7 +2814,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -2337,16 +3025,18 @@ namespace BMA.EHR.Leave.Service.Controllers /// เมื่อทำรายการสำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("user/checkout-check")] + [HttpGet("user/checkout-check/{isSeminar}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> CheckoutCheckAsync() + public async Task> CheckoutCheckAsync(string isSeminar = "N") { + // "S" = Seminar, "N" = Normal, "O" = One Stop Service + var time = DateTime.Now; var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -2374,8 +3064,16 @@ namespace BMA.EHR.Leave.Service.Controllers //var endTime = DateTimeOffset.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")}T{duty.EndTimeAfternoon}:00.0000000+07:00").ToLocalTime().DateTime; -  //var endTime = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")}T{duty.EndTimeAfternoon}:00.0000000+07:00"); - var endTime = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}"); + //var endTime = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")}T{duty.EndTimeAfternoon}:00.0000000+07:00"); + var endTime = isSeminar.Trim().ToUpper() == "S" + ? DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} 14:30") + : isSeminar.Trim().ToUpper() == "O" + ? DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} 18:30") + : DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}"); + + var endTimeMorning = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}"); + var endTimeDisplay = endTime; + var status = string.Empty; if(lastCheckIn == null) { @@ -2389,7 +3087,33 @@ namespace BMA.EHR.Leave.Service.Controllers { if (time < endTime) { - status = "ABSENT"; + + //string checkOutStatus = "NORMAL"; + var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(userId, time.Date); + if (leaveReq != null) + { + var leaveRange = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange == "AFTERNOON" || leaveRange == "ALL") + { + if(time < endTimeMorning) + { + status = "ABSENT"; + endTimeDisplay = endTimeMorning; + } + else + { + status = "NORMAL"; + } + } + else + { + status = "ABSENT"; + } + } + else + { + status = "ABSENT"; + } } else { @@ -2404,7 +3128,7 @@ namespace BMA.EHR.Leave.Service.Controllers Status = status, StatusText = status == "ABSENT" ? "ขาดราชการ" : "ปกติ", ServerTime = time, - EndTime = endTime + EndTime = endTimeDisplay }); } @@ -2432,9 +3156,18 @@ namespace BMA.EHR.Leave.Service.Controllers { return Error("ไม่สามารถขอลงเวลากรณีพิเศษในวันที่มากกว่าวันที่ปัจจุบันได้", StatusCodes.Status400BadRequest); } + + var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + + var checkin = await _userTimeStampRepository.GetTimestampByDateAsync(userId, req.CheckDate.Date); + if (checkin != null && checkin.CheckOut == null) + { + return Error("ระบบพบรายการลงเวลาของวันที่ต้องการแก้ไข แต่ยังไม่มีข้อมูลการลงเวลาออก กรุณาลงเวลาออกให้เรียบร้อยก่อนดำเนินการ"); + } + + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -2481,15 +3214,16 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetAdditionalCheckRequestAsync([Required] int year, [Required] int month, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false) + public async Task> GetAdditionalCheckRequestAsync([Required] DateTime startDate, [Required] DateTime endDate, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false,string? status = "") { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN_SPECIAL"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") + var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_CHECKIN_SPECIAL"); + //var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData!.status != 200) { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + return Error(jsonData.message, StatusCodes.Status403Forbidden); } - string role = jsonData["result"]?.ToString(); + //string role = jsonData["result"]?.ToString(); + string role = jsonData.result.privilege; var nodeId = string.Empty; var profileAdmin = new GetUserOCAllDto(); profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken); @@ -2519,13 +3253,91 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } //var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequests(year, month); - var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole(year, month, role, nodeId, profileAdmin?.Node); + var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole2(startDate, endDate, role, nodeId, profileAdmin?.Node, keyword,status); + + // ถ้ามีการรักษาการ + if (jsonData.result.isAct) + { + var posActs = jsonData.result.posMasterActs.Where(x => x.privilege != "EMPTY"); + foreach(var act in posActs) + { + var actRole = act.privilege; + string actNodeId = string.Empty; + int? actNode; + + if (actRole == "NORMAL" || actRole == "CHILD") + { + actNodeId = act.child4DnaId != null ? + act.child4DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child1DnaId != null ? + act.child1DnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "BROTHER") + { + actNodeId = act.child4DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child1DnaId!.Value.ToString("D") : + act.child1DnaId != null ? + act.rootDnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "ROOT" /*|| role == "PARENT"*/) + { + actNodeId = act.rootDnaId!.Value.ToString("D"); + actNode = 0; + } + + var rawDataAct = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole2(startDate, endDate, actRole, actNodeId, profileAdmin?.Node, keyword,status); + if (rawDataAct != null) + { + if (rawData != null) + rawData = rawData.Union(rawDataAct).DistinctBy(x => x.Id).ToList(); + else + rawData = rawDataAct; + } + } + } + var total = rawData.Count; var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); if (getDefaultRound == null) @@ -2535,19 +3347,76 @@ namespace BMA.EHR.Leave.Service.Controllers var result = new List(); - foreach (var data in rawData) + + if (!string.IsNullOrWhiteSpace(sortBy)) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); - if (profile == null) + switch (sortBy.ToUpper()) { - return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + case "FULLNAME": + if (descending == true) + rawData = rawData.OrderByDescending(x => x.Prefix) + .ThenByDescending(x => x.FirstName) + .ThenByDescending(x => x.LastName) + .ToList(); + else + rawData = rawData.OrderBy(x => x.Prefix) + .ThenBy(x => x.FirstName) + .ThenBy(x => x.LastName) + .ToList(); + break; + case "CREATEDAT": + if (descending == true) + rawData = rawData.OrderByDescending(x => x.CreatedAt).ToList(); + else + rawData = rawData.OrderBy(x => x.CreatedAt).ToList(); + break; + case "CHECKDATE": + if (descending == true) + rawData = rawData.OrderByDescending(x => x.CheckDate).ToList(); + else + rawData = rawData.OrderBy(x => x.CheckDate).ToList(); + break; + // case "STARTTIMEMORNING": + // if (descending == true) + // rawData = rawData.OrderByDescending(x => x.StartTimeMorning).ToList(); + // else + // result = result.OrderBy(x => x.StartTimeMorning).ToList(); + // break; + // case "STARTTIMEAFTERNOON": + // if (descending == true) + // result = result.OrderByDescending(x => x.StartTimeAfternoon).ToList(); + // else + // result = result.OrderBy(x => x.StartTimeAfternoon).ToList(); + // break; + case "DESCRIPTION": + if (descending == true) + rawData = rawData.OrderByDescending(x => x.Description).ToList(); + else + rawData = rawData.OrderBy(x => x.Description).ToList(); + break; + default: + rawData = rawData.OrderBy(x => + x.Status.Trim().ToLower() == "pending" ? 1 : + x.Status.Trim().ToLower() == "approve" ? 2 : 3).ToList(); + break; + } + } + + var rawDataPaged = rawData.Skip((page - 1) * pageSize).Take(pageSize) + .ToList(); + + foreach (var data in rawDataPaged) + { + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken); + UserDutyTime? effectiveDate = null; + if (profile != null) + { + effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id); + //return Error($"{data.Id} PF{data.FirstName} {data.LastName} : {GlobalMessages.DataNotFound}", StatusCodes.Status404NotFound); } //var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty); - - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id); var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); - var checkInData = await _userTimeStampRepository.GetTimestampByDateAsync(data.KeycloakUserId, data.CheckDate); var duty = userRound ?? getDefaultRound; @@ -2614,69 +3483,69 @@ namespace BMA.EHR.Leave.Service.Controllers result.Add(resObj); } - if (keyword != "") - { - result = result.Where(x => x.FullName.Contains(keyword)).ToList(); - } - if (string.IsNullOrWhiteSpace(sortBy)) - { - sortBy = "default"; - } - if (!string.IsNullOrWhiteSpace(sortBy)) - { - switch (sortBy.ToUpper()) - { - case "FULLNAME": - if (descending == true) - result = result.OrderByDescending(x => x.Prefix) - .ThenByDescending(x => x.FirstName) - .ThenByDescending(x => x.LastName) - .ToList(); - else - result = result.OrderBy(x => x.Prefix) - .ThenBy(x => x.FirstName) - .ThenBy(x => x.LastName) - .ToList(); - break; - case "CREATEDAT": - if (descending == true) - result = result.OrderByDescending(x => x.CreatedAt).ToList(); - else - result = result.OrderBy(x => x.CreatedAt).ToList(); - break; - case "CHECKDATE": - if (descending == true) - result = result.OrderByDescending(x => x.CheckDate).ToList(); - else - result = result.OrderBy(x => x.CheckDate).ToList(); - break; - case "STARTTIMEMORNING": - if (descending == true) - result = result.OrderByDescending(x => x.StartTimeMorning).ToList(); - else - result = result.OrderBy(x => x.StartTimeMorning).ToList(); - break; - case "STARTTIMEAFTERNOON": - if (descending == true) - result = result.OrderByDescending(x => x.StartTimeAfternoon).ToList(); - else - result = result.OrderBy(x => x.StartTimeAfternoon).ToList(); - break; - case "DESCRIPTION": - if (descending == true) - result = result.OrderByDescending(x => x.Description).ToList(); - else - result = result.OrderBy(x => x.Description).ToList(); - break; - default: - result = result.OrderBy(x => x.StatusSort).ToList(); - break; - } - } - var pageResult = result.Skip((page - 1) * pageSize).Take(pageSize) - .ToList(); + // if (keyword != "") + // { + // result = result.Where(x => x.FullName.Contains(keyword)).ToList(); + // } + // if (string.IsNullOrWhiteSpace(sortBy)) + // { + // sortBy = "default"; + // } + // if (!string.IsNullOrWhiteSpace(sortBy)) + // { + // switch (sortBy.ToUpper()) + // { + // case "FULLNAME": + // if (descending == true) + // result = result.OrderByDescending(x => x.Prefix) + // .ThenByDescending(x => x.FirstName) + // .ThenByDescending(x => x.LastName) + // .ToList(); + // else + // result = result.OrderBy(x => x.Prefix) + // .ThenBy(x => x.FirstName) + // .ThenBy(x => x.LastName) + // .ToList(); + // break; + // case "CREATEDAT": + // if (descending == true) + // result = result.OrderByDescending(x => x.CreatedAt).ToList(); + // else + // result = result.OrderBy(x => x.CreatedAt).ToList(); + // break; + // case "CHECKDATE": + // if (descending == true) + // result = result.OrderByDescending(x => x.CheckDate).ToList(); + // else + // result = result.OrderBy(x => x.CheckDate).ToList(); + // break; + // case "STARTTIMEMORNING": + // if (descending == true) + // result = result.OrderByDescending(x => x.StartTimeMorning).ToList(); + // else + // result = result.OrderBy(x => x.StartTimeMorning).ToList(); + // break; + // case "STARTTIMEAFTERNOON": + // if (descending == true) + // result = result.OrderByDescending(x => x.StartTimeAfternoon).ToList(); + // else + // result = result.OrderBy(x => x.StartTimeAfternoon).ToList(); + // break; + // case "DESCRIPTION": + // if (descending == true) + // result = result.OrderByDescending(x => x.Description).ToList(); + // else + // result = result.OrderBy(x => x.Description).ToList(); + // break; + // default: + // result = result.OrderBy(x => x.StatusSort).ToList(); + // break; + // } + // } + // var pageResult = result.Skip((page - 1) * pageSize).Take(pageSize) + // .ToList(); - return Success(new { data = pageResult, total = result.Count }); + return Success(new { data = result, total = total }); } /// @@ -2717,7 +3586,7 @@ namespace BMA.EHR.Leave.Service.Controllers // change user timestamp var processTimeStamp = await _processUserTimeStampRepository.GetTimestampByDateAsync(requestData.KeycloakUserId, requestData.CheckDate.Date); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(requestData.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(requestData.KeycloakUserId, AccessToken); if (processTimeStamp == null) { @@ -2871,7 +3740,7 @@ namespace BMA.EHR.Leave.Service.Controllers requestData.Comment = req.Reason; await _additionalCheckRequestRepository.UpdateAsync(requestData); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(requestData.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(requestData.KeycloakUserId, AccessToken); var recvId = new List { profile.Id }; await _notificationRepository.PushNotificationsAsync(recvId.ToArray(), "ลงเวลากรณีพิเศษ", "การขอลงเวลากรณีพิเศษของคุณไม่ได้รับการอนุมัติ", "", "", true, false); @@ -2915,7 +3784,7 @@ namespace BMA.EHR.Leave.Service.Controllers } else { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(d.KeycloakUserId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -2945,7 +3814,8 @@ namespace BMA.EHR.Leave.Service.Controllers CheckInPOI = d.CheckInPOI, CheckInLat = d.CheckInLat, CheckInLon = d.CheckInLon, - CheckInImg = $"{imgUrl}/{d.CheckInImageUrl}", + // CheckInImg = $"{imgUrl}/{d.CheckInImageUrl}", + CheckInImg = await _minIOService.ImagesPathByName(d.CheckInImageUrl), CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) > DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ? @@ -2962,7 +3832,7 @@ namespace BMA.EHR.Leave.Service.Controllers CheckOutPOI = d.CheckOut == null ? "" : d.CheckOutPOI, CheckOutLat = d.CheckOut == null ? null : d.CheckOutLat, CheckOutLon = d.CheckOut == null ? null : d.CheckOutLon, - CheckOutImg = d.CheckOut == null ? "" : $"{imgUrl}/{d.CheckOutImageUrl}", + CheckOutImg = d.CheckOut == null ? "" : await _minIOService.ImagesPathByName(d.CheckOutImageUrl), CheckOutStatus = d.CheckOut == null ? null : DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) < @@ -2973,6 +3843,10 @@ namespace BMA.EHR.Leave.Service.Controllers "ABSENT" : "NORMAL", CheckOutDescription = d.CheckOutRemark ?? "", + IsLocationCheckIn = d.IsLocationCheckIn, + IsLocationCheckOut = d.IsLocationCheckOut, + CheckInLocationName = d.CheckInLocationName ?? "", + CheckOutLocationName = d.CheckOutLocationName ?? "" }; return Success(result); @@ -3008,7 +3882,7 @@ namespace BMA.EHR.Leave.Service.Controllers foreach (var data in rawData) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -3037,6 +3911,7 @@ namespace BMA.EHR.Leave.Service.Controllers { resultCheckInDate = checkInData == null ? null : checkInData.CheckIn; resultCheckInTime = checkInData == null ? "00:00" : checkInData.CheckIn.ToString("HH:mm"); + resultCheckInLocation = checkInData == null ? "" : checkInData!.CheckInPOI; } if (data.CheckOutEdit) @@ -3054,6 +3929,7 @@ namespace BMA.EHR.Leave.Service.Controllers resultCheckOutTime = checkInData == null ? "00:00" : checkInData.CheckOut == null ? "00:00" : checkInData.CheckOut.Value.ToString("HH:mm"); + resultCheckOutLocation = checkInData == null ? "" : checkInData!.CheckOutPOI; } @@ -3106,10 +3982,7 @@ namespace BMA.EHR.Leave.Service.Controllers result.Add(resObj); } - if (keyword != "") - { - result = result.Where(x => x.EditReason!.Contains(keyword) || x.CheckInLocation!.Contains(keyword) || x.CheckOutLocation!.Contains(keyword)).ToList(); - } + var pageResult = result.Skip((page - 1) * pageSize).Take(pageSize) .ToList(); @@ -3296,7 +4169,62 @@ namespace BMA.EHR.Leave.Service.Controllers var data = await _processUserTimeStampRepository.GetByIdAsync(id); if (data == null) return Error(GlobalMessages.DataNotFound); + +  //if (data.CheckInStatus == "NORMAL" || data.CheckOutStatus == "NORMAL") + + //var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + // แก้เป็นมาใช้งาน KeycloakUserId แทน + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken); + var defaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (defaultRound == null) + { + return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound); + } + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile!.Id); + var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + var duty = userRound ?? defaultRound; + if (req.CheckInStatus == "NORMAL") + { + if(data.CheckInLocationName == "ไปประชุม / อบรม / สัมมนา") + { + data.CheckIn = DateTime.Parse($"{data.CheckIn.Date.ToString("yyyy-MM-dd")} 10:30"); + } + else if (data.CheckInLocationName == "ปฏิบัติงานในจุดบริการด่วนมหานคร") + { + data.CheckIn = DateTime.Parse($"{data.CheckIn.Date.ToString("yyyy-MM-dd")} 10:30"); + } + else + { + data.CheckIn = DateTime.Parse($"{data.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}"); + } + + } + if (req.CheckOutStatus == "NORMAL" ) + { + var checkOutTime = data.CheckOut != null ? data.CheckOut.Value : data.CheckIn; + var oldCheckOutTime = data.CheckOut != null ? data.CheckOut.Value : DateTime.Now; + var roundCheckOutTime = DateTime.Now; + if(data.CheckOutLocationName == "ไปประชุม / อบรม / สัมมนา") + { + roundCheckOutTime = DateTime.Parse($"{checkOutTime.Date.ToString("yyyy-MM-dd")} 14:30"); + } + else if (data.CheckInLocationName == "ปฏิบัติงานในจุดบริการด่วนมหานคร") + { + roundCheckOutTime = DateTime.Parse($"{checkOutTime.Date.ToString("yyyy-MM-dd")} 18:30"); + } + else + { + roundCheckOutTime = DateTime.Parse($"{checkOutTime.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}"); + } + + if (oldCheckOutTime < roundCheckOutTime) + { + data.CheckOut = roundCheckOutTime; + } + } + data.CheckInStatus = req.CheckInStatus; data.CheckOutStatus = req.CheckOutStatus; data.EditReason = req.Reason; @@ -3324,7 +4252,7 @@ namespace BMA.EHR.Leave.Service.Controllers [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetLeaveSummaryByProfileAsync(Guid id, [FromBody] GetLeaveSummaryDto req) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(id, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(id, AccessToken); var thisYear = DateTime.Now.Year; var startDate = req.StartDate; @@ -3373,6 +4301,182 @@ namespace BMA.EHR.Leave.Service.Controllers }); } + #endregion + + #region " Process - Leave and Absence " + + + /// + /// สร้าง Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("admin/leave-task/process")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> CreateProcessTaskAsync([FromBody] CreateLeaveProcessJobDto req) + { + var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); + if (profile == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + var task = new LeaveProcessJobStatus + { + RootDnaId = profile.RootDnaId ?? Guid.Empty, + CreatedUserId = profile.Keycloak?.ToString("D") ?? "", + CreatedFullName = profile.FirstName + " " + profile.LastName, + CreatedAt = DateTime.Now, + Status = "PENDING", + StartDate = req.StartDate, + EndDate = req.EndDate + }; + + await _leaveProcessJobStatusRepository.AddAsync(task); + + return Success(); + } + + /// + /// แสดงรายการ Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("admin/leave-task/process")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetProcessTaskAsync() + { + var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); + + var tasks = await _leaveProcessJobStatusRepository.GetByUserIdAsync(userId); + + var result = tasks.Select(t => new + { + t.Id, + t.CreatedFullName, + t.CreatedAt, + t.Status, + t.StartDate, + t.EndDate, + t.ProcessingDate, + t.CompletedDate, + t.ErrorMessage + }); + + return Success(result); + } + + + /// + /// แสดงรายการ Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("admin/leave-task/process/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetProcessTaskByIdAsync(Guid id) + { + var task = await _leaveProcessJobStatusRepository.GetByTaskIdAsync(id); + + if (task == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + var result = new + { + task.Id, + task.CreatedFullName, + task.CreatedAt, + task.Status, + task.StartDate, + task.EndDate, + task.ProcessingDate, + task.CompletedDate, + task.ErrorMessage + }; + + return Success(result); + } + + /// + /// ลบ Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpDelete("admin/leave-task/process/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> DeleteProcessTaskByIdAsync(Guid id) + { + var task = await _leaveProcessJobStatusRepository.GetByTaskIdAsync(id); + + if (task == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + await _leaveProcessJobStatusRepository.DeleteAsync(task); + + return Success(); + } + + /// + /// อัปเดต Task สำหรับ Process ข้อมูลวันลาและขาดราชการ (ADMIN) + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPut("admin/leave-task/process/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> UpdateProcessTaskByIdAsync(Guid id,[FromBody] CreateLeaveProcessJobDto req) + { + var task = await _leaveProcessJobStatusRepository.GetByTaskIdAsync(id); + + if (task == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + if(task.Status != "PENDING") + { + return Error("ไม่สามารถแก้ไขได้เนื่องจาก Task อยู่ในสถานะกำลังดำเนินการหรือดำเนินการเสร็จสิ้นแล้ว"); + } + + task.StartDate = req.StartDate; + task.EndDate = req.EndDate; + + await _leaveProcessJobStatusRepository.UpdateAsync(task); + + return Success(); + } + + #endregion #endregion diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index 2c001072..09542e34 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -7,6 +7,7 @@ using BMA.EHR.Application.Responses.Profiles; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Leave.Requests; +using BMA.EHR.Domain.Models.Leave.TimeAttendants; using BMA.EHR.Domain.Shared; using BMA.EHR.Leave.Service.DTOs.Reports; using Microsoft.AspNetCore.Authorization; @@ -137,22 +138,43 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport01(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave9"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; + var lastLeaveRequest = - await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId, - data.Type.Id, data.LeaveStartDate.Date); + await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync2(data.KeycloakUserId, + data.Type.Id, data.CreatedAt); - var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1); - var endFiscalYear = data.LeaveStartDate.Date.AddDays(-1); // นับจากวันที่ยื่นลา - var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear); + var startFiscalYear = (new DateTime(data.LeaveStartDate.Year - 1, 10, 1)).Date; + var endFiscalYear = (data.DateSendLeave ?? data.CreatedAt); + + var thisYear = data.LeaveStartDate.Year; + var toDay = data.LeaveStartDate.Date; + if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31)) + thisYear = thisYear + 1; + var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId); + var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear); + if (leaveData != null) + { + sumLeave += leaveData.BeginningLeaveDays; + } + + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); + return new { template = "leave9", @@ -160,14 +182,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), + posExecutiveName = profile.PosExecutiveName, organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leaveDetail = data.LeaveDetail.ToThaiNumber(), leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -208,13 +249,21 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport02(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave10"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -223,14 +272,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, wifeDayName = data.WifeDayName ?? "", wifeDayDateBorn = data.WifeDayDateBorn == null || data.WifeDayDateBorn == "" ? "" : DateTime.Parse(data.WifeDayDateBorn).ToThaiShortDate().ToThaiNumber(), leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), @@ -238,7 +306,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveTotal = data.LeaveTotal.ToString().ToThaiNumber(), //data.LeaveStartDate.DiffDay(data.LeaveEndDate).ToString().ToThaiNumber(), leaveAddress = data.LeaveAddress.ToThaiNumber(), leaveNumber = data.LeaveNumber.ToThaiNumber(), - + approve = approveResult, leaveStatus = data.LeaveStatus != null && data.LeaveStatus!.ToUpper() == "APPROVE" ? "🗹 อนุญาต ☐ ไม่อนุญาต" @@ -251,7 +319,12 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport03(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave11"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -259,7 +332,7 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1); - var endFiscalYear = data.LeaveStartDate.Date.AddDays(-1); // นับจากวันที่ยื่นลา + var endFiscalYear = data.CreatedAt; var thisYear = data.LeaveStartDate.Year; var toDay = data.LeaveStartDate.Date; @@ -272,10 +345,19 @@ namespace BMA.EHR.Leave.Service.Controllers //var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear); - var sumLeave = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed; + + var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear); + if (leaveData != null) + { + sumLeave += leaveData.BeginningLeaveDays; + } + + //var sumLeave = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed; var leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays; var extendLeave = leaveLimit - 10; - + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -284,14 +366,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, restDayOldTotal = extendLeave.ToString().ToThaiNumber(), restDayCurrentTotal = (10).ToString().ToThaiNumber(), @@ -322,7 +423,12 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport04(LeaveRequest data, bool isHajj = false) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, isHajj ? "leave13": "leave12"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -342,6 +448,9 @@ namespace BMA.EHR.Leave.Service.Controllers { isHajj = true; } + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); if (isHajj == true) { @@ -352,15 +461,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", - + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), hajjDayStatus = data.HajjDayStatus, @@ -388,14 +515,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate().ToThaiNumber(), leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), @@ -425,12 +571,16 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport05(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave14"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); @@ -441,6 +591,9 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -449,14 +602,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, absentDaySummon = data.AbsentDaySummon.ToThaiNumber(), absentDayLocation = data.AbsentDayLocation.ToThaiNumber(), @@ -480,12 +652,16 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport06(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave15"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); @@ -496,6 +672,9 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -504,14 +683,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate().ToThaiNumber(), leavegovernmentDate = data.LeaveGovernmentDate == null ? "" : data.LeaveGovernmentDate.Value.Date.ToThaiShortDate().ToThaiNumber(), @@ -551,18 +749,22 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport07(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + + //var profileLeave = await _userProfileRepository.GetProfileLeaveByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profileLeave == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave16"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - - var profileLeave = await _userProfileRepository.GetProfileLeaveByKeycloakIdAsync(data.KeycloakUserId, AccessToken); - if (profileLeave == null) - { - return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); - } - var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); @@ -573,6 +775,9 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -581,41 +786,60 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, fullnameEng = "", - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), profileType = profile.ProfileType, - birthDate = profileLeave.BirthDate.ToThaiShortDate().ToThaiNumber(), - retireDate = profileLeave.RetireDate.ToThaiShortDate().ToThaiNumber(), - govAge = profileLeave.GovAge.ToThaiNumber(), - age = profileLeave.Age.ToThaiNumber(), - dateAppoint = profileLeave.DateAppoint.ToThaiShortDate().ToThaiNumber(), - dateCurrent = profileLeave.DateCurrent.ToThaiShortDate().ToThaiNumber(), - amount = ((double)profileLeave.Amount).ToNumericText().ToThaiNumber(), - telephoneNumber = profileLeave.TelephoneNumber == null ? "" : profileLeave.TelephoneNumber.ToThaiNumber(), + birthDate = profile.BirthDate.ToThaiShortDate().ToThaiNumber(), + retireDate = profile.RetireDate.ToThaiShortDate().ToThaiNumber(), + govAge = profile.GovAge.ToThaiNumber(), + age = profile.Age.ToThaiNumber(), + dateAppoint = profile.DateAppoint.ToThaiShortDate().ToThaiNumber(), + dateCurrent = profile.DateCurrent.ToThaiShortDate().ToThaiNumber(), + amount = ((double)profile.Amount).ToNumericText().ToThaiNumber(), + telephoneNumber = profile.TelephoneNumber == null ? "" : profile.TelephoneNumber.ToThaiNumber(), - posLevel = profileLeave.PosLevel.ToThaiNumber(), - posType = profileLeave.PosType.ToThaiNumber(), - currentAddress = profileLeave.CurrentAddress.ToThaiNumber(), - oc = profileLeave.Oc.ToThaiNumber(), - root = profileLeave.Root.ToThaiNumber(), - child1 = profileLeave.Child1 == null ? "" : profileLeave.Child1!.ToThaiNumber(), - child2 = profileLeave.Child2 == null ? "" : profileLeave.Child2!.ToThaiNumber(), - child3 = profileLeave.Child3 == null ? "" : profileLeave.Child3!.ToThaiNumber(), - child4 = profileLeave.Child4 == null ? "" : profileLeave.Child4!.ToThaiNumber(), + posLevel = profile.PosLevel.ToThaiNumber(), + posType = profile.PosType.ToThaiNumber(), + currentAddress = profile.CurrentAddress.ToThaiNumber(), + oc = profile.Oc.ToThaiNumber(), + root = profile.Root.ToThaiNumber(), + child1 = profile.Child1 == null ? "" : profile.Child1!.ToThaiNumber(), + child2 = profile.Child2 == null ? "" : profile.Child2!.ToThaiNumber(), + child3 = profile.Child3 == null ? "" : profile.Child3!.ToThaiNumber(), + child4 = profile.Child4 == null ? "" : profile.Child4!.ToThaiNumber(), - positions = profileLeave.Positions.Select(x => new + positions = profile.Positions.Select(x => new { positionName = x.PositionName == null ? "" : x.PositionName.ToThaiNumber(), dateStart = x.DateStart.ToThaiShortDate().ToThaiNumber(), @@ -628,7 +852,7 @@ namespace BMA.EHR.Leave.Service.Controllers orgChild3 = x.OrgChild3 == null ? "" : x.OrgChild3.ToThaiNumber(), orgChild4 = x.OrgChild4 == null ? "" : x.OrgChild4.ToThaiNumber(), }).ToList(), - educations = profileLeave.Educations.Select(x => new + educations = profile.Educations.Select(x => new { educationLevel = x.EducationLevel == null ? "" : x.EducationLevel.ToThaiNumber(), institute = x.Institute == null ? "" : x.Institute.ToThaiNumber(), @@ -650,12 +874,16 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport08(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave17"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); @@ -666,6 +894,9 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -674,14 +905,33 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leaveSalary = data.LeaveSalary == null ? "" : data.LeaveSalary.Value.ToNumericText().ToThaiNumber(), leaveSalaryText = data.LeaveSalaryText.ToThaiNumber(), @@ -713,14 +963,19 @@ namespace BMA.EHR.Leave.Service.Controllers private async Task GetReport09(LeaveRequest data) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); - if (profile == null) - { - return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); - } + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} - var profileLeave = await _userProfileRepository.GetProfileLeaveByKeycloakIdAsync(data.KeycloakUserId, AccessToken); - if (profileLeave == null) + //var profileLeave = await _userProfileRepository.GetProfileLeaveByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profileLeave == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave18"); + if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } @@ -735,6 +990,9 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); var approveResult = await GetApproverData(data.Approvers); return new { @@ -743,40 +1001,59 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.LeaveWrote.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, leaveSubTypeName = data.LeaveSubTypeName != null ? data.LeaveSubTypeName.ToThaiNumber() : "", dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc!.ToThaiNumber() ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), profileType = profile.ProfileType, - birthDate = profileLeave.BirthDate.ToThaiShortDate().ToThaiNumber(), - retireDate = profileLeave.RetireDate.ToThaiShortDate().ToThaiNumber(), - govAge = profileLeave.GovAge.ToThaiNumber(), - age = profileLeave.Age.ToThaiNumber(), - dateAppoint = profileLeave.DateAppoint.ToThaiShortDate().ToThaiNumber(), - dateCurrent = profileLeave.DateCurrent.ToThaiShortDate().ToThaiNumber(), - amount = ((double)profileLeave.Amount).ToNumericText().ToThaiNumber(), - telephoneNumber = profileLeave.TelephoneNumber == null ? "" : profileLeave.TelephoneNumber.ToThaiNumber(), + birthDate = profile.BirthDate.ToThaiShortDate().ToThaiNumber(), + retireDate = profile.RetireDate.ToThaiShortDate().ToThaiNumber(), + govAge = profile.GovAge.ToThaiNumber(), + age = profile.Age.ToThaiNumber(), + dateAppoint = profile.DateAppoint.ToThaiShortDate().ToThaiNumber(), + dateCurrent = profile.DateCurrent.ToThaiShortDate().ToThaiNumber(), + amount = ((double)profile.Amount).ToNumericText().ToThaiNumber(), + telephoneNumber = profile.TelephoneNumber == null ? "" : profile.TelephoneNumber.ToThaiNumber(), - posLevel = profileLeave.PosLevel.ToThaiNumber(), - posType = profileLeave.PosType.ToThaiNumber(), - currentAddress = profileLeave.CurrentAddress.ToThaiNumber(), - oc = profileLeave.Oc.ToThaiNumber(), - root = profileLeave.Root.ToThaiNumber(), - child1 = profileLeave.Child1 == null ? "" : profileLeave.Child1!.ToThaiNumber(), - child2 = profileLeave.Child2 == null ? "" : profileLeave.Child2!.ToThaiNumber(), - child3 = profileLeave.Child3 == null ? "" : profileLeave.Child3!.ToThaiNumber(), - child4 = profileLeave.Child4 == null ? "" : profileLeave.Child4!.ToThaiNumber(), + posLevel = profile.PosLevel.ToThaiNumber(), + posType = profile.PosType.ToThaiNumber(), + currentAddress = profile.CurrentAddress.ToThaiNumber(), + oc = profile.Oc.ToThaiNumber(), + root = profile.Root.ToThaiNumber(), + child1 = profile.Child1 == null ? "" : profile.Child1!.ToThaiNumber(), + child2 = profile.Child2 == null ? "" : profile.Child2!.ToThaiNumber(), + child3 = profile.Child3 == null ? "" : profile.Child3!.ToThaiNumber(), + child4 = profile.Child4 == null ? "" : profile.Child4!.ToThaiNumber(), - positions = profileLeave.Positions.Select(x => new + positions = profile.Positions.Select(x => new { positionName = x.PositionName == null ? "" : x.PositionName.ToThaiNumber(), dateStart = x.DateStart.ToThaiShortDate().ToThaiNumber(), @@ -790,7 +1067,7 @@ namespace BMA.EHR.Leave.Service.Controllers orgChild4 = x.OrgChild4 == null ? "" : x.OrgChild4.ToThaiNumber(), }).ToList(), - educations = profileLeave.Educations.Select(x => new + educations = profile.Educations.Select(x => new { educationLevel = x.EducationLevel == null ? "" : x.EducationLevel.ToThaiNumber(), institute = x.Institute == null ? "" : x.Institute.ToThaiNumber(), @@ -919,12 +1196,16 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken); + //if (profile == null) + //{ + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + //} + var profile = await _userProfileRepository.GetProfileLeaveReportByKeycloakIdAsync(data.KeycloakUserId, AccessToken, "leave9"); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}"; //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); @@ -935,7 +1216,10 @@ namespace BMA.EHR.Leave.Service.Controllers // if (list.Count > 0) // approver = list.First().Name; //} - + var Oc = profile.isCommission == false + ? profile.Oc.ToThaiNumber() + : profile.Oc.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber(); + var approveResult = await GetApproverData(data.Approvers); var result = new { template = "แบบใบขอยกเลิกวันลา", @@ -943,12 +1227,31 @@ namespace BMA.EHR.Leave.Service.Controllers data = new { leaveWrote = data.CancelLeaveWrote!.ToThaiNumber() ?? "", - dateSendLeave = data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + dateSendLeave = data.DateSendLeave != null ? data.DateSendLeave.Value.Date.ToThaiShortDate().ToThaiNumber() : data.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), leaveTypeName = data.Type.Name, fullname = fullName, - positionName = profile!.Position == null ? "-" : profile!.Position.ToThaiNumber(), + position = string.IsNullOrEmpty(profile.Position) ? "-" : profile.Position, + positionName = (!string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? string.IsNullOrEmpty(profile.PosExecutiveName) + ? string.IsNullOrEmpty(profile.Position) + ? "-" + : profile.Position + : profile.PosExecutiveName + : string.IsNullOrEmpty(profile.Position) + ? "-" + : string.IsNullOrEmpty(profile.PositionLeaveName) + ? profile.Position + : $"{profile.Position}{profile.PositionLeaveName}").ToThaiNumber(), positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName.ToThaiNumber(), - organizationName = profile!.Oc ?? "", + posExecutiveName = profile.PosExecutiveName, + organizationName = profile!.Oc!.ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(profile.PositionLeaveName) && + (profile.PositionLeaveName.Contains("อำนวยการ") || profile.PositionLeaveName.Contains("บริหาร")) + ? new[] { Oc } + : !string.IsNullOrEmpty(profile.PosExecutiveName) + ? new[] { profile.PosExecutiveName.ToThaiNumber(), Oc } + : new[] { Oc }, leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(), leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(), dear = data.CommanderPosition == null ? data.Dear : data.CommanderPosition.ToThaiNumber(), @@ -956,6 +1259,22 @@ namespace BMA.EHR.Leave.Service.Controllers profileType = data.ProfileType, leaveReasonDelete = data.LeaveCancelComment == null ? "" : data.LeaveCancelComment!.ToThaiNumber(), leaveDetail = data.LeaveDetail.ToThaiNumber(), + + Type1 = profile.ProfileType == "OFFICER" ? "🗹" : "☐", + Type2 = profile.ProfileType != "OFFICER" ? "🗹" : "☐", + Type3 = "☐", + approve = approveResult, + approverComment = !string.IsNullOrEmpty(data.LeaveDirectorComment) + ? data.LeaveDirectorComment.Replace("\r", "").Replace("\n", "").Trim().ToThaiNumber() + : "......................", + approverUpdatedAt = data.LastUpdatedAt.HasValue + ? data.LastUpdatedAt.Value.ToThaiShortDate().ToThaiNumber() + : "...... /...... /......", + leaveStatus = data.LeaveCancelStatus != null && data.LeaveCancelStatus!.ToUpper() == "APPROVE" + ? "🗹 อนุญาต ☐ ไม่อนุญาต" + : data.LeaveCancelStatus != null && data.LeaveCancelStatus!.ToUpper() == "REJECT" + ? "☐ อนุญาต 🗹 ไม่อนุญาต" + : "☐ อนุญาต ☐ ไม่อนุญาต" } }; @@ -1022,18 +1341,18 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } if (type.Trim().ToUpper() == "OFFICER") { - profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetProfileByAdminRolev4(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } else { - profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } // get leave day var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate); @@ -1058,6 +1377,7 @@ namespace BMA.EHR.Leave.Service.Controllers FirstName = x.FirstName ?? "", LastName = x.LastName ?? "", DateStart = x.DateStart ?? x.DateAppoint, + DateAppoint = x.DateAppoint, }).Distinct().ToList(); var beginningData = await _leaveBeginningRepository.GetAllByYearAsync(year); @@ -1086,57 +1406,57 @@ namespace BMA.EHR.Leave.Service.Controllers var sickDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-001"); var sickDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-001"); var sickDayCount = sickDaySum != null ? sickDaySum.LeaveDaysUsed : 0; - var sickCount = sickDay != null ? sickDay.CountLeaveDay : 0; + var sickCount = sickDaySum != null ? sickDaySum.LeaveCount : 0; var personalDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-002"); var personalDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-002"); var personalDayCount = personalDaySum != null ? personalDaySum.LeaveDaysUsed : 0; - var personalCount = personalDay != null ? personalDay.CountLeaveDay : 0; + var personalCount = personalDaySum != null ? personalDaySum.LeaveCount : 0; var maternityDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-003"); var maternityDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-003"); var maternityDayCount = maternityDaySum != null ? maternityDaySum.LeaveDaysUsed : 0; - var maternityCount = maternityDay != null ? maternityDay.CountLeaveDay : 0; + var maternityCount = maternityDaySum != null ? maternityDaySum.LeaveCount : 0; var wifeDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-004"); var wifeDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-004"); var wifeDayCount = wifeDaySum != null ? wifeDaySum.LeaveDaysUsed : 0; - var wifeCount = wifeDay != null ? wifeDay.CountLeaveDay : 0; + var wifeCount = wifeDaySum != null ? wifeDaySum.LeaveCount : 0; var restDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-005"); var restDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-005"); var restDayCount = restDaySum != null ? restDaySum.LeaveDaysUsed : 0; - var restCount = restDay != null ? restDay.CountLeaveDay : 0; + var restCount = restDaySum != null ? restDaySum.LeaveCount : 0; var ordainDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-006"); var ordainDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-006"); var ordainDayCount = ordainDaySum != null ? ordainDaySum.LeaveDaysUsed : 0; - var ordainCount = ordainDay != null ? ordainDay.CountLeaveDay : 0; + var ordainCount = ordainDaySum != null ? ordainDaySum.LeaveCount : 0; var absentDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-007"); var absentDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-007"); var absentDayCount = absentDaySum != null ? absentDaySum.LeaveDaysUsed : 0; - var absentCount = absentDay != null ? absentDay.CountLeaveDay : 0; + var absentCount = absentDaySum != null ? absentDaySum.LeaveCount : 0; var studyDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-008"); var studyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-008"); var studyDayCount = studyDaySum != null ? studyDaySum.LeaveDaysUsed : 0; - var studyCount = studyDay != null ? studyDay.CountLeaveDay : 0; + var studyCount = studyDaySum != null ? studyDaySum.LeaveCount : 0; var agencyDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-009"); var agencyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-009"); var agencyDayCount = agencyDaySum != null ? agencyDaySum.LeaveDaysUsed : 0; - var agencyCount = agencyDay != null ? agencyDay.CountLeaveDay : 0; + var agencyCount = agencyDaySum != null ? agencyDaySum.LeaveCount : 0; var coupleDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-010"); var coupleDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-010"); var coupleDayCount = coupleDaySum != null ? coupleDaySum.LeaveDaysUsed : 0; - var coupleCount = coupleDay != null ? coupleDay.CountLeaveDay : 0; + var coupleCount = coupleDaySum != null ? coupleDaySum.LeaveCount : 0; var therapyDaySum = beginningData.FirstOrDefault(x => x.ProfileId == p.Id && x.LeaveType.Code == "LV-011"); var therapyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-011"); var therapyDayCount = therapyDaySum != null ? therapyDaySum.LeaveDaysUsed : 0; - var therapyCount = therapyDay != null ? therapyDay.CountLeaveDay : 0; + var therapyCount = therapyDaySum != null ? therapyDaySum.LeaveCount : 0; var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty, req.StartDate, req.EndDate); @@ -1213,17 +1533,21 @@ namespace BMA.EHR.Leave.Service.Controllers coupleCount = coupleCount, therapyCount = therapyCount, - leaveTotal = sickCount + - maternityCount + - wifeCount + - personalCount + - restCount + - ordainCount + - absentCount + - studyCount + - agencyCount + - coupleCount + - therapyCount + // ระบบนับจำนวนครั้ง วันลาพักผ่อนด้วย ซึ่งตามระเบียบไม่ให้นับจำนวนครั้งวันลาพักผ่อนครับ จำนวนครั้งนับเฉพาะ ป่วย กับ กิจ + leaveTotal = sickCount + + personalCount + + // leaveTotal = sickCount + + // maternityCount + + // wifeCount + + // personalCount + + // restCount + + // ordainCount + + // absentCount + + // studyCount + + // agencyCount + + // coupleCount + + // therapyCount }; @@ -1651,18 +1975,18 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } if (type.Trim().ToUpper() == "OFFICER") { - profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetProfileByAdminRolev4(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } else { - profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } var date = req.StartDate.Date; @@ -1752,7 +2076,8 @@ namespace BMA.EHR.Leave.Service.Controllers // return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound); //} - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id); + // ให้ใช้วันที่จาก loop date แทน + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date); var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); @@ -1771,20 +2096,68 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-005": remarkStr += leaveReq.Type.Name; var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper(); - if (leaveRange == "MORNING") - remarkStr += "ครึ่งวันเช้า"; - else if (leaveRange == "AFTERNOON") - remarkStr += "ครึ่งวันบ่าย"; - - var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); - if(leaveRange != leaveRangeEnd) + if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date) { - if (leaveRangeEnd == "MORNING") - remarkStr += " - ครึ่งวันเช้า"; - else if (leaveRangeEnd == "AFTERNOON") - remarkStr += " - ครึ่งวันบ่าย"; - } + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + + + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRangeEnd == "MORNING") + // remarkStr += "ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += "ครึ่งวันบ่าย"; + + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange != leaveRangeEnd) + { + if (leaveRangeEnd == "MORNING") + remarkStr += " - ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += " - ครึ่งวันบ่าย"; + } + } + else + { + if(dd.date == leaveReq.LeaveStartDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else if(dd.date == leaveReq.LeaveEndDate.Date) + { + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRangeEnd == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else + { + remarkStr += "เต็มวัน"; + } + } + + + // if (leaveRange == "MORNING") + // remarkStr += "ครึ่งวันเช้า"; + // else if (leaveRange == "AFTERNOON") + // remarkStr += "ครึ่งวันบ่าย"; + + + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRange != leaveRangeEnd) + // { + // if (leaveRangeEnd == "MORNING") + // remarkStr += " - ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += " - ครึ่งวันบ่าย"; + // } break; default: remarkStr += leaveReq.Type.Name; @@ -1992,18 +2365,18 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } if (type.Trim().ToUpper() == "OFFICER") { - profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetProfileByAdminRolev4(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } else { - profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId); + profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date); } // Child กรองตามที่ fe ส่งมาอีกชั้น if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT" || role == "BROTHER") /*&& req.node > profileAdmin?.Node*/) @@ -2082,7 +2455,7 @@ namespace BMA.EHR.Leave.Service.Controllers var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id); + var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id, dd.date); var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); @@ -2101,26 +2474,72 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-005": remarkStr += leaveReq.Type.Name; var leaveRange = leaveReq.LeaveRange == null ? "" : leaveReq.LeaveRange.ToUpper(); - if (leaveRange == "MORNING") - remarkStr += "ครึ่งวันเช้า"; - else if (leaveRange == "AFTERNOON") - remarkStr += "ครึ่งวันบ่าย"; + if(leaveReq.LeaveStartDate.Date == leaveReq.LeaveEndDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; - // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); - // if (leaveRangeEnd == "MORNING") + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRangeEnd == "MORNING") + // remarkStr += "ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += "ครึ่งวันบ่าย"; + + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRange != leaveRangeEnd) + { + if (leaveRangeEnd == "MORNING") + remarkStr += " - ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += " - ครึ่งวันบ่าย"; + } + } + else + { + if(dd.date == leaveReq.LeaveStartDate.Date) + { + if (leaveRange == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRange == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else if(dd.date == leaveReq.LeaveEndDate.Date) + { + var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + if (leaveRangeEnd == "MORNING") + remarkStr += "ครึ่งวันเช้า"; + else if (leaveRangeEnd == "AFTERNOON") + remarkStr += "ครึ่งวันบ่าย"; + } + else + { + remarkStr += "เต็มวัน"; + } + } + + // if (leaveRange == "MORNING") // remarkStr += "ครึ่งวันเช้า"; - // else if (leaveRangeEnd == "AFTERNOON") + // else if (leaveRange == "AFTERNOON") // remarkStr += "ครึ่งวันบ่าย"; - var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); - if(leaveRange != leaveRangeEnd) - { - if (leaveRangeEnd == "MORNING") - remarkStr += " - ครึ่งวันเช้า"; - else if (leaveRangeEnd == "AFTERNOON") - remarkStr += " - ครึ่งวันบ่าย"; - } + + // // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // // if (leaveRangeEnd == "MORNING") + // // remarkStr += "ครึ่งวันเช้า"; + // // else if (leaveRangeEnd == "AFTERNOON") + // // remarkStr += "ครึ่งวันบ่าย"; + + // var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); + // if (leaveRange != leaveRangeEnd) + // { + // if (leaveRangeEnd == "MORNING") + // remarkStr += " - ครึ่งวันเช้า"; + // else if (leaveRangeEnd == "AFTERNOON") + // remarkStr += " - ครึ่งวันบ่าย"; + // } break; default: remarkStr += leaveReq.Type.Name; @@ -2233,7 +2652,12 @@ namespace BMA.EHR.Leave.Service.Controllers } } //employees = employees.OrderBy(x => x.checkInDate).ThenBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList(); - employees = employees.OrderBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList(); + employees = employees + .OrderBy(x => x.checkInTime.Trim() != "" ? 0 : 1) // เรียงตามวันที่ลงเวลา + .ThenBy(x => x.remark.Trim() == "" ? 0 : 1) // ข้อมูลที่ไม่มี remark ให้ขึ้นก่อน + .ThenBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue) + .ThenBy(x => x.remark) // จากนั้นจัดเรียงตาม remark + .ToList(); for (int i = 0; i < employees.Count; i++) { employees[i].no = i + 1; @@ -2241,7 +2665,7 @@ namespace BMA.EHR.Leave.Service.Controllers var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate()}"; var org = _userProfileRepository.GetOc(Guid.Parse(req.nodeId), req.node, AccessToken); - var organizationName = $"{(!string.IsNullOrEmpty(org.Child4) ? org.Child4 + "/" : "")}{(!string.IsNullOrEmpty(org.Child3) ? org.Child3 + "/" : "")}{(!string.IsNullOrEmpty(org.Child2) ? org.Child2 + "/" : "")}{(!string.IsNullOrEmpty(org.Child1) ? org.Child1 + "/" : "")}{org.Root ?? ""}"; + var organizationName = org == null ? "" : $"{(!string.IsNullOrEmpty(org.Child4) ? org.Child4 + "/" : "")}{(!string.IsNullOrEmpty(org.Child3) ? org.Child3 + "/" : "")}{(!string.IsNullOrEmpty(org.Child2) ? org.Child2 + "/" : "")}{(!string.IsNullOrEmpty(org.Child1) ? org.Child1 + "/" : "")}{org.Root ?? ""}"; var dateTimeStamp = $"ประจำ ณ วัน{req.StartDate.Date.GetThaiDayOfWeek()} ที่ {req.StartDate.Date.ToThaiShortDate()}{enddate}"; var templatePath = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", "TimeStampRecords.xlsx"); @@ -2432,29 +2856,45 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } + var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync(); + if (getDefaultRound == null) + { + return Error("ไม่พบรอบลงเวลา Default", StatusCodes.Status404NotFound); + } var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), role, nodeId, profileAdmin.Node, req.nodeId, req.node, req.StartDate, req.EndDate); foreach (var p in userTimeStamps) { var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; - var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id); + UserDutyTime? effectiveDate = null; + + effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.ProfileId ?? Guid.Empty); + //return Error($"{data.Id} PF{data.FirstName} {data.LastName} : {GlobalMessages.DataNotFound}", StatusCodes.Status404NotFound); + + //var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty); var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); - var duty = userRound; - if (duty == null) - { - duty = await _dutyTimeRepository.GetDefaultAsync(); - if (duty == null) - { - return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound); - } - } + var duty = userRound ?? getDefaultRound; + + // var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id); + // var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty; + // var userRound = await _dutyTimeRepository.GetByIdAsync(roundId); + + // var duty = userRound; + // if (duty == null) + // { + // duty = await _dutyTimeRepository.GetDefaultAsync(); + // if (duty == null) + // { + // return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound); + // } + // } DateTime? checkIn = p.CheckIn; DateTime? checkOut = p.CheckOut ?? null; var emp = new @@ -2553,13 +2993,21 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByRootAndRange(req.StartDate, req.EndDate, type, jsonData["result"]?.ToString(), nodeId, profileAdmin?.Node, req.nodeId, req.node); var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}"; + + // var thisYear = req.StartDate.Year; + // var toDay = req.StartDate.Date; + // if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31)) + // thisYear = thisYear + 1; + + // var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, type, data.KeycloakUserId); + var result = new { template = "leave2", @@ -2584,11 +3032,12 @@ namespace BMA.EHR.Leave.Service.Controllers { var _default = new { - fullName = "......................", - positionName = "......................", - positionSign = "......................", - updatedAt = "...... /...... /......", - comment = "......................", + fullName = "............................................", + positionName = "............................................", + posExOrg = Array.Empty(), + positionSign = "............................................", + updatedAt = "............/............/............", + comment = "......................................................................................................................................................................", approveType = "" }; @@ -2596,38 +3045,61 @@ namespace BMA.EHR.Leave.Service.Controllers .Select(x => new { fullName = $"{(x.Prefix ?? "")}{(x.FirstName ?? "")} {(x.LastName ?? "")}".Trim(), - positionName = x.PositionName ?? "......................", - positionSign = x.PositionSign ?? "......................", + positionName = (!string.IsNullOrEmpty(x.PositionLevelName) && + (x.PositionLevelName.Contains("อำนวยการ") || x.PositionLevelName.Contains("บริหาร")) + ? string.IsNullOrEmpty(x.PosExecutiveName) + ? string.IsNullOrEmpty(x.PositionName) + ? "............................................" + : x.PositionName + : x.PosExecutiveName + : string.IsNullOrEmpty(x.PositionName) + ? "............................................" + : string.IsNullOrEmpty(x.PositionLevelName) + ? x.PositionName + : $"{x.PositionName}{x.PositionLevelName}").ToThaiNumber(), + posExOrg = !string.IsNullOrEmpty(x.PositionLevelName) && + (x.PositionLevelName.Contains("อำนวยการ") || x.PositionLevelName.Contains("บริหาร")) + ? new[] { (x!.OrganizationName.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.")).ToThaiNumber() } + : !string.IsNullOrEmpty(x.PosExecutiveName) + ? new[] { x.PosExecutiveName.ToThaiNumber(), x!.OrganizationName.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber() } + : new[] { x!.OrganizationName.Replace("สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", "สำนักงาน ก.ก.").ToThaiNumber() }, + positionSign = !string.IsNullOrEmpty(x.PositionSign) + ? x.PositionSign.Replace("\r", "").Replace("\n", " ").ToThaiNumber() + : "............................................", updatedAt = x.LastUpdatedAt.HasValue ? x.LastUpdatedAt.Value.Date.ToThaiShortDate().ToThaiNumber() - : "...... /...... /......", - comment = (x.Comment ?? "") - .Replace("\r", "") - .Replace("\n", "") - .Trim(), + : "............/............/............", + comment = !string.IsNullOrEmpty(x.Comment) + ? (x.Comment.Replace("\r", "").Replace("\n", " ").Trim()).ToThaiNumber() + : "......................................................................................................................................................................", approveType = (x.ApproveType ?? "").Trim().ToUpper() }) .ToList(); + // การเจ้าหน้าที่ var sender = approvers .FirstOrDefault(x => x.approveType == "SENDER") ?? _default; - var approver = approvers - .FirstOrDefault(x => x.approveType == "APPROVER") - ?? _default; - + // ผู้บังคับบัญชา (มีได้มากกว่า 1 คน) var commanders = approvers .Where(x => x.approveType == "COMMANDER") .DefaultIfEmpty(_default) .ToList(); + // ผู้มีอำนาจ + var approver = approvers + .FirstOrDefault(x => x.approveType == "APPROVER") + ?? _default; + return new { + sign = "............................................", sender = sender, approver = approver, commanders = commanders }; + } } diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 09addc23..8dee308e 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NodaTime; using Org.BouncyCastle.Asn1.Pkcs; using Sentry; using Swashbuckle.AspNetCore.Annotations; @@ -160,10 +161,23 @@ namespace BMA.EHR.Leave.Service.Controllers LastName = r.LastName, PositionName = r.PositionName, PositionSign = r.PositionSign, + PosExecutiveName = r.PosExecutiveName, + PositionLevelName = r.PositionLeaveName, + OrganizationName = r.OrganizationName, ProfileId = r.ProfileId, KeycloakId = r.KeycloakId, ApproveStatus = "PENDING", - ApproveType = type.Trim().ToUpper() + ApproveType = type.Trim().ToUpper(), + + CreatedFullName = FullName ?? "", + CreatedUserId = UserId!, + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "", + LastUpdateUserId = UserId!, + LastUpdatedAt = DateTime.Now, + + IsAct = r.isAct, + KeyId = r.keyId }); } @@ -202,7 +216,8 @@ namespace BMA.EHR.Leave.Service.Controllers var thisYear = DateTime.Now.Year; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { @@ -367,11 +382,15 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-008": { - var lastSalary = profile.ProfileSalary; - var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; - var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); - leaveRequest.LeaveSalary = (int)lastSalaryAmount; - leaveRequest.LeaveSalaryText = lastSalaryAmountText; + // var lastSalary = profile.ProfileSalary; + // var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + // var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + // leaveRequest.LeaveSalary = (int)lastSalaryAmount; + // leaveRequest.LeaveSalaryText = lastSalaryAmountText; + leaveRequest.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0; + leaveRequest.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : ""; //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; //leaveRequest.LeaveSalaryText = // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); @@ -391,11 +410,15 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-010": { - var lastSalary = profile.ProfileSalary; - var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; - var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); - leaveRequest.LeaveSalary = (int)lastSalaryAmount; - leaveRequest.LeaveSalaryText = lastSalaryAmountText; + // var lastSalary = profile.ProfileSalary; + // var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + // var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + // leaveRequest.LeaveSalary = (int)lastSalaryAmount; + // leaveRequest.LeaveSalaryText = lastSalaryAmountText; + leaveRequest.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0; + leaveRequest.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : ""; //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; //leaveRequest.LeaveSalaryText = // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); @@ -481,7 +504,8 @@ namespace BMA.EHR.Leave.Service.Controllers foreach (var leave in leaves) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(leave.KeycloakUserId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(leave.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(leave.KeycloakUserId, AccessToken); if (profile != null) { leave.Prefix = profile.Prefix; @@ -541,7 +565,8 @@ namespace BMA.EHR.Leave.Service.Controllers // return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้"); // } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { @@ -666,11 +691,15 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-008": { - var lastSalary = profile.ProfileSalary; + // var lastSalary = profile.ProfileSalary; - oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - oldData.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + // oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + // oldData.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + oldData.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0; + oldData.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : ""; oldData.LeaveBirthDate = profile.BirthDate; oldData.LeaveGovernmentDate = profile.DateStart; @@ -686,12 +715,15 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-010": { - var lastSalary = profile.ProfileSalary; - - oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - oldData.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + // var lastSalary = profile.ProfileSalary; + // oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + // oldData.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + oldData.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0; + oldData.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : ""; oldData.CoupleDayName = req.CoupleDayName ?? ""; oldData.CoupleDayPosition = req.CoupleDayPosition ?? ""; oldData.CoupleDayLevel = req.CoupleDayLevel ?? ""; @@ -826,15 +858,16 @@ namespace BMA.EHR.Leave.Service.Controllers { var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var thisYear = DateTime.Now.Year; + var thisYear = DateTime.Now.Year - 1; var toDay = DateTime.Now.Date; - var startFiscalDate = new DateTime(DateTime.Now.Year, 10, 1); - var endFiscalDate = new DateTime(DateTime.Now.Year + 1, 9, 30); + var startFiscalDate = new DateTime(DateTime.Now.Year - 1, 10, 1); + var endFiscalDate = new DateTime(DateTime.Now.Year, 9, 30); if (toDay >= startFiscalDate && toDay <= endFiscalDate) thisYear = thisYear + 1; - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); @@ -868,19 +901,36 @@ namespace BMA.EHR.Leave.Service.Controllers if (leaveType.Code.Trim().ToUpper() == "LV-005") { - leaveLimit = leaveData == null ? 0 : leaveData.LeaveDays; + // if (profile.IsProbation! == true) + // leaveLimit = 0; + // else + { + leaveLimit = leaveData == null ? + 10 + : leaveData.LeaveDays; + } } else leaveLimit = leaveType.Limit; var restOldDay = leaveData == null ? 0 : leaveData.LeaveDays - 10; var restCurrentDay = 10.0; + // if (profile.IsProbation! == true) + // { + // restOldDay = 0; + // restCurrentDay = 0; + // } + if(restOldDay < 0) + restOldDay = 0; var sumLeave = leaveData == null ? 0 : leaveData.LeaveDaysUsed; - var lastSalary = profile.ProfileSalary; + // var lastSalary = profile.ProfileSalary; var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type); + var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate); + var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate); + var result = new GetUserLeaveProfileResultDto { DateSendLeave = DateTime.Now.Date, @@ -896,14 +946,18 @@ namespace BMA.EHR.Leave.Service.Controllers OrganizationName = orgName, //profile.Oc ?? "", LeaveLimit = leaveLimit, // จำนวนวันลาทั้งหมดในปีนั้นๆที่ลาได้ โดยรวมยอดที่เหลือจากปีก่อนมา (เอาค่ามาจากตาราง Beginning เลย) - LeaveTotal = sumLeave, // จำนวนวันลาที่ลาไปแล้วในปีนั้นๆ โดยเมื่อมีการอนุมัติลา จะมาบวกค่านี้ไปเรื่อยๆ (เอาค่ามาจากตาราง Beginning เลย) - LeaveRemain = leaveLimit - sumLeave, + LeaveTotal = sumLeave ?? 0, // จำนวนวันลาที่ลาไปแล้วในปีนั้นๆ โดยเมื่อมีการอนุมัติลา จะมาบวกค่านี้ไปเรื่อยๆ (เอาค่ามาจากตาราง Beginning เลย) + LeaveRemain = leaveLimit - (sumLeave ?? 0), RestDayTotalOld = restOldDay, // เอา leaveLimit มาลบ 10 (LV-005) RestDayTotalCurrent = restCurrentDay,// 10 วันเสมอ (LV-005) BirthDate = profile.BirthDate.Date, DateAppoint = profile.DateAppoint == null ? null : profile.DateAppoint.Value.Date, - Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value, - SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), + // Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value, + // SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), + Salary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0, + SalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : "", LeaveLast = leaveLast == null ? null : leaveLast, TelephoneNumber = profile.TelephoneNumber ?? "", @@ -912,11 +966,56 @@ namespace BMA.EHR.Leave.Service.Controllers CurrentDistrict = profile.CurrentDistrict ?? "", CurrentProvince = profile.CurrentProvince ?? "", CurrentZipCode = profile.CurrentZipCode ?? "", + GovAge = govAge, + + LeaveDraftSummary = leaveDraftSummary, + LeaveWaitingSummary = leaveWaitingSummary }; return Success(result); } + [HttpGet("time-check")] + [AllowAnonymous] + public async Task> TimeCheckAsync() + { + var startDate = new DateTime(2017, 1, 6); + var govAge = (startDate).DiffDay(DateTime.Now.Date); + var date1Raw = startDate; + var date1 = new LocalDate(date1Raw.Year, date1Raw.Month, date1Raw.Day); + var date2 = new LocalDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + + + var (govAgeYear, govAgeMonth, govAgeDay) = startDate.GetDifference(DateTime.Now.Date); + + var isLeave = false; + var message = string.Empty; + + if (govAgeYear >= 1 || (govAgeYear == 0 && govAgeMonth >= 6)) + { + isLeave = true; + if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด"; + } + else + { + isLeave = false; + if (!isLeave) message = "อายุราชการน้อยกว่า 6 เดือนหรือ 180 วัน"; + } + + return Success(new + { + GovAge = govAge, + GovAgeDay = govAgeDay, + GovAgeMonth = govAgeMonth, + GovAgeYear = govAgeYear, + IsLeave = isLeave, + Message = message + + + + }); + } + /// /// LV2_003 - เช็คการยืนขอลา (USER) /// @@ -935,8 +1034,19 @@ namespace BMA.EHR.Leave.Service.Controllers var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date); + var startDate = profile?.DateStart?.Date ?? DateTime.Now.Date; + // var date1Raw = profile?.DateStart?.Date ?? DateTime.Now.Date; + // var date1 = new LocalDate(date1Raw.Year, date1Raw.Month, date1Raw.Day); + // var date2 = new LocalDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + // Period period = Period.Between(date1, date2); + // var govAgeMonth = period.Months; + // var govAgeYear = period.Years; + + var (govAgeYear, govAgeMonth, govAgeDay) = startDate.GetDifference(DateTime.Now.Date); + var thisYear = DateTime.Now.Year; var message = string.Empty; @@ -969,26 +1079,38 @@ namespace BMA.EHR.Leave.Service.Controllers fiscalYear = req.StartLeaveDate.Year + 1; var sumLeaveDay = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(fiscalYear, req.Type, userId); - - - var minLeave = (await _context.Set().Where(x => x.Type.Id == req.Type && - (x.LeaveStatus == "PENDING" || x.LeaveStatus == "APPROVE") && - x.KeycloakUserId == userId) - .OrderBy(x => x.LeaveStartDate) - .FirstOrDefaultAsync()); - - var maxLeave = (await _context.Set().Where(x => x.Type.Id == req.Type && - (x.LeaveStatus == "PENDING" || x.LeaveStatus == "APPROVE") && - x.KeycloakUserId == userId) - .OrderByDescending(x => x.LeaveEndDate) - .FirstOrDefaultAsync()); - var isBetween = false; - if (minLeave != null && maxLeave != null) - { - isBetween = (req.StartLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.StartLeaveDate.Date <= maxLeave.LeaveEndDate.Date) || - (req.EndLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.EndLeaveDate.Date <= maxLeave.LeaveEndDate.Date); - } + var existingLeaves = await _context.Set() + .Where(x => x.Type.Id == req.Type && + (x.LeaveStatus == "PENDING" || x.LeaveStatus == "APPROVE") && + x.KeycloakUserId == userId) + .ToListAsync(); + + isBetween = existingLeaves.Any(leave => + req.StartLeaveDate.Date <= leave.LeaveEndDate.Date && + req.EndLeaveDate.Date >= leave.LeaveStartDate.Date); + + // var minLeave = (await _context.Set().Where(x => x.Type.Id == req.Type && + // (x.LeaveStatus == "PENDING" || x.LeaveStatus == "APPROVE") && + // x.KeycloakUserId == userId) + // .OrderBy(x => x.LeaveStartDate) + // .FirstOrDefaultAsync()); + + // var maxLeave = (await _context.Set().Where(x => x.Type.Id == req.Type && + // (x.LeaveStatus == "PENDING" || x.LeaveStatus == "APPROVE") && + // x.KeycloakUserId == userId) + // .OrderByDescending(x => x.LeaveEndDate) + // .FirstOrDefaultAsync()); + + // var isBetween = false; + // if (minLeave != null && maxLeave != null) + // { + // // isBetween = (req.StartLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.StartLeaveDate.Date <= maxLeave.LeaveEndDate.Date) || + // // (req.EndLeaveDate.Date >= minLeave.LeaveStartDate.Date && req.EndLeaveDate.Date <= maxLeave.LeaveEndDate.Date); + // isBetween = req.StartLeaveDate.Date <= maxLeave.LeaveEndDate.Date && + // req.EndLeaveDate.Date >= minLeave.LeaveStartDate.Date; + + // } var isLeave = false; var approveDay = sumLeaveDay == null ? 0.0 : sumLeaveDay.LeaveDaysUsed; @@ -1006,12 +1128,11 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-002": // fix issue : ระบบลา (ขรก.) >> ลากิจส่วนตัว (กรณียื่นขอลาเกิน 45 วัน/ปี) #829 // fix issue : ระบบลา (ขรก.) >> ลากิจส่วนตัว (กรณีผู้เข้ารับราชการไม่เกิน 1 ปี ยื่นขอลาเกิน 15 วัน/ปี) #831 - if (govAge <= 365) + if (govAgeYear <= 1) { isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= 15; if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด"; } - else { isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= 45; @@ -1033,32 +1154,11 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-005": // fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838 - //var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(fiscalYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault(); - //var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน - - if (govAge >= 180) + if (govAgeYear >= 1 || (govAgeYear == 0 && govAgeMonth >= 6)) { isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay); if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด"; } - // else if (govAge >= 3650) - // { - // // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน - // var leavePrevYearRemain = 30 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน - // if (leavePrevYearRemain >= 20) leavePrevYearRemain = 20; - - // isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay); - // if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด"; - // } - // else if - // { - // //var leavePrevYearRemain = 20 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน - // //if (leavePrevYearRemain >= 10) leavePrevYearRemain = 10; - - // isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= (10 + leavePrevYearRemain); - // if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด"; - // } - else { isLeave = false; @@ -1068,7 +1168,7 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-006": // fix issue : ระบบลา(ขรก.) >> ลาอุปสมบทหรือการลาประกอบพิธีฮัจย์ฯ(กรณีรับราชการน้อยกว่า 1 ปี) #840 - if (govAge < 365) + if (govAgeYear < 1) { isLeave = false; if (!isLeave) message = "อายุราชการน้อยกว่า 1 ปีหรือ 365 วัน"; @@ -1094,7 +1194,7 @@ namespace BMA.EHR.Leave.Service.Controllers break; case "LV-008": case "LV-009": - isLeave = govAge >= 365; + isLeave = govAgeYear >= 1; if (!isLeave) message = "อายุราชการน้อยกว่า 1 ปีหรือ 365 วัน"; break; case "LV-010": @@ -1233,7 +1333,7 @@ namespace BMA.EHR.Leave.Service.Controllers Id = d.Id, LeaveTypeId = d.Type.Id, LeaveTypeName = d.Type.Name, - DateSendLeave = d.CreatedAt.Date, + DateSendLeave = d.DateSendLeave != null ? d.DateSendLeave.Value.Date : d.CreatedAt.Date, Status = d.LeaveStatus, FullName = $"{d.Prefix}{d.FirstName} {d.LastName}", LeaveEndDate = d.LeaveEndDate, @@ -1261,14 +1361,14 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> GetLeaveRequestCalendarAdminAsync( [FromBody] GetLeaveRequestCalendarDto req) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") + var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST"); + //var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData!.status != 200) { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + return Error(jsonData.message, StatusCodes.Status403Forbidden); } - - string role = jsonData["result"]?.ToString(); + //string role = jsonData["result"]?.ToString(); + string role = jsonData.result.privilege; var nodeId = string.Empty; var profileAdmin = new GetUserOCAllDto(); profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken); @@ -1298,12 +1398,93 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } var data = await _leaveRequestRepository.GetLeaveRequestByYearForAdminAsync(req.Year, role, nodeId, profileAdmin.Node); + + // ถ้ามีการรักษาการ + if (jsonData.result.isAct) + { + var posActs = jsonData.result.posMasterActs.Where(x => x.privilege != "EMPTY"); + foreach(var act in posActs) + { + var actRole = act.privilege; + string actNodeId = string.Empty; + int? actNode = null; + + if (actRole == "NORMAL" || actRole == "CHILD") + { + actNodeId = act.child4DnaId != null ? + act.child4DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child1DnaId != null ? + act.child1DnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "BROTHER") + { + actNodeId = act.child4DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child1DnaId!.Value.ToString("D") : + act.child1DnaId != null ? + act.rootDnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "ROOT" /*|| role == "PARENT"*/) + { + actNodeId = act.rootDnaId!.Value.ToString("D"); + actNode = 0; + } + + var rawDataAct = await _leaveRequestRepository.GetLeaveRequestByYearForAdminAsync(req.Year, actRole, actNodeId, actNode); + if (rawDataAct != null) + { + if (data != null) + data = data.Union(rawDataAct).DistinctBy(x => x.Id).ToList(); + else + data = rawDataAct; + } + } + } + + + + var resultData = (from d in data //join p in profileList on d.KeycloakUserId equals p.Keycloak select new GetLeaveRequestCalendarResultDto @@ -1311,12 +1492,13 @@ namespace BMA.EHR.Leave.Service.Controllers Id = d.Id, LeaveTypeId = d.Type.Id, LeaveTypeName = d.Type.Name, - DateSendLeave = d.CreatedAt.Date, + DateSendLeave = d.DateSendLeave != null ? d.DateSendLeave.Value.Date : d.CreatedAt.Date, Status = d.LeaveStatus, FullName = $"{d.Prefix}{d.FirstName} {d.LastName}", LeaveEndDate = d.LeaveEndDate, LeaveStartDate = d.LeaveStartDate, - KeycloakId = d.KeycloakUserId + KeycloakId = d.KeycloakUserId, + LeaveTotal = d.LeaveTotal }) .ToList(); @@ -1363,7 +1545,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveTypeName = item.Type.Name, LeaveSubTypeName = item.LeaveSubTypeName ?? "", FullName = $"{item.Prefix}{item.FirstName} {item.LastName}", - DateSendLeave = item.CreatedAt, + DateSendLeave = item.DateSendLeave ?? item.CreatedAt, IsDelete = item.LeaveStatus == "DELETE", Status = item.LeaveStatus, LeaveStartDate = item.LeaveStartDate, @@ -1484,7 +1666,8 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken); if (profile == null) { @@ -1496,8 +1679,8 @@ namespace BMA.EHR.Leave.Service.Controllers var userCalendar = await _userCalendarRepository.GetExist(profile.Id); var category = userCalendar == null ? "NORMAL" : userCalendar.Calendar; - var lastSalary = profile.ProfileSalary; - var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0; + // var lastSalary = profile.ProfileSalary; + // var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0; var lastLeaveRequest = await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId, @@ -1523,7 +1706,8 @@ namespace BMA.EHR.Leave.Service.Controllers var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId); - var restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : leaveData.LeaveDays - 10; + var restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : (leaveData.LeaveDays + leaveData.BeginningLeaveDays - 10); + if (restDayOld < 0) restDayOld = 0; var restDayCurrent = govAge < 180 ? 0 : 10; @@ -1536,7 +1720,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveSubTypeName = rawData.LeaveSubTypeName, LeaveTypeId = rawData.Type.Id, FullName = $"{rawData.Prefix}{rawData.FirstName} {rawData.LastName}", - DateSendLeave = rawData.CreatedAt, + DateSendLeave = rawData.DateSendLeave ?? rawData.CreatedAt, Status = rawData.LeaveStatus, LeaveStartDate = rawData.LeaveStartDate, LeaveEndDate = rawData.LeaveEndDate, @@ -1562,8 +1746,12 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveBirthDate = profile.BirthDate, LeaveGovernmentDate = profile.DateAppoint == null ? null : profile.DateAppoint.Value, - LeaveSalary = lastSalary == null ? 0 : lastSalaryAmount, - LeaveSalaryText = lastSalary == null ? "" : ((int)lastSalaryAmount).ToThaiBahtText(false), + // LeaveSalary = lastSalary == null ? 0 : lastSalaryAmount, + // LeaveSalaryText = lastSalary == null ? "" : ((int)lastSalaryAmount).ToThaiBahtText(false), + LeaveSalary = profile.Amount.HasValue && profile.Amount > 0 + ? (int)profile.Amount : 0, + LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0 + ? ((int)profile.Amount).ToThaiBahtText(false) : "", WifeDayName = rawData.WifeDayName, WifeDayDateBorn = rawData.WifeDayDateBorn, @@ -1652,14 +1840,14 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> GetLeaveRequestForAdminAsync( [FromBody] GetLeaveRequestForAdminDto req) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") + var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST"); + //var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData!.status != 200) { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + return Error(jsonData.message, StatusCodes.Status403Forbidden); } - - string role = jsonData["result"]?.ToString(); + //string role = jsonData["result"]?.ToString(); + string role = jsonData.result.privilege; var nodeId = string.Empty; var profileAdmin = new GetUserOCAllDto(); profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken); @@ -1689,13 +1877,92 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } var rawData = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, role, nodeId, profileAdmin?.Node); + + // ถ้ามีการรักษาการ + if (jsonData.result.isAct) + { + var posActs = jsonData.result.posMasterActs.Where(x => x.privilege != "EMPTY"); + foreach(var act in posActs) + { + var actRole = act.privilege; + string actNodeId = string.Empty; + int? actNode = null; + + if (actRole == "NORMAL" || actRole == "CHILD") + { + actNodeId = act.child4DnaId != null ? + act.child4DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child1DnaId != null ? + act.child1DnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "BROTHER") + { + actNodeId = act.child4DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child1DnaId!.Value.ToString("D") : + act.child1DnaId != null ? + act.rootDnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "ROOT" /*|| role == "PARENT"*/) + { + actNodeId = act.rootDnaId!.Value.ToString("D"); + actNode = 0; + } + + var rawDataAct = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, actRole, actNodeId, actNode); + if (rawDataAct != null) + { + if (rawData != null) + rawData = rawData.Union(rawDataAct).DistinctBy(x => x.Id).ToList(); + else + rawData = rawDataAct; + } + } + } + + var result = new List(); foreach (var item in rawData) @@ -1728,7 +1995,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveSubTypeName = item.LeaveSubTypeName, FullName = $"{item.Prefix}{item.FirstName} {item.LastName}", ProfileType = item.ProfileType ?? "-", - DateSendLeave = item.CreatedAt, + DateSendLeave = item.DateSendLeave ?? item.CreatedAt, Status = item.LeaveStatus, CitizenId = item.CitizenId ?? "", LeaveStartDate = item.LeaveStartDate, @@ -1740,6 +2007,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveRange = item.LeaveRange ?? "ALL", LeaveRangeEnd = item.LeaveRangeEnd ?? "ALL", HajjDayStatus = item.HajjDayStatus, + LeaveTotal = item.LeaveTotal }; result.Add(res); @@ -1777,6 +2045,12 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(data.KeycloakUserId, AccessToken); + if (profile == null) + { + return Error(GlobalMessages.ProfileNotFound, StatusCodes.Status404NotFound); + } + // change status to delete // แก้จาก DELETE เป็น DELETING ไว้ก่อน รอ approve ค่อยเปลี่ยนเป็น DELETE // data.LeaveStatus = "DELETE"; @@ -1813,7 +2087,7 @@ namespace BMA.EHR.Leave.Service.Controllers // TODO: Send notification to all users who need to approve the cancel leave request var approvers = data.Approvers - .Where(x => x.ApproveStatus!.ToUpper() == "PENDING") + //.Where(x => x.ApproveStatus!.ToUpper() == "PENDING") .OrderBy(x => x.Seq) .ToList(); @@ -1825,11 +2099,33 @@ namespace BMA.EHR.Leave.Service.Controllers Body = $"คำร้องขอยกเลิกการลาของคุณ {data.FirstName} {data.LastName} รอรับการอนุมัติจากคุณ", ReceiverUserId = approver!.ProfileId, Type = "", - Payload = $"{URL}/leave/detail/{id}", + Payload = $"{URL}/leave-reject/detail/{id}", }; _appDbContext.Set().Add(noti1); } + // Get Officer List + var officers = await _userProfileRepository.GetOCStaffAsync(profile.Id, AccessToken); + var approverProfileIdList = approvers.Select(x => x.ProfileId).ToList(); + + if(officers != null && officers.Count > 0) + { + officers = officers.Where(x => !approverProfileIdList.Contains(x.ProfileId)).ToList(); + foreach (var officer in officers) + { + // Send Notification + var noti = new Notification + { + Body = $"คำร้องขอยกเลิกการลาของคุณ {data.FirstName} {data.LastName} รอรับการอนุมัติจากคุณ", + ReceiverUserId = officer.ProfileId, + Type = "", + Payload = $"{URL}/leave-reject/detail/{id}", + }; + _appDbContext.Set().Add(noti); + } + await _appDbContext.SaveChangesAsync(); + } + return Success(); } @@ -1849,14 +2145,14 @@ namespace BMA.EHR.Leave.Service.Controllers public async Task> GetCancelLeaveRequestForAdminAsync( [FromBody] GetLeaveRequestForAdminDto req) { - var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") + var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST"); + //var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData!.status != 200) { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + return Error(jsonData.message, StatusCodes.Status403Forbidden); } - - string role = jsonData["result"]?.ToString(); + //string role = jsonData["result"]?.ToString(); + string role = jsonData.result.privilege; var nodeId = string.Empty; var profileAdmin = new GetUserOCAllDto(); profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken); @@ -1886,7 +2182,7 @@ namespace BMA.EHR.Leave.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -1894,11 +2190,98 @@ namespace BMA.EHR.Leave.Service.Controllers var rawData = await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, role, nodeId, profileAdmin?.Node); + // ถ้ามีการรักษาการ + if (jsonData.result.isAct) + { + var posActs = jsonData.result.posMasterActs.Where(x => x.privilege != "EMPTY"); + foreach(var act in posActs) + { + var actRole = act.privilege; + string actNodeId = string.Empty; + int? actNode = null; + + if (actRole == "NORMAL" || actRole == "CHILD") + { + actNodeId = act.child4DnaId != null ? + act.child4DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child1DnaId != null ? + act.child1DnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "BROTHER") + { + actNodeId = act.child4DnaId != null ? + act.child3DnaId.Value.ToString("D") : + act.child3DnaId != null ? + act.child2DnaId.Value.ToString("D") : + act.child2DnaId != null ? + act.child1DnaId!.Value.ToString("D") : + act.child1DnaId != null ? + act.rootDnaId.Value.ToString("D") : + act.rootDnaId != null ? + act.rootDnaId.Value.ToString("D") : + ""; + actNode = act.child4DnaId != null ? + 4 : + act.child3DnaId != null ? + 3 : + act.child2DnaId != null ? + 2 : + act.child1DnaId != null ? + 1 : + act.rootDnaId != null ? + 0 : + null; + } + else if (actRole == "ROOT" /*|| role == "PARENT"*/) + { + actNodeId = act.rootDnaId!.Value.ToString("D"); + actNode = 0; + } + + var rawDataAct = await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, actRole, actNodeId, actNode); + if (rawDataAct != null) + { + if (rawData != null) + rawData = rawData.Union(rawDataAct).DistinctBy(x => x.Id).ToList(); + else + rawData = rawDataAct; + } + } + } + + + var recCount = rawData.Count; + + if (req.Keyword != "") + rawData = rawData.Where(x => ($"{x.Prefix}{x.FirstName} {x.LastName}").Contains(req.Keyword)).ToList(); + if (!string.IsNullOrEmpty(req.ProfileType) && req.ProfileType.ToUpper() != "ALL") + rawData = rawData.Where(x => x.ProfileType.ToUpper().Contains(req.ProfileType.ToUpper())).ToList(); + + rawData = rawData.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList(); + var result = new List(); foreach (var item in rawData) { - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken); + //var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(item.KeycloakUserId, AccessToken); var res = new GetLeaveCancelRequestResultDto { Id = item.Id, @@ -1907,19 +2290,19 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveSubTypeName = item.LeaveSubTypeName, ProfileType = item.ProfileType ?? "-", FullName = $"{item.Prefix}{item.FirstName} {item.LastName}", - DateSendLeave = item.CreatedAt.Date, + DateSendLeave = item.DateSendLeave != null ? item.DateSendLeave.Value.Date : item.CreatedAt.Date, Status = item.LeaveCancelStatus ?? "" }; result.Add(res); } - if (req.Keyword != "") - result = result.Where(x => x.FullName.Contains(req.Keyword)).ToList(); - if (!string.IsNullOrEmpty(req.ProfileType) && req.ProfileType.ToUpper() != "ALL") - result = result.Where(x => x.ProfileType.ToUpper().Contains(req.ProfileType.ToUpper())).ToList(); - var pageResult = result.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList(); + // if (req.Keyword != "") + // result = result.Where(x => x.FullName.Contains(req.Keyword)).ToList(); + // if (!string.IsNullOrEmpty(req.ProfileType) && req.ProfileType.ToUpper() != "ALL") + // result = result.Where(x => x.ProfileType.ToUpper().Contains(req.ProfileType.ToUpper())).ToList(); + // var pageResult = result.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList(); - return Success(new { data = pageResult, total = result.Count }); + return Success(new { data = result, total = recCount }); } @@ -1946,12 +2329,12 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); - if (profile == null) - { - return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); - } + // if (profile == null) + // { + // return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + // } var result = new GetCancelLeaveRequestByIdDto { @@ -2003,7 +2386,8 @@ namespace BMA.EHR.Leave.Service.Controllers return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken); + // var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(Guid.Parse(UserId!), AccessToken); if (profile == null) { @@ -2027,13 +2411,16 @@ namespace BMA.EHR.Leave.Service.Controllers { new LeaveRequestApprover { - Prefix = profile.Prefix, - FirstName = profile.FirstName, - LastName = profile.LastName, - PositionName = profile.Position, + Prefix = profile.Prefix ?? "", + FirstName = profile.FirstName ?? "", + LastName = profile.LastName ?? "", + PositionName = $"{profile.Position ?? ""}", ProfileId = profile.Id, KeycloakId = Guid.Parse(UserId!), ApproveType = "SENDER", + PositionLevelName = profile.PositionLeaveName ?? "", + PosExecutiveName = profile.PosExecutiveName ?? "", + OrganizationName = profile.Oc ?? "", CreatedFullName = FullName ?? "", CreatedUserId = UserId!, @@ -2247,46 +2634,66 @@ namespace BMA.EHR.Leave.Service.Controllers { await _leaveRequestRepository.SendToOfficerAsync(id); + // Remove Workflow Integration var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId); var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); if (profile == null) { return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); } - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; - if (profile.ProfileType == "OFFICER") + + // Get Officer List + var officers = await _userProfileRepository.GetOCStaffAsync(profile.Id, AccessToken); + if(officers != null && officers.Count > 0) { - using (var client = new HttpClient()) + foreach (var officer in officers) { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // Send Notification + var noti = new Notification { - refId = id, - sysName = "SYS_LEAVE_LIST", - posLevelName = profile.PosLevel ?? "", - posTypeName = profile.PosType ?? "", - fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" - }); - } - } - else - { - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - refId = id, - sysName = "SYS_LEAVE_LIST_EMP", - posLevelName = profile.PosLevel ?? "", - posTypeName = profile.PosType ?? "", - fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" - }); + Body = $"มีคำร้องขอลาจาก {profile.Prefix}{profile.FirstName} {profile.LastName} รอรับการอนุมัติจากคุณ", + ReceiverUserId = officer.ProfileId, + Type = "", + Payload = $"{URL}/leave/detail/{id}", + }; + _appDbContext.Set().Add(noti); } + await _appDbContext.SaveChangesAsync(); } + // var baseAPIOrg = _configuration["API"]; + // var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; + // if (profile.ProfileType == "OFFICER") + // { + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // refId = id, + // sysName = "SYS_LEAVE_LIST", + // posLevelName = profile.PosLevel ?? "", + // posTypeName = profile.PosType ?? "", + // fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" + // }); + // } + // } + // else + // { + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // refId = id, + // sysName = "SYS_LEAVE_LIST_EMP", + // posLevelName = profile.PosLevel ?? "", + // posTypeName = profile.PosType ?? "", + // fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}" + // }); + // } + // } return Success(); } @@ -2374,8 +2781,10 @@ namespace BMA.EHR.Leave.Service.Controllers } } } - var thisYear = DateTime.Now.Year; - var toDay = DateTime.Now.Date; + var thisYear = rawData.LeaveStartDate.Year; + var toDay = rawData.LeaveStartDate.Date; + // var thisYear = DateTime.Now.Year; + // var toDay = DateTime.Now.Date; if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31)) thisYear = thisYear + 1; @@ -2393,8 +2802,8 @@ namespace BMA.EHR.Leave.Service.Controllers //var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0; var lastLeaveRequest = - await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId, - rawData.Type.Id, rawData.LeaveStartDate.Date); + await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync2(rawData.KeycloakUserId, + rawData.Type.Id, rawData.CreatedAt); //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); //var approver = string.Empty; @@ -2427,7 +2836,20 @@ namespace BMA.EHR.Leave.Service.Controllers orgName += $" {rawData.Root}"; var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId); - var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed; + + var startFiscalYear = new DateTime(rawData.LeaveStartDate.Year - 1, 10, 1); + var endFiscalYear = rawData.DateSendLeave ?? rawData.CreatedAt; + var endFiscalYear2 = new DateTime(rawData.LeaveStartDate.Year, 9, 30); + //var endFiscalYear3 = rawData.DateSendLeave ?? rawData.CreatedAt; + var leaveSummary = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear); + + // วันลาแบบร่างและที่ยื่นลาไปแล้ว + var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear2); + var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear2); + + //var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed; + if (leaveData != null) + leaveSummary += leaveData.BeginningLeaveDays; var extendLeave = 0.0; var leaveLimit = (double)rawData.Type.Limit; @@ -2435,7 +2857,7 @@ namespace BMA.EHR.Leave.Service.Controllers if (rawData.Type.Code == "LV-005") { leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays; - extendLeave = leaveLimit - 10; + extendLeave = leaveLimit <= 0 ? 0 : leaveLimit - 10; } var result = new GetLeaveRequestForAdminByIdDto @@ -2448,7 +2870,7 @@ namespace BMA.EHR.Leave.Service.Controllers LeaveSubTypeName = rawData.LeaveSubTypeName, LeaveTypeId = rawData.Type.Id, FullName = $"{rawData.Prefix}{rawData.FirstName} {rawData.LastName}", - DateSendLeave = rawData.CreatedAt, + DateSendLeave = rawData.DateSendLeave ?? rawData.CreatedAt, Status = rawData.LeaveStatus, LeaveStartDate = rawData.LeaveStartDate, LeaveEndDate = rawData.LeaveEndDate, @@ -2534,13 +2956,14 @@ namespace BMA.EHR.Leave.Service.Controllers //OrganizationName = rawData.OrganizationName ?? "", // fix SIT ระบบบันทึกการลา>>รายการลา (ข้อมูลผู้สังกัดและเรียนไม่แสดง) #971 - - ApproveStep = rawData.ApproveStep ?? "-", LeaveLimit = rawData.Type.Limit + extendLeave, LeaveSummary = leaveSummary, - LeaveRemain = (rawData.Type.Limit + extendLeave) - leaveSummary + LeaveRemain = (rawData.Type.Limit + extendLeave) - leaveSummary, + + LeaveDraftSummary = leaveDraftSummary, + LeaveWaitingSummary = leaveWaitingSummary }; if (rawData.LeaveDocument != null && rawData.LeaveDocument.Count > 0) @@ -2568,7 +2991,10 @@ namespace BMA.EHR.Leave.Service.Controllers ApproveStatus = x.ApproveStatus, Comment = x.Comment, ProfileId = x.ProfileId, - KeycloakId = x.KeycloakId + KeycloakId = x.KeycloakId, + isAct = x.IsAct, + keyId = x.KeyId + }).ToList(); var approvers = rawData.Approvers.Where(x => x.ApproveType.ToUpper() == "APPROVER") @@ -2583,7 +3009,10 @@ namespace BMA.EHR.Leave.Service.Controllers ApproveStatus = x.ApproveStatus, Comment = x.Comment, ProfileId = x.ProfileId, - KeycloakId = x.KeycloakId + KeycloakId = x.KeycloakId, + + isAct = x.IsAct, + keyId = x.KeyId }).ToList(); result.Approvers.AddRange(approvers); @@ -2618,7 +3047,8 @@ namespace BMA.EHR.Leave.Service.Controllers var sendList = await _leaveRequestRepository.GetSumSendLeaveAsync(thisYear); var rejectList = await _leaveRequestRepository.GetSumRejectLeaveAsync(thisYear); var deleteList = await _leaveRequestRepository.GetSumDeleteLeaveAsync(thisYear); - var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + // var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken); + var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken); if (pf == null) { @@ -2660,7 +3090,7 @@ namespace BMA.EHR.Leave.Service.Controllers if (leaveType.Code == "LV-005") { leaveLimit = leaveData?.LeaveDays ?? 0.0; - extendLeave = leaveLimit - 10; + extendLeave = leaveLimit <= 0 ? 0 : leaveLimit - 10; } var data = new diff --git a/BMA.EHR.Leave/DTOs/ChangeRound/CreateChangeRoundDto.cs b/BMA.EHR.Leave/DTOs/ChangeRound/CreateChangeRoundDto.cs index 6ad96fcd..5379abda 100644 --- a/BMA.EHR.Leave/DTOs/ChangeRound/CreateChangeRoundDto.cs +++ b/BMA.EHR.Leave/DTOs/ChangeRound/CreateChangeRoundDto.cs @@ -12,4 +12,25 @@ namespace BMA.EHR.Leave.Service.DTOs.ChangeRound public string Remark { get; set; } } + + public class CreateChangeRoundMultipleDto + { + public Guid ProfileId { get; set; } + + public Guid RoundId { get; set; } + + public DateTime EffectiveDate { get; set; } + + public string Remark { get; set; } + + public Guid? RootDnaId { get; set; } + public Guid? Child1DnaId { get; set; } + public Guid? Child2DnaId { get; set; } + public Guid? Child3DnaId { get; set; } + public Guid? Child4DnaId { get; set; } + + public string? Prefix { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + } } diff --git a/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileDto.cs b/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileDto.cs index 3b05ad29..69f5cbba 100644 --- a/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileDto.cs +++ b/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileDto.cs @@ -17,5 +17,9 @@ public string? sortBy { get; set; } public bool? descending { get; set; } + + public Guid? SelectedNodeId { get; set; } + + public int? SelectedNode { get; set; } } } diff --git a/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileResultDto.cs b/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileResultDto.cs index 83b4d7b9..00df91a9 100644 --- a/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileResultDto.cs +++ b/BMA.EHR.Leave/DTOs/ChangeRound/SearchProfileResultDto.cs @@ -17,5 +17,11 @@ public string LeaveTimeAfterNoon { get;set; } public DateTime? EffectiveDate { get; set; } + + public string? RootDnaId { get; set; } + public string? Child1DnaId { get; set; } + public string? Child2DnaId { get; set; } + public string? Child3DnaId { get; set; } + public string? Child4DnaId { get; set; } } } diff --git a/BMA.EHR.Leave/DTOs/CheckIn/CheckTimeDto.cs b/BMA.EHR.Leave/DTOs/CheckIn/CheckTimeDto.cs index 3a738170..0d49c24f 100644 --- a/BMA.EHR.Leave/DTOs/CheckIn/CheckTimeDto.cs +++ b/BMA.EHR.Leave/DTOs/CheckIn/CheckTimeDto.cs @@ -54,6 +54,7 @@ namespace BMA.EHR.Leave.Service.DTOs.CheckIn public Guid? CheckInId { get; set; } + public Guid? TaskId { get; set; } public double Lat { get; set; } = 0; diff --git a/BMA.EHR.Leave/DTOs/LeaveBeginnings/CreateLeaveBeginningDto.cs b/BMA.EHR.Leave/DTOs/LeaveBeginnings/CreateLeaveBeginningDto.cs index 79d33052..423385ed 100644 --- a/BMA.EHR.Leave/DTOs/LeaveBeginnings/CreateLeaveBeginningDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveBeginnings/CreateLeaveBeginningDto.cs @@ -14,10 +14,19 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveBeginnings [Required, Comment("ปีงบประมาณ")] public int LeaveYear { get; set; } = 0; - [Required, Comment("จำนวนวันลายกมา")] + [Required, Comment("จำนวนวันลาที่ได้รับ")] public double LeaveDays { get; set; } = 0.0; [Required, Comment("จำนวนวันลาที่ใช้ไป")] public double LeaveDaysUsed { get; set; } = 0.0; + + [Required, Comment("จำนวนครั้งที่ลาสะสม")] + public int LeaveCount { get; set; } = 0; + + [Required, Comment("จำนวนวันลายกมา")] + public double BeginningLeaveDays { get; set; } = 0.0; + + [Comment("จำนวนครั้งที่ลายกมา")] + public int BeginningLeaveCount { get; set; } = 0; } } diff --git a/BMA.EHR.Leave/DTOs/LeaveBeginnings/EditLeaveBeginningDto.cs b/BMA.EHR.Leave/DTOs/LeaveBeginnings/EditLeaveBeginningDto.cs index 6ecfe1f4..a41aa9f2 100644 --- a/BMA.EHR.Leave/DTOs/LeaveBeginnings/EditLeaveBeginningDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveBeginnings/EditLeaveBeginningDto.cs @@ -17,7 +17,47 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveBeginnings [Required, Comment("จำนวนวันลายกมา")] public double LeaveDays { get; set; } = 0.0; - [Required, Comment("จำนวนวันลาที่ใช้ไป")] - public double LeaveDaysUsed { get; set; } = 0.0; + [Comment("จำนวนวันลาที่ใช้ไป")] + public double? LeaveDaysUsed { get; set; } + + [Comment("จำนวนครั้งที่ลาสะสม")] + public int? LeaveCount { get; set; } + + [Required, Comment("จำนวนวันลายกมาก่อนใช้ระบบ")] + public double BeginningLeaveDays { get; set; } = 0.0; + + [Comment("จำนวนครั้งที่ลายกมาก่อนใช้ระบบ")] + public int BeginningLeaveCount { get; set; } = 0; + } + + + public class ScheduleEditLeaveBeginningDto + { + [Required] + public Guid ProfileId { get; set; } = Guid.Empty; + + [Required] + public Guid LeaveTypeId { get; set; } = Guid.Empty; + + [Required, Comment("ปีงบประมาณ")] + public int LeaveYear { get; set; } = 0; + + [Required, Comment("จำนวนวันลายกมา")] + public double LeaveDays { get; set; } = 0.0; + } + + public class ScheduleUpdateDnaDto + { + [Required] + public Guid ProfileId { get; set; } = Guid.Empty; + + // [Required, Comment("ปีงบประมาณ")] + // public int LeaveYear { get; set; } = 0; + + public Guid? RootDnaId { get; set; } + public Guid? Child1DnaId { get; set; } + public Guid? Child2DnaId { get; set; } + public Guid? Child3DnaId { get; set; } + public Guid? Child4DnaId { get; set; } } } diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/CreateLeaveProcessJobDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/CreateLeaveProcessJobDto.cs new file mode 100644 index 00000000..ae4aacc4 --- /dev/null +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/CreateLeaveProcessJobDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest +{ + /// + /// ข้อมูลสำหรับสร้าง Job ประมวลผลวันลา โดยมีช่วงวันที่เริ่มต้นและสิ้นสุดของการประมวลผลวันลา + /// + public class CreateLeaveProcessJobDto + { + /// + /// วันที่เริ่มต้นของการประมวลผลวันลา + /// + public DateTime StartDate { get; set; } + + /// + /// วันที่สิ้นสุดของการประมวลผลวันลา + /// + public DateTime EndDate { get; set; } + } +} \ No newline at end of file diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestCalendarResultDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestCalendarResultDto.cs index ef895786..be03ec4c 100644 --- a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestCalendarResultDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestCalendarResultDto.cs @@ -19,5 +19,7 @@ public DateTime LeaveEndDate { get; set; } public Guid KeycloakId { get; set; } + + public double LeaveTotal { get; set; } } } diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminByIdDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminByIdDto.cs index 88dfe7da..8afa5ca1 100644 --- a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminByIdDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminByIdDto.cs @@ -147,6 +147,10 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest public List Approvers { get; set; } = new(); public Guid? KeycloakUserId { get; set; } = Guid.Empty; + + + public double LeaveDraftSummary { get; set; } = 0; + public double LeaveWaitingSummary { get; set; } = 0; } public class GetLeaveApproverDto @@ -170,5 +174,8 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest public string ApproveStatus { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty; + + public bool isAct { get; set; } = false; + public string keyId { get; set; } = string.Empty; } } diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminResultDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminResultDto.cs index 42a508ff..d723bd66 100644 --- a/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminResultDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/GetLeaveRequestForAdminResultDto.cs @@ -37,5 +37,7 @@ public bool? HajjDayStatus { get; set; } public string? ProfileType { get; set; } + + public double LeaveTotal { get; set; } } } diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/GetUserLeaveProfileResultDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/GetUserLeaveProfileResultDto.cs index 6ddc93cb..a59eab85 100644 --- a/BMA.EHR.Leave/DTOs/LeaveRequest/GetUserLeaveProfileResultDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/GetUserLeaveProfileResultDto.cs @@ -51,5 +51,10 @@ public string? CurrentProvince { get; set; } public string? CurrentZipCode { get; set; } + + public int GovAge { get; set; } = 0; + + public double LeaveDraftSummary { get; set; } = 0; + public double LeaveWaitingSummary { get; set; } = 0; } } diff --git a/BMA.EHR.Leave/DTOs/LeaveRequest/LeaveRequestApproverDto.cs b/BMA.EHR.Leave/DTOs/LeaveRequest/LeaveRequestApproverDto.cs index 21c2a216..a542d393 100644 --- a/BMA.EHR.Leave/DTOs/LeaveRequest/LeaveRequestApproverDto.cs +++ b/BMA.EHR.Leave/DTOs/LeaveRequest/LeaveRequestApproverDto.cs @@ -27,5 +27,21 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest [JsonProperty("keycloakId")] public Guid KeycloakId { get; set; } = Guid.Empty; + + [JsonProperty("positionLeaveName")] + public string PositionLeaveName { get; set; } = string.Empty; + + [JsonProperty("posExecutiveName")] + public string PosExecutiveName { get; set; } = string.Empty; + + [JsonProperty("organizationName")] + public string OrganizationName { get; set; } = string.Empty; + + [JsonProperty("isAct")] + public bool isAct { get; set; } = false; + + [JsonProperty("keyId")] + public string keyId { get; set; } = string.Empty; + } } diff --git a/BMA.EHR.Leave/Program.cs b/BMA.EHR.Leave/Program.cs index 7ff93507..9d42133e 100644 --- a/BMA.EHR.Leave/Program.cs +++ b/BMA.EHR.Leave/Program.cs @@ -23,6 +23,7 @@ using Hangfire.Common; using BMA.EHR.Application.Repositories.Leaves.TimeAttendants; using BMA.EHR.Leave.Service.Extensions; using BMA.EHR.Leave.Service.Services; +using BMA.EHR.Leave.Services; var builder = WebApplication.CreateBuilder(args); // ตั้ง TimeZone เป็น Asia/Bangkok ในโค้ด @@ -95,8 +96,16 @@ builder.Services.AddLeaveApplication(); builder.Services.AddPersistence(builder.Configuration); builder.Services.AddLeavePersistence(builder.Configuration); builder.Services.AddTransient(); +builder.Services.AddTransient(); +// Configure HttpClient with increased timeout for long-running operations (e.g., RabbitMQ Management API) builder.Services.AddHttpClient(); +builder.Services.AddTransient(sp => +{ + var httpClient = sp.GetRequiredService().CreateClient(); + httpClient.Timeout = TimeSpan.FromMinutes(10); // Set timeout to 10 minutes + return httpClient; +}); builder.Services.AddControllers(options => { @@ -112,7 +121,7 @@ builder.Services.AddHealthChecks(); builder.Services.AddRabbitMqConnectionPooling(builder.Configuration); // Add Hangfire services. -var defaultConnection = builder.Configuration.GetConnectionString("DefaultConnection"); +var hangfireConnection = builder.Configuration.GetConnectionString("defaultConnection"); builder.Services.AddHangfire(configuration => configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) @@ -120,19 +129,24 @@ builder.Services.AddHangfire(configuration => configuration .UseRecommendedSerializerSettings() .UseStorage( new MySqlStorage( - defaultConnection, + hangfireConnection, new MySqlStorageOptions { - TransactionIsolationLevel = IsolationLevel.ReadCommitted, QueuePollInterval = TimeSpan.FromSeconds(15), JobExpirationCheckInterval = TimeSpan.FromHours(1), CountersAggregateInterval = TimeSpan.FromMinutes(5), PrepareSchemaIfNecessary = true, DashboardJobListLimit = 50000, TransactionTimeout = TimeSpan.FromMinutes(1), - TablesPrefix = "Hangfire" + InvisibilityTimeout = TimeSpan.FromHours(3), + TablesPrefix = "Hangfire_Leave" }))); -builder.Services.AddHangfireServer(); +builder.Services.AddHangfireServer(options => + { + options.ServerName = "Leave-Server"; // ← ระบุชื่อ server + options.WorkerCount = 5; // ← + options.Queues = new[] { "leave","default" }; // ← worker จะรันเฉพาะ queue "leave" + }); var app = builder.Build(); @@ -181,6 +195,15 @@ var manager = new RecurringJobManager(); if (manager != null) { manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression(x => x.UpdateUserDutyTime()), "0 1 * * *", bangkokTimeZone); + // ทำความสะอาดข้อมูล CheckIn Job Status ที่เก่ากว่า 30 วัน - รันทุกวันเวลา 02:00 น. + manager.AddOrUpdate("ทำความสะอาดข้อมูล CheckIn Job Status", Job.FromExpression(x => x.CleanupOldJobsAsync(30)), "0 2 * * *", bangkokTimeZone); + + manager.AddOrUpdate("ประมวลผลงานที่ค้างอยู่ในสถานะ Pending หรือ Processing", Job.FromExpression(x => x.ProcessPendingJobsAsync()), "0 3 * * *", + new RecurringJobOptions + { + TimeZone = bangkokTimeZone, + QueueName = "leave" // ← กำหนด queue + }); } // apply migrations diff --git a/BMA.EHR.Leave/Services/NotificationService.cs b/BMA.EHR.Leave/Services/NotificationService.cs new file mode 100644 index 00000000..3ada008e --- /dev/null +++ b/BMA.EHR.Leave/Services/NotificationService.cs @@ -0,0 +1,58 @@ +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System.Net.Http.Headers; +using System.Text; + +namespace BMA.EHR.Leave.Services; + +public class NotificationService +{ + private readonly IHttpClientFactory _httpClientFactory; + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + + private const string NotifyEndpoint = "https://hrmsbkk.case-collection.com/api/v1/org/through-socket/notify-from-token"; + + public NotificationService(IHttpClientFactory httpClientFactory, ILogger logger, IConfiguration configuration) + { + _httpClientFactory = httpClientFactory; + _logger = logger; + _configuration = configuration; + } + + public async Task SendNotificationAsync(string? token, bool error, string message) + { + if (string.IsNullOrEmpty(token)) + { + _logger.LogWarning("Cannot send import notification: token is null or empty."); + return; + } + + try + { + var client = _httpClientFactory.CreateClient("default"); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + + var payload = new + { + error, + message + }; + + var json = JsonConvert.SerializeObject(payload); + var content = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = await client.PostAsync(NotifyEndpoint, content); + + if (!response.IsSuccessStatusCode) + { + var responseBody = await response.Content.ReadAsStringAsync(); + _logger.LogWarning("Import notification failed with status {StatusCode}: {Body}", response.StatusCode, responseBody); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to send import notification: {Message}", ex.Message); + } + } +} diff --git a/BMA.EHR.Leave/appsettings.json b/BMA.EHR.Leave/appsettings.json index e1bb5d10..7c098db0 100644 --- a/BMA.EHR.Leave/appsettings.json +++ b/BMA.EHR.Leave/appsettings.json @@ -9,8 +9,8 @@ } }, "ElasticConfiguration": { - "Uri": "http://192.168.1.40:9200", - "IndexFormat": "bma-ehr-log-index", + "Uri": "http://192.168.1.63:9200", + "IndexFormat": "hrms-log-index", "SystemName": "leave" }, "AllowedHosts": "*", @@ -19,20 +19,19 @@ // "ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", // "LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" - "DefaultConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "ExamConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "LeaveConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "DefaultConnection": "Server=192.168.1.63;User ID=root;Password=12345678;Port=3306;Database=hrms;Allow User Variables=True;Convert Zero Datetime=True;Pooling=True;", + "ExamConnection": "Server=192.168.1.63;User ID=root;Password=12345678;Port=3306;Database=hrms_exam;Allow User Variables=True;Convert Zero Datetime=True;Pooling=True;", + "LeaveConnection": "Server=192.168.1.63;User ID=root;Password=12345678;Port=3306;Database=hrms_leave;Allow User Variables=True;Convert Zero Datetime=True;Pooling=True;" - //"DefaultConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - //"ExamConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - //"LeaveConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + // "DefaultConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;", + // "ExamConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;", + // "LeaveConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;" }, "Jwt": { - //"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", "Key": "j7C9RO_p4nRtuwCH4z9Db_A_6We42tkD_p4lZtDrezc", "Issuer": "https://hrmsbkk-id.case-collection.com/realms/hrms" - //"Key": "xY2VR-EFvvNPsMs39u8ooVBWQL6mPwrNJOh3koJFTgU", - //"Issuer": "https://hrms-id.bangkok.go.th/realms/hrms" + // "Key": "xY2VR-EFvvNPsMs39u8ooVBWQL6mPwrNJOh3koJFTgU", + // "Issuer": "https://hrms-id.bangkok.go.th/realms/hrms" }, "EPPlus": { "ExcelPackage": { @@ -53,8 +52,13 @@ "Host": "192.168.1.63", "User": "admin", "Password": "12345678", - "Queue": "hrms-checkin-queue", + "Queue": "hrms-checkin-queue-dev", "URL": "http://192.168.1.63:9122/api/queues/%2F/" + // "Host": "172.27.17.68", + // "User": "admin", + // "Password": "admin123456", + // "Queue": "hrms-checkin-queue", + // "URL": "http://172.27.17.68:9122/api/queues/%2F/" }, "Mail": { "Server": "mail.bangkok.go.th", @@ -68,7 +72,10 @@ "API": "https://hrmsbkk.case-collection.com/api/v1", "APIV2": "https://hrmsbkk.case-collection.com/api/v2", "VITE_URL_MGT": "https://hrmsbkk-mgt.case-collection.com", - //"API": "https://bma-ehr.frappet.synology.me/api/v1", - //"API": "https://bma-hrms.bangkok.go.th/api/v1", + // "Domain": "https://hrms-exam.bangkok.go.th", + // "APIPROBATION": "https://hrms.bangkok.go.th/api/v1/probation", + // "API": "https://hrms.bangkok.go.th/api/v1", + // "APIV2": "https://hrms.bangkok.go.th/api/v2", + // "VITE_URL_MGT": "https://hrms-mgt.bangkok.go.th", "API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz" } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index a98abb74..ff010a2a 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -112,7 +112,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -239,11 +239,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementAppointments = placementAppointments .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - placementAppointments = placementAppointments - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementAppointments = placementAppointments + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { placementAppointments = placementAppointments.Where(x => diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index ae8e40ac..971cd526 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -110,7 +110,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -232,11 +232,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementAppointments = placementAppointments .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - placementAppointments = placementAppointments - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementAppointments = placementAppointments + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { placementAppointments = placementAppointments.Where(x => diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 62b9bbce..39b7fc63 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -62,9 +62,9 @@ namespace BMA.EHR.Placement.Service.Controllers #region " Properties " private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; - private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"]; + //private bool isSuperAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("SUPER_ADMIN") ?? false; #endregion @@ -140,6 +140,7 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> GetExamByPlacement(Guid examId) { var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(examId.ToString(), "SYS_PLACEMENT_PASS"); + var role = string.Empty; if (getWorkflow == false) { var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_PLACEMENT_PASS"); @@ -148,6 +149,7 @@ namespace BMA.EHR.Placement.Service.Controllers { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } + role = jsonData["result"]?.ToString(); } var rootId = ""; @@ -155,6 +157,7 @@ namespace BMA.EHR.Placement.Service.Controllers var child2Id = ""; var child3Id = ""; var child4Id = ""; + var rootDnaId = ""; var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position-act"; using (var client = new HttpClient()) { @@ -166,18 +169,19 @@ namespace BMA.EHR.Placement.Service.Controllers if (_res.IsSuccessStatusCode) { var org = JsonConvert.DeserializeObject(_result); - if (org.result.isOfficer == false) + if (org.result.isOfficer == false && role?.Trim().ToUpper() != "OWNER") { rootId = org.result.rootId == null ? "" : org.result.rootId; // child1Id = org.result.child1Id == null ? "" : org.result.child1Id; // child2Id = org.result.child2Id == null ? "" : org.result.child2Id; // child3Id = org.result.child3Id == null ? "" : org.result.child3Id; // child4Id = org.result.child4Id == null ? "" : org.result.child4Id; + rootDnaId = org.result.rootDnaId == null ? "" : org.result.rootDnaId; var data1 = await _context.PlacementProfiles .Where(x => x.Placement.Id == examId) .Where(x => x.Draft == true) .Where(x => x.PlacementStatus != "UN-CONTAIN") - .Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))) + .Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))) .Select(x => new { Id = x.Id, @@ -300,7 +304,7 @@ namespace BMA.EHR.Placement.Service.Controllers } return Success(result1); } - if (org.result.isOfficer == true) + if (org.result.isOfficer == true || role?.Trim().ToUpper() == "OWNER") { var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new { @@ -688,12 +692,20 @@ namespace BMA.EHR.Placement.Service.Controllers public async Task> GetDashboardByPlacement(Guid examId) { + var role = string.Empty; + var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_PLACEMENT_PASS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() == "200") + { + role = jsonData["result"]?.ToString(); + } var rootId = ""; var child1Id = ""; var child2Id = ""; var child3Id = ""; var child4Id = ""; + var rootDnaId = ""; var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position-act"; using (var client = new HttpClient()) { @@ -706,30 +718,31 @@ namespace BMA.EHR.Placement.Service.Controllers if (_res.IsSuccessStatusCode) { var org = JsonConvert.DeserializeObject(_result); - if (org.result.isOfficer == false) + if (org.result.isOfficer == false && role?.Trim().ToUpper() != "OWNER") { rootId = org.result.rootId == null ? "" : org.result.rootId; // child1Id = org.result.child1Id == null ? "" : org.result.child1Id; // child2Id = org.result.child2Id == null ? "" : org.result.child2Id; // child3Id = org.result.child3Id == null ? "" : org.result.child3Id; // child4Id = org.result.child4Id == null ? "" : org.result.child4Id; + rootDnaId = org.result.rootDnaId == null ? "" : org.result.rootDnaId; var placement = await _context.Placements .Where(x => x.Id == examId) .Select(x => new { - Total = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Count(), - UnContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(), - PrepareContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(), - Report = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "REPORT").Count(), - Done = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DONE").Count(), - Disclaim = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(), + Total = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Count(), + UnContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(), + PrepareContain = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(), + Report = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "REPORT").Count(), + Done = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DONE").Count(), + Disclaim = x.PlacementProfiles.Where(x => x.Draft == true).Where(x => rootDnaId == "" ? true : (child1Id == "" ? x.rootDnaId == rootDnaId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))).Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(), }).FirstOrDefaultAsync(); if (placement == null) return Error(GlobalMessages.DataNotFound, 404); return Success(placement); } - if (org.result.isOfficer == true) + if (org.result.isOfficer == true || role?.Trim().ToUpper() == "OWNER") { var placement = await _context.Placements .Where(x => x.Id == examId) @@ -848,6 +861,91 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// API อัพเดทสถานะเป็นบรรจุ + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("pass/update-status")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PersonUpdateStatus([FromBody] PersonUpdateStatusRequest req) + { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_PLACEMENT_PASS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + string role = jsonData["result"]?.ToString(); + if (role != "OWNER") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + + var person = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == req.PersonalId); + if (person == null) + return Error(GlobalMessages.DataNotFound, 404); + + person.PlacementStatus = "DONE"; + person.LastUpdateFullName = FullName ?? "System Administrator"; + person.LastUpdateUserId = UserId ?? ""; + person.LastUpdatedAt = DateTime.Now; + + await _context.SaveChangesAsync(); + + return Success(); + } + + /// + /// API สำหรับยกเลิกการส่งตัว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("update/draft-status")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> PersonUpdateDraftStatus([FromBody] PersonUpdateStatusRequest req) + { + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_PLACEMENT_PASS"); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + + string role = jsonData["result"]?.ToString(); + if (role != "OWNER") + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + + var person = await _context.PlacementProfiles + .FirstOrDefaultAsync(x => x.Id == req.PersonalId); + if (person == null) + return Error(GlobalMessages.DataNotFound, 404); + + if (person.PlacementStatus == "REPORT") + return Error("ไม่สามารถยกเลิกการส่งตัวได้ เนื่องจากส่งไปออกคำสั่งแล้ว"); + + if (person.PlacementStatus == "DONE") + return Error("ไม่สามารถยกเลิกการส่งตัวได้ เนื่องจากบรรจุไปแล้ว"); + + person.Draft = false; + person.LastUpdateFullName = FullName ?? "System Administrator"; + person.LastUpdateUserId = UserId ?? ""; + person.LastUpdatedAt = DateTime.Now; + await _context.SaveChangesAsync(); + return Success(); + } + [HttpGet("pass/deferment/{personalId:length(36)}")] public async Task> GetPersonDeferment(Guid personalId) { @@ -1745,7 +1843,7 @@ namespace BMA.EHR.Placement.Service.Controllers isLeave = false, dateRetire = (DateTime?)null, dateAppoint = r.commandDateAffect, - dateStart = r.commandDateAffect, + dateStart = p.ReportingDate, govAgeAbsent = 0, govAgePlus = 0, birthDate = (p.DateOfBirth == null || p.DateOfBirth == DateTime.MinValue) ? (DateTime?)null : p.DateOfBirth, @@ -1947,7 +2045,7 @@ namespace BMA.EHR.Placement.Service.Controllers .Where(x => req.refIds.Contains(x.Id.ToString())) // .Where(x => x.PlacementStatus.ToUpper() == "REPORT") .ToListAsync(); - placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAI"); + placementProfiles.ForEach(profile => profile.PlacementStatus = "PREPARE-CONTAIN"); await _context.SaveChangesAsync(); return Success(); } @@ -2443,6 +2541,11 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementProfiles .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -2492,12 +2595,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.PlacementStatus = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.PlacementStatus = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -2679,6 +2782,11 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementProfiles .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -2728,12 +2836,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.PlacementStatus = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.PlacementStatus = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } @@ -2900,6 +3008,11 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementProfiles .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.PlacementStatus = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -2949,12 +3062,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.PlacementStatus = "DONE"); - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// data.ForEach(profile => profile.PlacementStatus = "DONE"); + //// await _context.SaveChangesAsync(); + //// } } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs index 8638291e..e05f03f3 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementOfficerController.cs @@ -111,7 +111,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -193,11 +193,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementOfficers = placementOfficers .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - placementOfficers = placementOfficers - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementOfficers = placementOfficers + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { placementOfficers = placementOfficers.Where(x => @@ -223,7 +223,8 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpGet("keycloak")] public async Task> GetListByKeycloak() { - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + // var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -757,6 +758,17 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementOfficers .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + var firstRef = req.refIds.FirstOrDefault(); + var commandNoText = firstRef != null ? $"{firstRef.commandNo}/{firstRef.commandYear.ToThaiYear()}" : null; + foreach (var profile in data) + { + profile.Status = "DONE"; + profile.commandNo = commandNoText; + } + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -808,17 +820,16 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - //data.ForEach(profile => profile.Status = "DONE"); - foreach (var profile in data) - { - profile.Status = "DONE"; - profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null; - } - await _context.SaveChangesAsync(); - } + //// var _result = await _res.Content.ReadAsStringAsync(); + //// if (_res.IsSuccessStatusCode) + //// { + //// foreach (var profile in data) + //// { + //// profile.Status = "DONE"; + //// profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null; + //// } + //// await _context.SaveChangesAsync(); + //// } } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index f18e2b32..68634c78 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -112,7 +112,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -129,6 +129,7 @@ namespace BMA.EHR.Placement.Service.Controllers { p.Id, p.prefix, + p.rank, p.firstName, p.lastName, p.citizenId, @@ -231,11 +232,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementReceives = placementReceives .Where(x => (x.rootDnaId == nodeId) || (x.CreatedUserId == UserId)).ToList(); } - else if (role == "PARENT") - { - placementReceives = placementReceives - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementReceives = placementReceives + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { placementReceives = placementReceives.Where(x => @@ -280,6 +281,7 @@ namespace BMA.EHR.Placement.Service.Controllers // ProfileId = p.Profile.Id, p.citizenId, p.prefix, + p.rank, p.firstName, p.lastName, p.DateOfBirth, @@ -377,6 +379,7 @@ namespace BMA.EHR.Placement.Service.Controllers // data.ProfileId, data.citizenId, data.prefix, + data.rank, data.firstName, data.lastName, data.DateOfBirth, @@ -484,6 +487,7 @@ namespace BMA.EHR.Placement.Service.Controllers // Profile = profile, citizenId = req.citizenId, prefix = req.prefix, + rank = req.rank, firstName = req.firstName, lastName = req.lastName, DateOfBirth = req.BirthDate, @@ -553,18 +557,23 @@ namespace BMA.EHR.Placement.Service.Controllers // placementReceive.citizenId = org.result.citizenId; placementReceive.rootOld = org.result.root; placementReceive.rootOldId = org.result.rootId; + placementReceive.rootDnaId = org.result.rootDnaId; placementReceive.rootShortNameOld = org.result.rootShortName; placementReceive.child1Old = org.result.child1; placementReceive.child1OldId = org.result.child1Id; + placementReceive.child1DnaId = org.result.child1DnaId; placementReceive.child1ShortNameOld = org.result.child1ShortName; placementReceive.child2Old = org.result.child2; placementReceive.child2OldId = org.result.child2Id; + placementReceive.child2DnaId = org.result.child2DnaId; placementReceive.child2ShortNameOld = org.result.child2ShortName; placementReceive.child3Old = org.result.child3; placementReceive.child3OldId = org.result.child3Id; + placementReceive.child4DnaId = org.result.child4DnaId; placementReceive.child3ShortNameOld = org.result.child3ShortName; placementReceive.child4Old = org.result.child4; placementReceive.child4OldId = org.result.child4Id; + placementReceive.child4DnaId = org.result.child4DnaId; placementReceive.child4ShortNameOld = org.result.child4ShortName; placementReceive.posMasterNoOld = org.result.posMasterNo; placementReceive.posTypeOldId = org.result.posTypeId; @@ -847,6 +856,7 @@ namespace BMA.EHR.Placement.Service.Controllers uppdated.Gender = req.Gender; uppdated.citizenId = req.citizenId; uppdated.prefix = req.prefix; + uppdated.rank = req.rank; uppdated.firstName = req.firstName; uppdated.lastName = req.lastName; uppdated.DateOfBirth = req.DateOfBirth; @@ -1119,6 +1129,10 @@ namespace BMA.EHR.Placement.Service.Controllers .Include(x => x.Avatar) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1126,7 +1140,7 @@ namespace BMA.EHR.Placement.Service.Controllers { bodyProfile = new { - rank = string.Empty, + rank = string.IsNullOrEmpty(p.rank) ? string.Empty : p.rank, prefix = p.prefix == null ? string.Empty : p.prefix, firstName = p.firstName == null ? string.Empty : p.firstName, lastName = p.lastName == null ? string.Empty : p.lastName, @@ -1208,7 +1222,6 @@ namespace BMA.EHR.Placement.Service.Controllers }).ToList(); var baseAPIOrg = _configuration["API"]; - //var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current"; var apiUrlOrg = $"{_configuration["API"]}/org/command/excexute/create-officer-profile"; using (var client = new HttpClient()) { @@ -1218,12 +1231,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs index 45798f6c..26da4786 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRepatriationController.cs @@ -112,7 +112,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -198,11 +198,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementRepatriations = placementRepatriations .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - placementRepatriations = placementRepatriations - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementRepatriations = placementRepatriations + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { placementRepatriations = placementRepatriations.Where(x => @@ -623,6 +623,10 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementRepatriations .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -675,12 +679,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs index 566b799b..d7e62306 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementTransferController.cs @@ -79,7 +79,8 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpGet("user")] public async Task> GetListByProfile() { - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + // var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -204,7 +205,7 @@ namespace BMA.EHR.Placement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -284,11 +285,11 @@ namespace BMA.EHR.Placement.Service.Controllers placementTransfers = placementTransfers .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - placementTransfers = placementTransfers - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // placementTransfers = placementTransfers + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { placementTransfers = placementTransfers.Where(x => @@ -574,6 +575,145 @@ namespace BMA.EHR.Placement.Service.Controllers LastUpdatedAt = DateTime.Now, }; var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + bool isDeputy = false; + 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(_result); + + if (org == null || org.result == null) + return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); + + isDeputy = org.result.isDeputy.HasValue ? org.result.isDeputy.Value : false; + + placementTransfer.profileId = org.result.profileId; + placementTransfer.prefix = org.result.prefix; + placementTransfer.firstName = org.result.firstName; + placementTransfer.lastName = org.result.lastName; + placementTransfer.citizenId = org.result.citizenId; + placementTransfer.rootOld = org.result.root; + placementTransfer.rootOldId = org.result.rootId; + placementTransfer.rootDnaOldId = org.result.rootDnaId; + placementTransfer.rootShortNameOld = org.result.rootShortName; + placementTransfer.child1Old = org.result.child1; + placementTransfer.child1OldId = org.result.child1Id; + placementTransfer.child1DnaOldId = org.result.child1DnaId; + placementTransfer.child1ShortNameOld = org.result.child1ShortName; + placementTransfer.child2Old = org.result.child2; + placementTransfer.child2OldId = org.result.child2Id; + placementTransfer.child2DnaOldId = org.result.child2DnaId; + placementTransfer.child2ShortNameOld = org.result.child2ShortName; + placementTransfer.child3Old = org.result.child3; + placementTransfer.child3OldId = org.result.child3Id; + placementTransfer.child3DnaOldId = org.result.child3DnaId; + placementTransfer.child3ShortNameOld = org.result.child3ShortName; + placementTransfer.child4Old = org.result.child4; + placementTransfer.child4OldId = org.result.child4Id; + placementTransfer.child4DnaOldId = org.result.child4DnaId; + placementTransfer.child4ShortNameOld = org.result.child4ShortName; + placementTransfer.posMasterNoOld = org.result.posMasterNo; + placementTransfer.posTypeOldId = org.result.posTypeId; + placementTransfer.posTypeNameOld = org.result.posTypeName; + placementTransfer.posLevelOldId = org.result.posLevelId; + placementTransfer.posLevelNameOld = org.result.posLevelName; + placementTransfer.AmountOld = org.result.salary; + placementTransfer.PositionOld = org.result.position; + placementTransfer.PositionExecutiveOld = org.result.posExecutiveName; + placementTransfer.positionExecutiveFieldOld = org.result.positionExecutiveField; + placementTransfer.positionAreaOld = org.result.positionArea; + placementTransfer.PositionLevelOld = org.result.posLevelName; + placementTransfer.PositionTypeOld = org.result.posTypeName; + placementTransfer.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo; + placementTransfer.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") + + (org.result.child3 == null ? "" : org.result.child3 + "\n") + + (org.result.child2 == null ? "" : org.result.child2 + "\n") + + (org.result.child1 == null ? "" : org.result.child1 + "\n") + + (org.result.root == null ? "" : org.result.root); + placementTransfer.OrganizationPositionOld = org.result.position + "\n" + + (placementTransfer.PositionExecutiveOld == null ? "" : (placementTransfer.positionExecutiveField == null ? placementTransfer.PositionExecutiveOld + "\n" : placementTransfer.PositionExecutiveOld + "(" + placementTransfer.positionExecutiveField + ")" + "\n")) + + placementTransfer.OrganizationOld; + } + await _context.PlacementTransfers.AddAsync(placementTransfer); + await _context.SaveChangesAsync(); + if (Request.Form.Files != null && Request.Form.Files.Count != 0) + { + foreach (var file in Request.Form.Files) + { + var fileExtension = Path.GetExtension(file.FileName); + + var doc = await _documentService.UploadFileAsync(file, file.FileName); + var _doc = await _context.Documents.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == doc.Id); + if (_doc != null) + { + var placementTransferDoc = new PlacementTransferDoc + { + PlacementTransfer = placementTransfer, + Document = _doc, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + await _context.PlacementTransferDocs.AddAsync(placementTransferDoc); + + } + } + } + + var baseAPIOrg = _configuration["API"]; + var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + var _res = await client.PostAsJsonAsync(apiUrlOrg, new + { + refId = placementTransfer.Id, + sysName = "SYS_TRANSFER_REQ", + posLevelName = placementTransfer.posLevelNameOld, + posTypeName = placementTransfer.posTypeNameOld, + fullName = $"{placementTransfer.prefix}{placementTransfer.firstName} {placementTransfer.lastName}", + isDeputy = isDeputy + }); + } + await _context.SaveChangesAsync(); + + return Success(placementTransfer.Id); + } + + /// + /// สร้างคำขอโอน โดย admin + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("admin")] + public async Task> PostAdmin([FromForm] PlacementTransferAdminRequest req) + { + var placementTransfer = new PlacementTransfer + { + Organization = req.Organization, + Reason = req.Reason, + Status = "APPROVE", + Date = req.Date, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.ProfileId}"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -663,21 +803,22 @@ namespace BMA.EHR.Placement.Service.Controllers } } } - var baseAPIOrg = _configuration["API"]; - var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - refId = placementTransfer.Id, - sysName = "SYS_TRANSFER_REQ", - posLevelName = placementTransfer.posLevelNameOld, - posTypeName = placementTransfer.posTypeNameOld, - fullName = $"{placementTransfer.prefix}{placementTransfer.firstName} {placementTransfer.lastName}" - }); - } + + //var baseAPIOrg = _configuration["API"]; + //var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow"; + //using (var client = new HttpClient()) + //{ + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // refId = placementTransfer.Id, + // sysName = "SYS_TRANSFER_REQ", + // posLevelName = placementTransfer.posLevelNameOld, + // posTypeName = placementTransfer.posTypeNameOld, + // fullName = $"{placementTransfer.prefix}{placementTransfer.firstName} {placementTransfer.lastName}" + // }); + //} await _context.SaveChangesAsync(); return Success(placementTransfer.Id); @@ -953,6 +1094,10 @@ namespace BMA.EHR.Placement.Service.Controllers var data = await _context.PlacementTransfers .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -1005,12 +1150,12 @@ namespace BMA.EHR.Placement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } diff --git a/BMA.EHR.Placement.Service/Requests/OrgRequest.cs b/BMA.EHR.Placement.Service/Requests/OrgRequest.cs index 817c583f..c943bc53 100644 --- a/BMA.EHR.Placement.Service/Requests/OrgRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/OrgRequest.cs @@ -52,6 +52,7 @@ namespace BMA.EHR.Placement.Service.Requests public string? education { get; set; } public double? Amount { get; set; } public string? avatarUrl { get; set; } + public bool? isDeputy { get; set; } } } \ No newline at end of file diff --git a/BMA.EHR.Placement.Service/Requests/OrgRequestAct.cs b/BMA.EHR.Placement.Service/Requests/OrgRequestAct.cs index dace91d3..6189eaf4 100644 --- a/BMA.EHR.Placement.Service/Requests/OrgRequestAct.cs +++ b/BMA.EHR.Placement.Service/Requests/OrgRequestAct.cs @@ -15,5 +15,6 @@ namespace BMA.EHR.Placement.Service.Requests public string? child2Id { get; set; } public string? child3Id { get; set; } public string? child4Id { get; set; } + public string? rootDnaId { get; set; } } } \ No newline at end of file diff --git a/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs new file mode 100644 index 00000000..aef70fb5 --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/PersonUpdateStatusRequest.cs @@ -0,0 +1,10 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class PersonUpdateStatusRequest + { + public Guid PersonalId { get; set; } + } +} diff --git a/BMA.EHR.Placement.Service/Requests/PlacementReceiveEditRequest.cs b/BMA.EHR.Placement.Service/Requests/PlacementReceiveEditRequest.cs index 7c1cb172..cafc0ad9 100644 --- a/BMA.EHR.Placement.Service/Requests/PlacementReceiveEditRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/PlacementReceiveEditRequest.cs @@ -6,7 +6,8 @@ namespace BMA.EHR.Placement.Service.Requests public class PlacementReceiveEditRequest { public string citizenId { get; set; } - public string prefix { get; set; } + public string? prefix { get; set; } + public string? rank { get; set; } public string firstName { get; set; } public string lastName { get; set; } public DateTime DateOfBirth { get; set; } diff --git a/BMA.EHR.Placement.Service/Requests/PlacementReceiveRequest.cs b/BMA.EHR.Placement.Service/Requests/PlacementReceiveRequest.cs index b546c1f3..49563324 100644 --- a/BMA.EHR.Placement.Service/Requests/PlacementReceiveRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/PlacementReceiveRequest.cs @@ -6,7 +6,9 @@ namespace BMA.EHR.Placement.Service.Requests public class PlacementReceiveRequest { public string citizenId { get; set; } - public string prefix { get; set; } + + public string? prefix { get; set; } + public string? rank { get; set; } public string firstName { get; set; } public string lastName { get; set; } public DateTime BirthDate { get; set; } diff --git a/BMA.EHR.Placement.Service/Requests/PlacementTransferRequest.cs b/BMA.EHR.Placement.Service/Requests/PlacementTransferRequest.cs index 7f740043..6611f92c 100644 --- a/BMA.EHR.Placement.Service/Requests/PlacementTransferRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/PlacementTransferRequest.cs @@ -10,4 +10,13 @@ namespace BMA.EHR.Placement.Service.Requests public DateTime? Date { get; set; } public List? File { get; set; } } + + public class PlacementTransferAdminRequest + { + public string ProfileId { get; set; } + public string Organization { get; set; } + public string Reason { get; set; } + public DateTime? Date { get; set; } + public List? File { get; set; } + } } diff --git a/BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj b/BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj index 255f2a75..6a820e15 100644 --- a/BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj +++ b/BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj @@ -40,10 +40,17 @@ + + + + PreserveNewest + + + diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index 74f217a2..b7a8b8df 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -7,6 +7,7 @@ using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using BMA.EHR.Infrastructure.Persistence; using BMA.EHR.Retirement.Service.Requests; +using BMA.EHR.Retirement.Service.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -37,6 +38,7 @@ namespace BMA.EHR.Retirement.Service.Controllers private readonly PermissionRepository _permission; private readonly DisciplineDbContext _contextDiscipline; private readonly RetireReportRepository _service; + private readonly RetirementReportService _reportService; public RetirementController(RetirementRepository repository, NotificationRepository repositoryNoti, ApplicationDBContext context, @@ -46,7 +48,8 @@ namespace BMA.EHR.Retirement.Service.Controllers IHttpContextAccessor httpContextAccessor, PermissionRepository permission, DisciplineDbContext contextDiscipline, - RetireReportRepository service) + RetireReportRepository service, + RetirementReportService reportService) { _repository = repository; _repositoryNoti = repositoryNoti; @@ -58,6 +61,7 @@ namespace BMA.EHR.Retirement.Service.Controllers _permission = permission; _contextDiscipline = contextDiscipline; _service = service; + _reportService = reportService; } #region " Properties " @@ -1306,12 +1310,20 @@ namespace BMA.EHR.Retirement.Service.Controllers { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } + + // แยกดึงข้อมูลเพื่อลดภาระ Database var retire = await _context.RetirementPeriods - .Include(x => x.RetirementProfiles) - .Include(x => x.RetirementRawProfiles) + //.Include(x => x.RetirementProfiles) + //.Include(x => x.RetirementRawProfiles) .FirstOrDefaultAsync(x => x.Id == retireId); + if (retire == null) return Error(GlobalMessages.RetirementNotFound, 404); + + // โหลดข้อมูลลูกแยกกัน + var profiles = await _context.RetirementProfiles.Where(x => x.RetirementPeriod.Id == retireId).ToListAsync(); + var rawProfiles = await _context.RetirementRawProfiles.Where(x => x.RetirementPeriod.Id == retireId).ToListAsync(); + if (Request.Form.Files != null && Request.Form.Files.Count != 0) { var file = Request.Form.Files[0]; @@ -1366,7 +1378,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } var order = 1; - foreach (var profile in retire.RetirementProfiles + foreach (var profile in profiles .OrderBy(x => string.IsNullOrEmpty(x.root) ? int.MaxValue : rootOrder.ToObject>().IndexOf(x.root)) .ThenBy(x => child1Order.ToObject>().IndexOf(x.child1 ?? "")) .ThenBy(x => child2Order.ToObject>().IndexOf(x.child2 ?? "")) @@ -1381,7 +1393,7 @@ namespace BMA.EHR.Retirement.Service.Controllers } order = 1; - foreach (var profile in retire.RetirementRawProfiles + foreach (var profile in rawProfiles .OrderBy(x => string.IsNullOrEmpty(x.root) ? int.MaxValue : rootOrder.ToObject>().IndexOf(x.root)) .ThenBy(x => child1Order.ToObject>().IndexOf(x.child1 ?? "")) .ThenBy(x => child2Order.ToObject>().IndexOf(x.child2 ?? "")) @@ -2205,5 +2217,83 @@ namespace BMA.EHR.Retirement.Service.Controllers } } #endregion + + #region รายงานรายชื่อผู้เกษียณอายุราชการ ข้าราชการ & ลูกจ้างประจำ + /// + /// รายงานรายชื่อผู้เกษียณอายุราชการ ข้าราชการ & ลูกจ้างประจำ + /// + /// Id ของรอบเกษียณ + /// pdf, docx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("report/{exportType}/{Id}")] + public async Task> GetReportProfileRetirement([FromRoute] Guid Id, string exportType = "pdf") + { + var retire = await _service.GetProfileRetirementdAsync(Id, token); + if (retire != null) + { + var reportfile = string.Empty; + exportType = exportType.Trim(); + + switch (retire.GetType().GetProperty("Type").GetValue(retire)) + { + case "OFFICER": + if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire))) + { + reportfile = $"retire-1"; + } + else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT") + { + reportfile = $"retire-2"; + } + else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE") + { + reportfile = $"retire-3"; + } + else + { + return Error(retire.GetType().GetProperty("TypeReport").GetValue(retire)); + } + break; + case "EMPLOYEE": + if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire))) + { + reportfile = $"retire-emp-1"; + } + else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT") + { + reportfile = $"retire-emp-2"; + } + else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE") + { + reportfile = $"retire-emp-3"; + } + else + { + return Error(retire.GetType().GetProperty("TypeReport").GetValue(retire)); + } + break; + default: + return Error(retire.GetType().GetProperty("Type").GetValue(retire)); + } + + var reportBytes = await _reportService.GenerateReportAsync(reportfile, retire, exportType); + + var fileName = $"reportRetirement-{DateTime.Now:yyyyMMdd-HHmmss}.{exportType}"; + var contentType = exportType.Trim().ToLower() == "pdf" + ? "application/pdf" + : "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + + return File(reportBytes, contentType, fileName); + + } + else + { + return NotFound(); + } + } + #endregion } } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 33808435..cf9f153d 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -116,7 +116,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -177,11 +177,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementDeceaseds = retirementDeceaseds .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementDeceaseds = retirementDeceaseds - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementDeceaseds = retirementDeceaseds + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { retirementDeceaseds = retirementDeceaseds.Where(x => diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index 4db9f778..588ccabe 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -112,7 +112,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -227,11 +227,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementOthers = retirementOthers .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementOthers = retirementOthers - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementOthers = retirementOthers + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementOthers = retirementOthers.Where(x => @@ -845,6 +845,10 @@ namespace BMA.EHR.Retirement.Service.Controllers var data = await _context.RetirementOthers .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -914,12 +918,12 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } @@ -1090,6 +1094,10 @@ namespace BMA.EHR.Retirement.Service.Controllers var data = await _context.RetirementOthers .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -1159,12 +1167,12 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs index e996abab..a8c9d8e2 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOutController.cs @@ -127,7 +127,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -208,11 +208,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementOuts = retirementOuts .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementOuts = retirementOuts - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementOuts = retirementOuts + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementOuts = retirementOuts.Where(x => @@ -239,16 +239,6 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpGet("{id:length(36)}")] public async Task> GetDetailAdmin(Guid id) { - var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), "SYS_DISMISS"); - if (getWorkflow == false) - { - var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISMISS"); - var jsonData = JsonConvert.DeserializeObject(getPermission); - if (jsonData["status"]?.ToString() != "200") - { - return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); - } - } var data = await _context.RetirementOuts.AsQueryable() .Where(x => x.Id == id) .Select(p => new @@ -294,6 +284,20 @@ namespace BMA.EHR.Retirement.Service.Controllers p.OrganizationOld, }) .FirstOrDefaultAsync(); + + string _system = data != null && data.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), _system); + if (getWorkflow == false) + { + var getPermission = await _permission.GetPermissionAPIAsync("GET", _system); + var jsonData = JsonConvert.DeserializeObject(getPermission); + if (jsonData["status"]?.ToString() != "200") + { + return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); + } + } + if (data == null) return Error(GlobalMessages.DataNotFound, 404); @@ -462,14 +466,18 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpPut("{id:length(36)}")] public async Task> Put([FromBody] RetirementOutEditRequest req, Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_DISMISS"); + var uppdated = await _context.RetirementOuts + .FirstOrDefaultAsync(x => x.Id == id); + + string _system = uppdated != null && uppdated.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", _system); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var uppdated = await _context.RetirementOuts - .FirstOrDefaultAsync(x => x.Id == id); + if (uppdated == null) return Error(GlobalMessages.RetirementOutNotFound, 404); @@ -527,14 +535,18 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpDelete("{id:length(36)}")] public async Task> Delete(Guid id) { - var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_DISMISS"); + var deleted = await _context.RetirementOuts.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == id); + + string _system = deleted != null && deleted.profileType?.Trim().ToUpper() == "OFFICER" ? "SYS_DISMISS" : "SYS_DISMISS_EMP"; + + var getPermission = await _permission.GetPermissionAPIAsync("DELETE", _system); var jsonData = JsonConvert.DeserializeObject(getPermission); if (jsonData["status"]?.ToString() != "200") { return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); } - var deleted = await _context.RetirementOuts.AsQueryable() - .FirstOrDefaultAsync(x => x.Id == id); + if (deleted == null) return NotFound(); _context.RetirementOuts.Remove(deleted); @@ -630,6 +642,10 @@ namespace BMA.EHR.Retirement.Service.Controllers var data = await _context.RetirementOuts .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -689,12 +705,12 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index d33b945b..ea791129 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -135,7 +135,8 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpGet("user")] public async Task> GetListByProfile() { - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + // var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -164,7 +165,7 @@ namespace BMA.EHR.Retirement.Service.Controllers p.ApproveReason, p.RejectReason, p.CancelReason, - p.Status, + status = p.RetirementResignCancels.FirstOrDefault() == null ? p.Status : p.RetirementResignCancels.FirstOrDefault().Status, statusCancel = p.RetirementResignCancels.FirstOrDefault() == null ? null : p.RetirementResignCancels.FirstOrDefault().Status, p.IsActive, }) @@ -185,7 +186,8 @@ namespace BMA.EHR.Retirement.Service.Controllers [HttpGet("user-cancel")] public async Task> GetListByProfileCancel() { - var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + // var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); @@ -269,7 +271,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -334,11 +336,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementResigns = retirementResigns .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementResigns = retirementResigns - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementResigns = retirementResigns + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementResigns = retirementResigns.Where(x => @@ -401,7 +403,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -465,11 +467,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementResigns = retirementResigns .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementResigns = retirementResigns - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementResigns = retirementResigns + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementResigns = retirementResigns.Where(x => @@ -1343,6 +1345,155 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(retirementResign); } + /// + /// สร้างการลาออก โดย admin + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("admin")] + public async Task> PostAdmin([FromForm] RetirementResignAdminRequest req) + { + var Remark = req.Remark; + if (req.Reason != null) + { + switch (req.Reason.Trim().ToUpper()) + { + case "CAREER": Remark = $"ประกอบอาชีพอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "MOVE": Remark = $"รับราชการสังกัดอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "FAMILY": Remark = $"ดูแลบิดามารดา" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "EDUCATION": Remark = $"ศึกษาต่อ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "OTHER": Remark = $"อื่น ๆ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + } + } + + var retirementResign = new RetirementResign + { + ApproveStep = "st1", + Location = req.Location, + SendDate = DateTime.Now, + ActiveDate = req.ActiveDate, + Reason = req.Reason, + ReasonResign = Remark, + Remark = req.Remark, + Status = "APPROVE", + IsActive = true, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + + var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.ProfileId}"; + 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(_result); + + if (org == null || org.result == null) + return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); + + retirementResign.profileId = org.result.profileId; + retirementResign.prefix = org.result.prefix; + retirementResign.firstName = org.result.firstName; + retirementResign.lastName = org.result.lastName; + retirementResign.citizenId = org.result.citizenId; + retirementResign.rootOld = org.result.root; + retirementResign.rootOldId = org.result.rootId; + retirementResign.rootDnaOldId = org.result.rootDnaId; + retirementResign.rootShortNameOld = org.result.rootShortName; + retirementResign.child1Old = org.result.child1; + retirementResign.child1OldId = org.result.child1Id; + retirementResign.child1DnaOldId = org.result.child1DnaId; + retirementResign.child1ShortNameOld = org.result.child1ShortName; + retirementResign.child2Old = org.result.child2; + retirementResign.child2OldId = org.result.child2Id; + retirementResign.child2DnaOldId = org.result.child2DnaId; + retirementResign.child2ShortNameOld = org.result.child2ShortName; + retirementResign.child3Old = org.result.child3; + retirementResign.child3OldId = org.result.child3Id; + retirementResign.child3DnaOldId = org.result.child3DnaId; + retirementResign.child3ShortNameOld = org.result.child3ShortName; + retirementResign.child4Old = org.result.child4; + retirementResign.child4OldId = org.result.child4Id; + retirementResign.child4DnaOldId = org.result.child4DnaId; + retirementResign.child4ShortNameOld = org.result.child4ShortName; + retirementResign.posMasterNoOld = org.result.posMasterNo; + retirementResign.posTypeOldId = org.result.posTypeId; + retirementResign.posTypeNameOld = org.result.posTypeName; + retirementResign.posLevelOldId = org.result.posLevelId; + retirementResign.posLevelNameOld = org.result.posLevelName; + retirementResign.AmountOld = org.result.salary; + retirementResign.PositionOld = org.result.position; + retirementResign.PositionExecutiveOld = org.result.posExecutiveName; + retirementResign.positionExecutiveFieldOld = org.result.positionExecutiveField; + retirementResign.positionAreaOld = org.result.positionArea; + retirementResign.PositionLevelOld = org.result.posLevelName; + retirementResign.PositionTypeOld = org.result.posTypeName; + retirementResign.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo; + retirementResign.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") + + (org.result.child3 == null ? "" : org.result.child3 + "\n") + + (org.result.child2 == null ? "" : org.result.child2 + "\n") + + (org.result.child1 == null ? "" : org.result.child1 + "\n") + + (org.result.root == null ? "" : org.result.root); + retirementResign.OrganizationPositionOld = org.result.position + "\n" + + (retirementResign.PositionExecutiveOld == null ? "" : (retirementResign.positionExecutiveField == null ? retirementResign.PositionExecutiveOld + "\n" : retirementResign.PositionExecutiveOld + "(" + retirementResign.positionExecutiveField + ")" + "\n")) + + retirementResign.OrganizationOld; + + if ((retirementResign.posTypeNameOld == "ทั่วไป" && retirementResign.posLevelNameOld == "ชำนาญงาน") || (retirementResign.posTypeNameOld == "ทั่วไป" && retirementResign.posLevelNameOld == "ปฏิบัติงาน") || (retirementResign.posTypeNameOld == "วิชาการ" && retirementResign.posLevelNameOld == "ปฏิบัติการ") || (retirementResign.posTypeNameOld == "วิชาการ" && retirementResign.posLevelNameOld == "ชำนาญการ")) + { + retirementResign.Group = "1.1"; + } + else if ((retirementResign.posTypeNameOld == "ทั่วไป" && retirementResign.posLevelNameOld == "อาวุโส") || (retirementResign.posTypeNameOld == "วิชาการ" && retirementResign.posLevelNameOld == "ชำนาญการพิเศษ") || (retirementResign.posTypeNameOld == "อำนวยการ" && retirementResign.posLevelNameOld == "ต้น")) + { + retirementResign.Group = "1.2"; + } + else if ((retirementResign.posTypeNameOld == "ทั่วไป" && retirementResign.posLevelNameOld == "ทักษะพิเศษ") || (retirementResign.posTypeNameOld == "วิชาการ" && retirementResign.posLevelNameOld == "เชี่ยวชาญ") || (retirementResign.posTypeNameOld == "วิชาการ" && retirementResign.posLevelNameOld == "ทรงคุณวุฒิ") || (retirementResign.posTypeNameOld == "อำนวยการ" && retirementResign.posLevelNameOld == "สูง") || (retirementResign.posTypeNameOld == "บริหาร" && retirementResign.posLevelNameOld == "ต้น") || (retirementResign.posTypeNameOld == "บริหาร" && retirementResign.posLevelNameOld == "สูง")) + { + retirementResign.Group = "2"; + } + } + await _context.RetirementResigns.AddAsync(retirementResign); + await _context.SaveChangesAsync(); + if (Request.Form.Files != null && Request.Form.Files.Count != 0) + { + foreach (var file in Request.Form.Files) + { + var fileExtension = Path.GetExtension(file.FileName); + + var doc = await _documentService.UploadFileAsync(file, file.FileName); + var _doc = await _context.Documents.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == doc.Id); + if (_doc != null) + { + var retirementResignDoc = new RetirementResignDoc + { + RetirementResign = retirementResign, + Document = _doc, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + await _context.RetirementResignDocs.AddAsync(retirementResignDoc); + } + } + } + await _context.SaveChangesAsync(); + return Success(retirementResign); + } + /// /// แก้ไขการลาออก /// @@ -2019,7 +2170,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -2077,11 +2228,11 @@ namespace BMA.EHR.Retirement.Service.Controllers data = data .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - data = data - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => @@ -2710,6 +2861,10 @@ namespace BMA.EHR.Retirement.Service.Controllers var data = await _context.RetirementResigns .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -2764,12 +2919,12 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } @@ -2909,6 +3064,11 @@ namespace BMA.EHR.Retirement.Service.Controllers .Include(x => x.RetirementResign) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -2953,13 +3113,13 @@ namespace BMA.EHR.Retirement.Service.Controllers }).ToList(); var baseAPIOrg = _configuration["API"]; - var reportDone = false; - if (data.Where(profile => profile.Status == "DONE").Any()) - { - reportDone = true; - } - if (reportDone == true) - { + //var reportDone = false; + //if (data.Where(profile => profile.Status == "DONE").Any()) + //{ + // reportDone = true; + //} + //if (reportDone == true) + //{ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave"; using (var client = new HttpClient()) { @@ -2969,35 +3129,35 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); + // // await _context.SaveChangesAsync(); + // // } } - } - else - { - var apiUrlOrg = $"{baseAPIOrg}/org/command/cancel-resign"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - resignId = resultData.Select(x => x.resignId).ToList(), - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); - await _context.SaveChangesAsync(); - } - } - } + //} + //else + //{ + // var apiUrlOrg = $"{baseAPIOrg}/org/command/cancel-resign"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // resignId = resultData.Select(x => x.resignId).ToList(), + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // if (_res.IsSuccessStatusCode) + // { + // data.ForEach(profile => profile.Status = "DONE"); + // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL"); + // await _context.SaveChangesAsync(); + // } + // } + //} return Success(); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs index bfd8ab9f..7db20848 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs @@ -102,8 +102,8 @@ namespace BMA.EHR.Retirement.Service.Controllers p.Remark, p.ApproveReason, p.RejectReason, - p.CancelReason, - p.Status, + p.CancelReason, + status = p.RetirementResignEmployeeCancels.FirstOrDefault() == null ? p.Status : p.RetirementResignEmployeeCancels.FirstOrDefault().Status, statusCancel = p.RetirementResignEmployeeCancels.FirstOrDefault() == null ? null : p.RetirementResignEmployeeCancels.FirstOrDefault().Status, p.IsActive, }) @@ -208,7 +208,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -273,11 +273,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementResignEmployees = retirementResignEmployees .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementResignEmployees = retirementResignEmployees - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementResignEmployees = retirementResignEmployees + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementResignEmployees = retirementResignEmployees.Where(x => @@ -340,7 +340,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -403,11 +403,11 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementResignEmployees = retirementResignEmployees .Where(x => x.rootDnaOldId == nodeId).ToList(); } - else if (role == "PARENT") - { - retirementResignEmployees = retirementResignEmployees - .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); - } + // else if (role == "PARENT") + // { + // retirementResignEmployees = retirementResignEmployees + // .Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList(); + // } else if (role == "NORMAL") { retirementResignEmployees = retirementResignEmployees.Where(x => @@ -1291,6 +1291,148 @@ namespace BMA.EHR.Retirement.Service.Controllers return Success(retirementResignEmployee); } + /// + /// สร้างการลาออก โดย admin + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("admin")] + public async Task> PostAdmin([FromForm] RetirementResignEmployeeAdminRequest req) + { + var Remark = req.Remark; + if (req.Reason != null) + { + switch (req.Reason.Trim().ToUpper()) + { + case "CAREER": Remark = $"ประกอบอาชีพอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "MOVE": Remark = $"รับราชการสังกัดอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "FAMILY": Remark = $"ดูแลบิดามารดา" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "EDUCATION": Remark = $"ศึกษาต่อ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + case "OTHER": Remark = $"อื่น ๆ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break; + } + } + var retirementResignEmployee = new RetirementResignEmployee + { + ApproveStep = "st1", + Location = req.Location, + SendDate = DateTime.Now, + ActiveDate = req.ActiveDate, + Reason = req.Reason, + ReasonResign = Remark, + Remark = req.Remark, + Status = "APPROVE", + IsActive = true, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + + var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.ProfileId}"; + 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(_result); + + if (org == null || org.result == null) + return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); + + retirementResignEmployee.profileId = org.result.profileId; + retirementResignEmployee.prefix = org.result.prefix; + retirementResignEmployee.firstName = org.result.firstName; + retirementResignEmployee.lastName = org.result.lastName; + retirementResignEmployee.citizenId = org.result.citizenId; + retirementResignEmployee.rootOld = org.result.root; + retirementResignEmployee.rootOldId = org.result.rootId; + retirementResignEmployee.rootDnaOldId = org.result.rootDnaId; + retirementResignEmployee.rootShortNameOld = org.result.rootShortName; + retirementResignEmployee.child1Old = org.result.child1; + retirementResignEmployee.child1OldId = org.result.child1Id; + retirementResignEmployee.child1DnaOldId = org.result.child1DnaId; + retirementResignEmployee.child1ShortNameOld = org.result.child1ShortName; + retirementResignEmployee.child2Old = org.result.child2; + retirementResignEmployee.child2OldId = org.result.child2Id; + retirementResignEmployee.child2DnaOldId = org.result.child2DnaId; + retirementResignEmployee.child2ShortNameOld = org.result.child2ShortName; + retirementResignEmployee.child3Old = org.result.child3; + retirementResignEmployee.child3OldId = org.result.child3Id; + retirementResignEmployee.child3DnaOldId = org.result.child3DnaId; + retirementResignEmployee.child3ShortNameOld = org.result.child3ShortName; + retirementResignEmployee.child4Old = org.result.child4; + retirementResignEmployee.child4OldId = org.result.child4Id; + retirementResignEmployee.child4DnaOldId = org.result.child4DnaId; + retirementResignEmployee.child4ShortNameOld = org.result.child4ShortName; + retirementResignEmployee.posMasterNoOld = org.result.posMasterNo; + retirementResignEmployee.posTypeOldId = org.result.posTypeId; + retirementResignEmployee.posTypeNameOld = org.result.posTypeName; + retirementResignEmployee.posLevelOldId = org.result.posLevelId; + retirementResignEmployee.posLevelNameOld = org.result.posLevelName; + retirementResignEmployee.AmountOld = org.result.salary; + retirementResignEmployee.PositionOld = org.result.position; + retirementResignEmployee.PositionLevelOld = org.result.posLevelName; + retirementResignEmployee.PositionTypeOld = org.result.posTypeName; + retirementResignEmployee.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo; + retirementResignEmployee.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") + + (org.result.child3 == null ? "" : org.result.child3 + "\n") + + (org.result.child2 == null ? "" : org.result.child2 + "\n") + + (org.result.child1 == null ? "" : org.result.child1 + "\n") + + (org.result.root == null ? "" : org.result.root); + retirementResignEmployee.OrganizationPositionOld = org.result.position + "\n" + retirementResignEmployee.OrganizationOld; + if ((retirementResignEmployee.posTypeNameOld == "ทั่วไป" && retirementResignEmployee.posLevelNameOld == "ชำนาญงาน") || (retirementResignEmployee.posTypeNameOld == "ทั่วไป" && retirementResignEmployee.posLevelNameOld == "ปฏิบัติงาน") || (retirementResignEmployee.posTypeNameOld == "วิชาการ" && retirementResignEmployee.posLevelNameOld == "ปฏิบัติการ") || (retirementResignEmployee.posTypeNameOld == "วิชาการ" && retirementResignEmployee.posLevelNameOld == "ชำนาญการ")) + { + retirementResignEmployee.Group = "1.1"; + } + else if ((retirementResignEmployee.posTypeNameOld == "ทั่วไป" && retirementResignEmployee.posLevelNameOld == "อาวุโส") || (retirementResignEmployee.posTypeNameOld == "วิชาการ" && retirementResignEmployee.posLevelNameOld == "ชำนาญการพิเศษ") || (retirementResignEmployee.posTypeNameOld == "อำนวยการ" && retirementResignEmployee.posLevelNameOld == "ต้น")) + { + retirementResignEmployee.Group = "1.2"; + } + else if ((retirementResignEmployee.posTypeNameOld == "ทั่วไป" && retirementResignEmployee.posLevelNameOld == "ทักษะพิเศษ") || (retirementResignEmployee.posTypeNameOld == "วิชาการ" && retirementResignEmployee.posLevelNameOld == "เชี่ยวชาญ") || (retirementResignEmployee.posTypeNameOld == "วิชาการ" && retirementResignEmployee.posLevelNameOld == "ทรงคุณวุฒิ") || (retirementResignEmployee.posTypeNameOld == "อำนวยการ" && retirementResignEmployee.posLevelNameOld == "สูง") || (retirementResignEmployee.posTypeNameOld == "บริหาร" && retirementResignEmployee.posLevelNameOld == "ต้น") || (retirementResignEmployee.posTypeNameOld == "บริหาร" && retirementResignEmployee.posLevelNameOld == "สูง")) + { + retirementResignEmployee.Group = "2"; + } + } + await _context.RetirementResignEmployees.AddAsync(retirementResignEmployee); + await _context.SaveChangesAsync(); + if (Request.Form.Files != null && Request.Form.Files.Count != 0) + { + foreach (var file in Request.Form.Files) + { + var fileExtension = Path.GetExtension(file.FileName); + + var doc = await _documentService.UploadFileAsync(file, file.FileName); + var _doc = await _context.Documents.AsQueryable() + .FirstOrDefaultAsync(x => x.Id == doc.Id); + if (_doc != null) + { + var retirementResignEmployeeDoc = new RetirementResignEmployeeDoc + { + RetirementResignEmployee = retirementResignEmployee, + Document = _doc, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + await _context.RetirementResignEmployeeDocs.AddAsync(retirementResignEmployeeDoc); + } + } + } + await _context.SaveChangesAsync(); + return Success(retirementResignEmployee); + } + /// /// แก้ไขการลาออก /// @@ -1936,7 +2078,7 @@ namespace BMA.EHR.Retirement.Service.Controllers ? profileAdmin?.RootDnaId : ""; } - else if (role == "ROOT" || role == "PARENT") + else if (role == "ROOT" /*|| role == "PARENT"*/) { nodeId = profileAdmin?.RootDnaId; } @@ -1994,11 +2136,11 @@ namespace BMA.EHR.Retirement.Service.Controllers data = data .Where(x => x.rootDnaId == nodeId).ToList(); } - else if (role == "PARENT") - { - data = data - .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); - } + // else if (role == "PARENT") + // { + // data = data + // .Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList(); + // } else if (role == "NORMAL") { data = data.Where(x => @@ -2219,6 +2361,10 @@ namespace BMA.EHR.Retirement.Service.Controllers var data = await _context.RetirementResignEmployees .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + await _context.SaveChangesAsync(); + var resultData = (from p in data join r in req.refIds on p.Id.ToString() equals r.refId @@ -2271,12 +2417,12 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // await _context.SaveChangesAsync(); + // // } } return Success(); } @@ -2414,6 +2560,11 @@ namespace BMA.EHR.Retirement.Service.Controllers .Include(x => x.RetirementResignEmployee) .Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString())) .ToListAsync(); + // Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ + data.ForEach(profile => profile.Status = "DONE"); + data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); + await _context.SaveChangesAsync(); + string? _null = null; var resultData = (from p in data join r in req.refIds @@ -2456,14 +2607,14 @@ namespace BMA.EHR.Retirement.Service.Controllers }).ToList(); var baseAPIOrg = _configuration["API"]; - var reportDone = false; - if (data.Where(profile => profile.Status == "DONE").Any()) - { - reportDone = true; - } + //var reportDone = false; + //if (data.Where(profile => profile.Status == "DONE").Any()) + //{ + // reportDone = true; + //} - if (reportDone == true) - { + //if (reportDone == true) + //{ var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave"; using (var client = new HttpClient()) { @@ -2473,35 +2624,35 @@ namespace BMA.EHR.Retirement.Service.Controllers { data = resultData, }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); - await _context.SaveChangesAsync(); - } + // // var _result = await _res.Content.ReadAsStringAsync(); + // // if (_res.IsSuccessStatusCode) + // // { + // // data.ForEach(profile => profile.Status = "DONE"); + // // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); + // // await _context.SaveChangesAsync(); + // // } } - } - else - { - var apiUrlOrg = $"{baseAPIOrg}/org/command/cancel-resign"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); - var _res = await client.PostAsJsonAsync(apiUrlOrg, new - { - resignId = resultData.Select(x => x.resignId).ToList(), - }); - var _result = await _res.Content.ReadAsStringAsync(); - if (_res.IsSuccessStatusCode) - { - data.ForEach(profile => profile.Status = "DONE"); - data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); - await _context.SaveChangesAsync(); - } - } - } + //} + //else + //{ + // var apiUrlOrg = $"{baseAPIOrg}/org/command/cancel-resign"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]); + // var _res = await client.PostAsJsonAsync(apiUrlOrg, new + // { + // resignId = resultData.Select(x => x.resignId).ToList(), + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // if (_res.IsSuccessStatusCode) + // { + // data.ForEach(profile => profile.Status = "DONE"); + // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL"); + // await _context.SaveChangesAsync(); + // } + // } + //} return Success(); } diff --git a/BMA.EHR.Retirement.Service/Program.cs b/BMA.EHR.Retirement.Service/Program.cs index ee807e0a..a55f9674 100644 --- a/BMA.EHR.Retirement.Service/Program.cs +++ b/BMA.EHR.Retirement.Service/Program.cs @@ -3,6 +3,7 @@ using BMA.EHR.Domain.Middlewares; using BMA.EHR.Infrastructure; using BMA.EHR.Infrastructure.Persistence; using BMA.EHR.Retirement.Service; +using BMA.EHR.Retirement.Service.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; @@ -86,6 +87,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddApplication(); builder.Services.AddLeaveApplication(); builder.Services.AddPersistence(builder.Configuration); + builder.Services.AddScoped(); builder.Services.AddLeavePersistence(builder.Configuration); builder.Services.AddHttpClient(); diff --git a/BMA.EHR.Retirement.Service/Requests/RetirementResignEmployeeRequest.cs b/BMA.EHR.Retirement.Service/Requests/RetirementResignEmployeeRequest.cs index 409bc185..dd883d0d 100644 --- a/BMA.EHR.Retirement.Service/Requests/RetirementResignEmployeeRequest.cs +++ b/BMA.EHR.Retirement.Service/Requests/RetirementResignEmployeeRequest.cs @@ -19,4 +19,21 @@ namespace BMA.EHR.Retirement.Service.Requests public double? AmountOld { get; set; } public List? File { get; set; } } + + public class RetirementResignEmployeeAdminRequest + { + public string ProfileId { get; set; } + public string? Location { get; set; } + public DateTime? ActiveDate { get; set; } + public string? Reason { get; set; } + public string? Remark { get; set; } + public string? ReasonResign { get; set; } + public string? OrganizationPositionOld { get; set; } + public string? PositionTypeOld { get; set; } + public string? PositionLevelOld { get; set; } + public string? PositionNumberOld { get; set; } + public string? RemarkHorizontal { get; set; } + public double? AmountOld { get; set; } + public List? File { get; set; } + } } diff --git a/BMA.EHR.Retirement.Service/Requests/RetirementResignRequest.cs b/BMA.EHR.Retirement.Service/Requests/RetirementResignRequest.cs index 7f1bf500..acef05aa 100644 --- a/BMA.EHR.Retirement.Service/Requests/RetirementResignRequest.cs +++ b/BMA.EHR.Retirement.Service/Requests/RetirementResignRequest.cs @@ -20,4 +20,21 @@ namespace BMA.EHR.Retirement.Service.Requests public double? AmountOld { get; set; } public List? File { get; set; } } + public class RetirementResignAdminRequest + { + public string ProfileId { get; set; } + public string? Location { get; set; } + public DateTime? ActiveDate { get; set; } + public string? Reason { get; set; } + public string? Remark { get; set; } + public string? ReasonResign { get; set; } + public string? OrganizationPositionOld { get; set; } + public string? PositionExecutiveOld { get; set; } + public string? PositionTypeOld { get; set; } + public string? PositionLevelOld { get; set; } + public string? PositionNumberOld { get; set; } + public string? RemarkHorizontal { get; set; } + public double? AmountOld { get; set; } + public List? File { get; set; } + } } diff --git a/BMA.EHR.Retirement.Service/Services/RetirementReportService.cs b/BMA.EHR.Retirement.Service/Services/RetirementReportService.cs new file mode 100644 index 00000000..48e301be --- /dev/null +++ b/BMA.EHR.Retirement.Service/Services/RetirementReportService.cs @@ -0,0 +1,698 @@ +using BMA.EHR.Application.Responses; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace BMA.EHR.Retirement.Service.Services +{ + public class RetirementReportService + { + private readonly IWebHostEnvironment _environment; + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + + /// + /// Initializes a new instance of the RetirementReportService class. + /// + public RetirementReportService( + IWebHostEnvironment environment, + ILogger logger, + IConfiguration configuration) + { + _environment = environment; + _logger = logger; + _configuration = configuration; + } + + #region Public Methods + + /// + /// สร้างรายงานจาก Template (.docx) + /// + public async Task GenerateReportAsync(string templateName, dynamic data, string exportType) + { + try + { + var templatePath = GetTemplatePath(templateName); + var docxBytes = await ProcessTemplateAsync(templatePath, data); + + return exportType.ToLower() == "pdf" + ? await ConvertToPdfAsync(docxBytes) + : docxBytes; + } + catch (Exception ex) + { + _logger.LogError(ex, "Error generating report"); + throw; + } + } + + #endregion + + #region Template Processing + + private string GetTemplatePath(string templateName) + { + var path = Path.Combine(_environment.ContentRootPath, "Templates", $"{templateName}.docx"); + if (!File.Exists(path)) + throw new FileNotFoundException($"Template not found: {templateName}"); + return path; + } + + private async Task ProcessTemplateAsync(string templatePath, dynamic data) + { + using var templateStream = File.OpenRead(templatePath); + using var outputStream = new MemoryStream(); + await templateStream.CopyToAsync(outputStream); + outputStream.Position = 0; + + using (var wordDoc = WordprocessingDocument.Open(outputStream, true)) + { + var mainPart = wordDoc.MainDocumentPart; + if (mainPart == null) return Array.Empty(); + + ReplacePlaceholders(mainPart, data); + wordDoc.Save(); + } + + return outputStream.ToArray(); + } + + private void ReplacePlaceholders(MainDocumentPart mainPart, dynamic data) + { + var document = mainPart.Document; + if (document == null) return; + + var processor = CreateDataProcessor(data); + processor.Process(document, new Action(FillTableRows)); + } + + #endregion + + #region Data Processing Strategy + + private IDataProcessor CreateDataProcessor(dynamic data) + { + var dataType = data.GetType(); + var isDictionary = dataType.IsGenericType && + dataType.GetGenericTypeDefinition() == typeof(Dictionary<,>); + + return isDictionary + ? new DictionaryDataProcessor(data) + : new ObjectDataProcessor(data); + } + + #endregion + + #region Table Processing + + private void FillTableRows(Document document, System.Collections.IEnumerable profiles) + { + var table = document.Descendants().FirstOrDefault(); + if (table == null) return; + + var rows = table.Elements().ToList(); + if (rows.Count == 0) return; + + var strategy = CreateTableStrategy(rows); + strategy.Process(table, rows, profiles); + } + + private static ITableStrategy CreateTableStrategy(List rows) + { + // retire-1 format: 1 row, 1 cell, 1 paragraph + if (IsSingleParagraphFormat(rows)) + return new SingleParagraphTableStrategy(); + + // retire-1 format: 2 rows, 3 columns (root row + data row per profile) + if (IsTwoRowPerProfileFormat(rows)) + return new TwoRowPerProfileTableStrategy(); + + // retire-3 format: 2+ rows (header + template) + return new MultiRowTableStrategy(); + } + + private static bool IsSingleParagraphFormat(List rows) => + rows.Count == 1 && + rows[0].Elements().Count() == 1 && + rows[0].Elements().First().Elements().Count() == 1; + + private static bool IsTwoRowPerProfileFormat(List rows) => + rows.Count == 2 && + rows[0].Elements().Count() == 3 && + rows[1].Elements().Count() == 3; + + #endregion + + #region PDF Conversion + + private async Task ConvertToPdfAsync(byte[] docxBytes) + { + var tempDocx = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.docx"); + var tempPdf = Path.ChangeExtension(tempDocx, ".pdf"); + + try + { + await File.WriteAllBytesAsync(tempDocx, docxBytes); + await ConvertToPdfInternalAsync(tempDocx, tempPdf); + return await File.ReadAllBytesAsync(tempPdf); + } + finally + { + if (File.Exists(tempDocx)) File.Delete(tempDocx); + if (File.Exists(tempPdf)) File.Delete(tempPdf); + } + } + + private async Task ConvertToPdfInternalAsync(string docxPath, string pdfPath) + { + try + { + var useDocker = _configuration.GetValue("LibreOffice:UseDocker", false); + var timeout = _configuration.GetValue("LibreOffice:Timeout", 180000); + + if (useDocker) + { + await ConvertToPdfViaDockerAsync(docxPath, pdfPath, timeout); + } + else + { + // // PROD: Disabled local LibreOffice conversion + // await ConvertToPdfLocallyAsync(docxPath, pdfPath, timeout); + throw new NotSupportedException("LibreOffice conversion is disabled."); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Error converting to PDF"); + throw; + } + } + + private async Task ConvertToPdfViaDockerAsync(string docxPath, string pdfPath, int timeout) + { + var inputDir = _configuration["LibreOffice:InputDirectory"] ?? "/app/libreoffice/input"; + var outputDir = _configuration["LibreOffice:OutputDirectory"] ?? "/app/libreoffice/output"; + var fileName = Path.GetFileName(docxPath); + var pdfName = Path.ChangeExtension(fileName, ".pdf"); + + // Ensure directories exist + Directory.CreateDirectory(inputDir); + Directory.CreateDirectory(outputDir); + + // Copy file to input folder (LibreOffice watcher will pick it up) + var inputPath = Path.Combine(inputDir, fileName).Replace('\\', '/'); + var outputPath = Path.Combine(outputDir, pdfName).Replace('\\', '/'); + + _logger.LogInformation("📤 Sending file to LibreOffice: {FileName}", fileName); + await File.WriteAllBytesAsync(inputPath, await File.ReadAllBytesAsync(docxPath)); + + // Wait for LibreOffice to convert (file watcher handles it) + var stopwatch = System.Diagnostics.Stopwatch.StartNew(); + var pollInterval = TimeSpan.FromMilliseconds(500); + + while (stopwatch.ElapsedMilliseconds < timeout) + { + if (File.Exists(outputPath)) + { + _logger.LogInformation("✅ PDF received: {PdfName} (took {ElapsedMs}ms)", pdfName, stopwatch.ElapsedMilliseconds); + + await File.WriteAllBytesAsync(pdfPath, await File.ReadAllBytesAsync(outputPath)); + + // Cleanup + try + { + if (File.Exists(outputPath)) File.Delete(outputPath); + _logger.LogDebug("🗑️ Cleaned up output file: {PdfName}", pdfName); + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to cleanup output file"); + } + + return; + } + + await Task.Delay(pollInterval); + } + + throw new TimeoutException($"LibreOffice conversion timed out after {timeout}ms. File not found: {outputPath}"); + } + + // // PROD: Disabled local LibreOffice conversion + // private async Task ConvertToPdfLocallyAsync(string docxPath, string pdfPath, int timeout) + // { + // var libreOfficePath = _configuration["LibreOffice:Path"] ?? GetDefaultLibreOfficePath(); + // var arguments = _configuration["LibreOffice:Arguments"] ?? "--headless --convert-to pdf --nologo --norestore"; + // var outputDir = Path.GetDirectoryName(pdfPath); + + // if (string.IsNullOrEmpty(outputDir)) + // { + // throw new DirectoryNotFoundException("Output directory cannot be determined"); + // } + + // var psi = new ProcessStartInfo + // { + // FileName = libreOfficePath, + // Arguments = $"{arguments} --outdir \"{outputDir}\" \"{docxPath}\"", + // UseShellExecute = false, + // RedirectStandardOutput = true, + // RedirectStandardError = true, + // CreateNoWindow = true + // }; + + // using var process = Process.Start(psi); + // var exited = process.WaitForExit(timeout); + + // if (!exited) + // { + // process.Kill(entireProcessTree: true); + // throw new TimeoutException($"LibreOffice conversion timed out after {timeout}ms"); + // } + + // if (process.ExitCode != 0) + // { + // var error = await process.StandardError.ReadToEndAsync(); + // throw new Exception($"LibreOffice conversion failed: {error}"); + // } + // } + + // // PROD: Disabled local LibreOffice path detection + // private static string GetDefaultLibreOfficePath() + // { + // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // { + // var possiblePaths = new[] + // { + // @"C:\Program Files\LibreOffice\program\soffice.exe", + // @"C:\Program Files (x86)\LibreOffice\program\soffice.exe", + // @"C:\Program Files\LibreOffice\program\soffice.com" + // }; + + // return possiblePaths.FirstOrDefault(File.Exists) + // ?? throw new FileNotFoundException("LibreOffice not found. Please install LibreOffice or configure the path in appsettings.json"); + // } + + // // Linux/Docker: use default path + // return "libreoffice"; + // } + + #endregion + } + + #region Data Processor Interfaces & Implementations + + internal interface IDataProcessor + { + void Process(Document document, Action tableFiller); + } + + internal class DictionaryDataProcessor : IDataProcessor + { + private readonly dynamic _data; + + public DictionaryDataProcessor(dynamic data) + { + _data = data; + } + + public void Process(Document document, Action tableFiller) + { + var keys = _data.Keys as System.Collections.ICollection; + if (keys == null) return; + + System.Collections.IEnumerable? profiles = null; + + foreach (string key in keys) + { + if (key.Equals("profiles", StringComparison.OrdinalIgnoreCase)) + { + profiles = _data[key] as System.Collections.IEnumerable; + continue; + } + + var valueObj = _data[key]; + if (valueObj != null && typeof(System.Collections.IEnumerable).IsAssignableFrom(valueObj.GetType()) && + valueObj.GetType() != typeof(string)) + { + continue; + } + + var value = valueObj?.ToString() ?? string.Empty; + var placeholder = $"{{{{{key}}}}}"; + TextReplacer.ReplaceAll(document, placeholder, value); + } + + if (profiles != null) + { + tableFiller(document, profiles); + } + } + } + + internal class ObjectDataProcessor : IDataProcessor + { + private readonly dynamic _data; + + public ObjectDataProcessor(dynamic data) + { + _data = data; + } + + public void Process(Document document, Action tableFiller) + { + var dataType = _data.GetType(); + var allProps = dataType.GetProperties(); + var validProps = new List(); + + foreach (var p in allProps) + { + if (p.GetIndexParameters().Length == 0) + { + validProps.Add(p); + } + } + + System.Collections.IEnumerable? profiles = null; + + foreach (var prop in validProps) + { + var propType = prop.PropertyType; + bool isEnumerable = typeof(System.Collections.IEnumerable).IsAssignableFrom(propType); + bool isString = propType == typeof(string); + + if (isEnumerable && !isString) + { + if (prop.Name.Equals("profiles", StringComparison.OrdinalIgnoreCase)) + { + profiles = prop.GetValue(_data) as System.Collections.IEnumerable; + } + continue; + } + + var value = prop.GetValue(_data)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + TextReplacer.ReplaceAll(document, placeholder, value); + } + + if (profiles != null) + { + tableFiller(document, profiles); + } + } + } + + #endregion + + #region Text Replacer + + internal static class TextReplacer + { + public static void ReplaceAll(Document document, string oldValue, string newValue) + { + bool found = false; + + // Method 1: Check within single Run + foreach (var run in document.Descendants()) + { + var textElements = run.Elements().ToList(); + if (textElements.Count == 0) continue; + + var combinedText = string.Concat(textElements.Select(t => t.Text)); + if (combinedText.Contains(oldValue)) + { + found = true; + var replacedText = combinedText.Replace(oldValue, newValue); + textElements[0].Text = replacedText; + for (int i = 1; i < textElements.Count; i++) + { + textElements[i].Text = string.Empty; + } + } + } + + // Method 2: Check across all Runs in Paragraph + foreach (var para in document.Descendants()) + { + var allRuns = para.Elements().ToList(); + if (allRuns.Count == 0) continue; + + var combinedParaText = string.Concat(allRuns.SelectMany(r => r.Elements().Select(t => t.Text))); + if (combinedParaText.Contains(oldValue)) + { + found = true; + var replacedText = combinedParaText.Replace(oldValue, newValue); + + var firstRunTexts = allRuns[0].Elements().ToList(); + if (firstRunTexts.Count > 0) + { + firstRunTexts[0].Text = replacedText; + for (int i = 1; i < firstRunTexts.Count; i++) + { + firstRunTexts[i].Text = string.Empty; + } + } + + for (int i = 1; i < allRuns.Count; i++) + { + foreach (var t in allRuns[i].Elements()) + { + t.Text = string.Empty; + } + } + } + } + + // Fallback: Check individual Text elements + if (!found) + { + foreach (var text in document.Descendants()) + { + if (!string.IsNullOrEmpty(text.Text) && text.Text.Contains(oldValue)) + { + found = true; + text.Text = text.Text.Replace(oldValue, newValue); + } + } + } + } + + public static void ReplaceInRow(TableRow row, string oldValue, string newValue) + { + bool found = false; + + foreach (var cell in row.Descendants()) + { + foreach (var para in cell.Elements()) + { + found = ReplaceInParagraph(para, oldValue, newValue) || found; + } + } + + // Fallback: Check individual Text elements + if (!found) + { + foreach (var text in row.Descendants()) + { + if (!string.IsNullOrEmpty(text.Text) && text.Text.Contains(oldValue)) + { + found = true; + text.Text = text.Text.Replace(oldValue, newValue); + } + } + } + } + + public static bool ReplaceInParagraph(Paragraph paragraph, string oldValue, string newValue) + { + bool found = false; + + var allTexts = paragraph.Descendants().ToList(); + if (allTexts.Count == 0) return false; + + var combinedParaText = string.Concat(allTexts.Select(t => t.Text)); + + if (combinedParaText.Contains(oldValue)) + { + found = true; + var replacedText = combinedParaText.Replace(oldValue, newValue); + allTexts[0].Text = replacedText; + + for (int i = 1; i < allTexts.Count; i++) + { + allTexts[i].Text = string.Empty; + } + } + + // Fallback: Check individual Text elements + if (!found) + { + foreach (var text in allTexts) + { + if (!string.IsNullOrEmpty(text.Text) && text.Text.Contains(oldValue)) + { + found = true; + text.Text = text.Text.Replace(oldValue, newValue); + } + } + } + + return found; + } + } + + #endregion + + #region Table Strategy Interfaces & Implementations + + internal interface ITableStrategy + { + void Process(Table table, List rows, System.Collections.IEnumerable profiles); + } + + internal class SingleParagraphTableStrategy : ITableStrategy + { + public void Process(Table table, List rows, System.Collections.IEnumerable profiles) + { + var cell = rows[0].Elements().First(); + var templatePara = cell.Elements().First(); + + var profileList = profiles.Cast().ToList(); + + foreach (var profile in profileList) + { + var props = profile.GetType() + .GetProperties() + .Where(p => p.GetIndexParameters().Length == 0) + .ToList(); + + var newPara = (Paragraph)templatePara.CloneNode(true); + + foreach (var prop in props) + { + var value = prop.GetValue(profile)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + TextReplacer.ReplaceInParagraph(newPara, placeholder, value); + } + + cell.Append(newPara); + } + + templatePara.Remove(); + } + } + + internal class MultiRowTableStrategy : ITableStrategy + { + public void Process(Table table, List rows, System.Collections.IEnumerable profiles) + { + var templateRowIndex = rows.Count >= 2 ? 1 : 0; + var templateRow = rows[templateRowIndex]; + templateRow.Remove(); + + var profileList = profiles.Cast().ToList(); + + // Process header row if exists + if (rows.Count >= 2) + { + ProcessHeaderRow(rows[0], profileList); + } + + // Process template rows + foreach (var profile in profileList) + { + var newRow = (TableRow)templateRow.CloneNode(true); + var props = profile.GetType() + .GetProperties() + .Where(p => p.GetIndexParameters().Length == 0) + .ToList(); + + foreach (var prop in props) + { + var value = prop.GetValue(profile)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + TextReplacer.ReplaceInRow(newRow, placeholder, value); + } + + table.AppendChild(newRow); + } + } + + private static void ProcessHeaderRow(TableRow headerRow, List profileList) + { + var firstProfile = profileList.FirstOrDefault(); + if (firstProfile == null) return; + + var props = firstProfile.GetType() + .GetProperties() + .Where(p => p.GetIndexParameters().Length == 0) + .ToList(); + + foreach (var prop in props) + { + var value = prop.GetValue(firstProfile)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + + if (!string.IsNullOrWhiteSpace(value)) + { + TextReplacer.ReplaceInRow(headerRow, placeholder, value); + } + } + } + } + + internal class TwoRowPerProfileTableStrategy : ITableStrategy + { + public void Process(Table table, List rows, System.Collections.IEnumerable profiles) + { + // retire-1 format: 2 rows per profile (root row + data row) + var rootRow = rows[0]; + var dataRow = rows[1]; + + // Remove template rows from table + rootRow.Remove(); + dataRow.Remove(); + + var profileList = profiles.Cast().ToList(); + + foreach (var profile in profileList) + { + var props = profile.GetType() + .GetProperties() + .Where(p => p.GetIndexParameters().Length == 0) + .ToList(); + + // Check root value - skip root row if empty or null + var rootValue = props.FirstOrDefault(p => p.Name.Equals("root", StringComparison.OrdinalIgnoreCase)) + ?.GetValue(profile)?.ToString() ?? string.Empty; + + // Clone root row and fill with placeholders (only if root has value) + if (!string.IsNullOrWhiteSpace(rootValue)) + { + var newRootRow = (TableRow)rootRow.CloneNode(true); + foreach (var prop in props) + { + var value = prop.GetValue(profile)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + TextReplacer.ReplaceInRow(newRootRow, placeholder, value); + } + table.AppendChild(newRootRow); + } + + // Clone data row and fill with placeholders (always show) + var newDataRow = (TableRow)dataRow.CloneNode(true); + foreach (var prop in props) + { + var value = prop.GetValue(profile)?.ToString() ?? string.Empty; + var placeholder = $"{{{{{prop.Name}}}}}"; + TextReplacer.ReplaceInRow(newDataRow, placeholder, value); + } + table.AppendChild(newDataRow); + } + } + } + + #endregion +} diff --git a/BMA.EHR.Retirement.Service/Templates/retire-1.docx b/BMA.EHR.Retirement.Service/Templates/retire-1.docx new file mode 100644 index 00000000..aae58587 Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-1.docx differ diff --git a/BMA.EHR.Retirement.Service/Templates/retire-2.docx b/BMA.EHR.Retirement.Service/Templates/retire-2.docx new file mode 100644 index 00000000..4c9db823 Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-2.docx differ diff --git a/BMA.EHR.Retirement.Service/Templates/retire-3.docx b/BMA.EHR.Retirement.Service/Templates/retire-3.docx new file mode 100644 index 00000000..4257c5f6 Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-3.docx differ diff --git a/BMA.EHR.Retirement.Service/Templates/retire-emp-1.docx b/BMA.EHR.Retirement.Service/Templates/retire-emp-1.docx new file mode 100644 index 00000000..28e5c9ea Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-emp-1.docx differ diff --git a/BMA.EHR.Retirement.Service/Templates/retire-emp-2.docx b/BMA.EHR.Retirement.Service/Templates/retire-emp-2.docx new file mode 100644 index 00000000..3fd290de Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-emp-2.docx differ diff --git a/BMA.EHR.Retirement.Service/Templates/retire-emp-3.docx b/BMA.EHR.Retirement.Service/Templates/retire-emp-3.docx new file mode 100644 index 00000000..622f5b8e Binary files /dev/null and b/BMA.EHR.Retirement.Service/Templates/retire-emp-3.docx differ diff --git a/README.md b/README.md new file mode 100644 index 00000000..074e828b --- /dev/null +++ b/README.md @@ -0,0 +1,210 @@ +# BMA.EHR - HRMS API Backend + +ระบบบริหารจัดการทรัพยากรบุคคล (Human Resource Management System) พัฒนาด้วยสถาปัตยกรรม Microservices บน .NET + +--- + +## Tech Stack + +| Category | Technology | +| ----------------- | ----------------------------- | +| Framework | .NET 6.0 / 7.0 / 8.0 | +| Architecture | Clean Architecture, DDD, CQRS | +| Database | MySQL (Entity Framework Core) | +| Authentication | JWT + Keycloak | +| Message Queue | RabbitMQ | +| Object Storage | MinIO | +| Background Jobs | Hangfire | +| Logging | Serilog + Elasticsearch | +| Error Tracking | Sentry | +| API Documentation | Swagger / OpenAPI | +| Containerization | Docker | +| Testing | xUnit, k6 (Load Testing) | + +--- + +## โครงสร้างโปรเจกต์ (Project Structure) + +``` +BMA.EHR.Solution.sln +├── src/ # Core Libraries +│ ├── BMA.EHR.Domain/ # Domain layer (Entities, Business Rules) +│ ├── BMA.EHR.Application/ # Application layer (Use Cases, Interfaces) +│ └── BMA.EHR.Infrastructure/ # Infrastructure layer (Data Access, External Services) +│ +└── Service/ # Microservices + ├── BMA.EHR.Command.Service/ # Command/CQRS API Gateway + ├── BMA.EHR.MetaData.Service/ # ข้อมูลอ้างอิง (คำนำหน้า, หมู่เลือด, ศาสนา ฯลฯ) + ├── BMA.EHR.Placement.Service/ # การบริจาค/สั่งย้าย/แต่งตั้ง + ├── BMA.EHR.OrganizationEmployee.Service/ # โครงสร้างองค์กรและบุคลากร + ├── BMA.EHR.Discipline.Service/ # การ discipline บุคลากร + ├── BMA.EHR.Retirement.Service/ # การเกษียณอายุราชการ + ├── BMA.EHR.Report.Service/ # รายงาน + ├── BMA.EHR.Insignia/ # เครื่องราชอิสริยาภรณ์ + ├── BMA.EHR.Leave/ # ระบบลา + └── BMA.EHR.CheckInConsumer/ # ลงเวลาปฏิบัติงาน +``` + +--- + +## โมดูลหลัก (Key Modules) + +### การบริหารทรัพยากรบุคคล + +- **Placement Service** - สั่งย้าย, แต่งตั้ง, เลื่อนตำแหน่ง, โอนย้ายบุคลากร +- **Organization Employee Service** - จัดการโครงสร้างองค์กร, ตำแหน่ง, ข้อมูลบุคลากร +- **Leave Service** - การลางาน, การอนุมัติ, วันหยุดนักขัตฤกษ์, ยอดวันลาคงเหลือ +- **Discipline Service** - การดำเนินการ discipline, การสืบสวน, เอกสารที่เกี่ยวข้อง +- **Retirement Service** - การเกษียณอายุ, เอกสาร, สิทธิประโยชน์ +- **Insignia Service** - เครื่องราชอิสริยาภรณ์และรางวัล +- **CheckIn Consumer** - ติดตามการลงเวลาปฏิบัติงาน + +### ระบบสนับสนุน + +- **Metadata Service** - ข้อมูลอ้างอิง (คำนำหน้าชื่อ, หมู่เลือด, ศาสนา, ระดับการศึกษา ฯลฯ) +- **Report Service** - สร้างรายงาน PDF/Excel +- **Command Service** - API Gateway สำหรับ CQRS command operations + +### ฟีเจอร์เด่น + +- **Real-time Notifications** - แจ้งเตือนผ่าน WebSocket +- **Background Processing** - งานที่กำหนดเวลาผ่าน Hangfire +- **Event-Driven Communication** - สื่อสารระหว่าง services ผ่าน RabbitMQ +- **Document Generation** - สร้างเอกสาร PDF/Excel +- **Audit Trail** - บันทึกประวัติการเปลี่ยนแปลงข้อมูลทั้งหมด + +--- + +## API Endpoints + +API ใช้ versioning และสามารถดูรายละเอียดได้ผ่าน Swagger UI: + +``` +/api/v1/placement # การบริจาค/สั่งย้าย/แต่งตั้ง +/api/v1/leave # ระบบลา +/api/v1/discipline # การ discipline +/api/v1/organization # โครงสร้างองค์กร +/api/v1/metadata # ข้อมูลอ้างอิง +/api/v1/retirement # การเกษียณอายุ +/api/v1/insignia # เครื่องราชอิสริยาภรณ์ +/api/v1/reports # รายงาน +``` + +--- + +## Getting Started + +### Prerequisites + +- .NET SDK 6.0 / 7.0 / 8.0 +- MySQL Server +- Keycloak (Authentication Server) +- RabbitMQ +- MinIO (Object Storage) +- Docker (สำหรับ deployment) + +### Configuration + +แต่ละ service มีไฟล์ `appsettings.json` สำหรับ config ดังนี้: + +- **JWT Authentication** - เชื่อมต่อกับ Keycloak +- **Database Connection** - MySQL connection string +- **RabbitMQ** - Message queue connection +- **MinIO** - File storage endpoint +- **Elasticsearch** - Logging endpoint +- **Mail Server** - สำหรับส่งอีเมล + +### Build & Run + +```bash +# Restore dependencies +dotnet restore + +# Build solution +dotnet build + +# Run specific service +dotnet run --project Service/BMA.EHR.Command.Service +``` + +### Docker + +```bash +# Build Docker image +docker build -t bma-ehr-service . + +# Run container +docker run -d -p 5000:80 bma-ehr-service +``` + +--- + +## Architecture + +``` +┌──────────────┐ ┌──────────────┐ ┌──────────────┐ +│ Swagger │ │ Client │ │ WebSocket │ +│ UI │ │ Apps │ │ Clients │ +└──────┬───────┘ └──────┬───────┘ └──────┬───────┘ + │ │ │ + └────────────────────┼────────────────────┘ + │ + ┌────────▼────────┐ + │ API Gateway │ + │ (Keycloak JWT) │ + └────────┬────────┘ + │ + ┌────────────────────┼────────────────────┐ + │ │ │ +┌──────▼──────┐ ┌────────▼──────┐ ┌────────▼──────┐ +│ Placement │ │ Leave │ │ Discipline │ +│ Service │ │ Service │ │ Service │ +└──────┬──────┘ └────────┬──────┘ └────────┬──────┘ + │ │ │ + └────────────────────┼────────────────────┘ + │ + ┌─────────────▼──────────────┐ + │ MySQL Database │ + │ (Entity Framework) │ + └────────────────────────────┘ + + ┌────────────────────────────┐ + │ RabbitMQ / MinIO / │ + │ Elasticsearch / Hangfire │ + └────────────────────────────┘ +``` + +--- + +## Dependencies ที่สำคัญ + +| Package | หน้าที่ | +| --------------------- | ------------------------- | +| Entity Framework Core | ORM สำหรับ MySQL | +| Serilog | Structured Logging | +| Swashbuckle | API Documentation | +| Hangfire | Background Job Processing | +| EPPlus | สร้าง/อ่านไฟล์ Excel | +| iTextSharp | สร้างไฟล์ PDF | +| RabbitMQ.Client | Message Queue | +| NEST | Elasticsearch Client | +| ThaiBahtText | แปลงตัวเลขเป็นหน่วยบาทไทย | +| NodaTime | Date/Time Handling | +| Sentry | Error Tracking | + +--- + +## Testing + +```bash +# Run unit tests +dotnet test + +# Run with coverage +dotnet test --collect:"XPlat Code Coverage" + +# Run load tests (k6) +k6 run tests/load/*.js +``` + +--- diff --git a/dotnet_keycloak_test.js b/dotnet_keycloak_test.js new file mode 100644 index 00000000..1e623210 --- /dev/null +++ b/dotnet_keycloak_test.js @@ -0,0 +1,54 @@ +// ทดสอบการยิง 30,000 requests ในเวลา 10 นาที โดยให้กระจายการยิงในเวลาที่ต่างๆ กัน + +import { check, sleep } from "k6"; +import http from "k6/http"; +import { Rate } from "k6/metrics"; + +export let errorRate = new Rate("errors"); + +// จำนวน request ที่ต้องการยิง + +// ระยะเวลาทดสอบทั้งหมด + +// จำนวน Virtual Users เฉลี่ยที่ต้องการ 300 users +//const averageVus = Math.ceil(totalRequests / totalDuration); +const averageVus = 300; + +export let options = { + stages: [ + { duration: "2m", target: averageVus * 0.5 }, // 20% ของการทดสอบ เพิ่ม VUs เป็น 50% ของค่าเฉลี่ย + { duration: "4m", target: averageVus }, // 40% ของการทดสอบ เพิ่ม VUs เป็น 100% ของค่าเฉลี่ย + { duration: "2m", target: averageVus * 1.5 }, // 20% ของการทดสอบ เพิ่ม VUs เป็น 150% ของค่าเฉลี่ย + { duration: "2m", target: 0 }, // ลด VUs ลงมาเป็น 0 + ], + thresholds: { + errors: ["rate<0.01"], // อัตรา error ต้องน้อยกว่า 1% + http_req_duration: ["p(95)<2000"], // 95% ของ requests ควรใช้เวลาไม่เกิน 2 วินาที + }, +}; + +export default function () { + // ตัวเลือก headers + let headers = { + "Content-Type": "application/json", + Authorization: + "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ4WTJWUi1FRnZ2TlBzTXMzOXU4b29WQldRTDZtUHdyTkpPaDNrb0pGVGdVIn0.eyJleHAiOjE3NzYyMTkxNjgsImlhdCI6MTc2ODQ0MzE2OCwianRpIjoiZDQxMmI5MWEtZmZhMi00N2JiLTliZDUtZDE5NTdmMDFjYzQyIiwiaXNzIjoiaHR0cHM6Ly9ocm1zLWlkLmJhbmdrb2suZ28udGgvcmVhbG1zL2hybXMiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiYmFmYzU3OTUtYmVmYy00ZDNmLWE0NjEtMzUzM2MzOGE1ZmMxIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiZ2V0dG9rZW4tY2hlY2tpbiIsInNpZCI6IjBkNzdiY2Y5LTE4YWQtNGQyMS1hYjBjLTI4Y2ZiZjUyZGZiNCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiaHR0cHM6Ly9ocm1zLmJhbmdrb2suZ28udGgiLCJodHRwczovL2hybXMtY2hlY2tpbi5iYW5na29rLmdvLnRoIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJTVVBFUl9BRE1JTiIsInN0b3JhZ2VfbWFuYWdlbWVudCIsIm9mZmxpbmVfYWNjZXNzIiwiU1RBRkYiLCJkZWZhdWx0LXJvbGVzLWhybXMiLCJ1bWFfYXV0aG9yaXphdGlvbiIsIkFETUlOIiwiVVNFUiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgb3BlbmlkIHByb2ZpbGUiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInJvbGUiOlsiU1VQRVJfQURNSU4iLCJzdG9yYWdlX21hbmFnZW1lbnQiLCJvZmZsaW5lX2FjY2VzcyIsIlNUQUZGIiwiZGVmYXVsdC1yb2xlcy1ocm1zIiwidW1hX2F1dGhvcml6YXRpb24iLCJBRE1JTiIsIlVTRVIiXSwibmFtZSI6IuC4p-C4seC4meC5gOC4ieC4peC4tOC4oSDguInguLHguJXguKPguJfguK3guIciLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiIzMTIwMjAwNDI0OTc1IiwiZ2l2ZW5fbmFtZSI6IuC4p-C4seC4meC5gOC4ieC4peC4tOC4oSIsImZhbWlseV9uYW1lIjoi4LiJ4Lix4LiV4Lij4LiX4Lit4LiHIn0.UhMn0NEkymPxMAcb4noZedHCSqXotCyD2RziBtLYHn5OhA9yk1915Rrt9iV4wVaebr74iZ2eZMpBwp8YVy8-3cPXSv9T3vzbXwFP7IeICPCDDf4bOPFEHP5FYow2s9v48qG81wnu01AG7_EL2-CQKh1sBVrCVUUlATlf-P4lT_lHeHOCKNXTmw4V0IWm96ec6pk-jFY3KH2JdRSWR7wq8g-KVxhLOxk_pF72kMwOpdvcr_99byg28zzj6QfeNYXLt61koHXnZppUqytt86mQQgfamv2FNVywCEzbRITUceu2rmJnwQE8ubeoCh4UOsYauUuSKd7RPqvvXxL_Vg__8Q", + //"Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJTT2wwWmFidm9rRzZET3pDZVBtT09Kek5haTdMUldkci1zV3lEYjRELTc0In0.eyJleHAiOjE3Njg4ODAzMjgsImlhdCI6MTc2ODc5MzkyOCwianRpIjoiMDYxODBlMWYtNTQzYy00MjU0LWFmN2QtYWI1NDA5NzFmNWY2IiwiaXNzIjoiaHR0cHM6Ly9ocm1zYmtrLWlkLmNhc2UtY29sbGVjdGlvbi5jb20vcmVhbG1zL2hybXMiLCJhdWQiOlsiYWNjb3VudCIsImdldHRva2VuIl0sInN1YiI6IjQzOWZhMzZkLTZiYzUtNGVmNS05NWFhLWVmMjllNjRkMmU5ZiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImdldHRva2VuIiwic2lkIjoiZGI2YzUxNjItNzZhYS00MmVmLWI0ZDMtYThmOTk2N2NjZWM2IiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyIqIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJTVVBFUl9BRE1JTiIsIm9mZmxpbmVfYWNjZXNzIiwiU1RBRkYiLCJkZWZhdWx0LXJvbGVzLWhybXMiLCJ1bWFfYXV0aG9yaXphdGlvbiIsIkFETUlOIiwiVVNFUiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgb3BlbmlkIHByb2ZpbGUiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInJvbGUiOlsiU1VQRVJfQURNSU4iLCJvZmZsaW5lX2FjY2VzcyIsIlNUQUZGIiwiZGVmYXVsdC1yb2xlcy1ocm1zIiwidW1hX2F1dGhvcml6YXRpb24iLCJBRE1JTiIsIlVTRVIiXSwibmFtZSI6IuC4p-C4seC4meC5gOC4ieC4peC4tOC4oSDguInguLHguJXguKPguJfguK3guIciLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiIzMTIwMjAwNDI0OTc1IiwiZ2l2ZW5fbmFtZSI6IuC4p-C4seC4meC5gOC4ieC4peC4tOC4oSIsImZhbWlseV9uYW1lIjoi4LiJ4Lix4LiV4Lij4LiX4Lit4LiHIn0.fHdMzpHMD4JcbzYnUrfM473FSXka2Z4lz_S3HI2c-dPXfO5ATpijqsi12C6-ExE0RJRXUK671erMuyVXL6u2qj-FvdliBL3ubKy4J3jIT3svkcZxZL2ib16dRg375dITefvqd-J4vw6MR4bq8YAGPbqRIy6BQ2pdEiZgNiwUUihHAFwZlVER1lNbaqlbL6vk_L4k-g25DBVnDr756BFvrw7zEDbawkKZ31EZF5_DYk4RWej0wvWrGHQWLw-RyzYVSBB_AooqHkncHn_CwLBGC5juOEfFO4a2ThuKwoxYCstjtBj-zmjpHFs-Hh3CBTWJCGFcKst1Ey28StlKtNkLiw", + }; + + // ส่ง GET request + let response = http.get( + //"https://bma-hrms.bangkok.go.th/api/v1/leave/fake-check-in", + //"https://hrmsbkk.case-collection.com/api/v1/org/dotnet/keycloak/439fa36d-6bc5-4ef5-95aa-ef29e64d2e9f", + "https://hrms.bangkok.go.th/api/v1/org/dotnet/keycloak/bafc5795-befc-4d3f-a461-3533c38a5fc1", + { headers: headers }, + ); + + // ตรวจสอบการตอบสนอง + check(response, { + "is status 200": (r) => r.status === 200, + }); + + // หน่วงเวลา 1 วินาที + sleep(1); +} diff --git a/dotnet_leave_test.js b/dotnet_leave_test.js new file mode 100644 index 00000000..658848ec --- /dev/null +++ b/dotnet_leave_test.js @@ -0,0 +1,47 @@ +// ทดสอบการยิง 30,000 requests ในเวลา 10 นาที โดยให้กระจายการยิงในเวลาที่ต่างๆ กัน + +import { check, sleep } from "k6"; +import http from "k6/http"; +import { Rate } from "k6/metrics"; + +export let errorRate = new Rate("errors"); + +// จำนวน request ที่ต้องการยิง + +// ระยะเวลาทดสอบทั้งหมด + +// จำนวน Virtual Users เฉลี่ยที่ต้องการ 300 users +//const averageVus = Math.ceil(totalRequests / totalDuration); +const averageVus = 300; + +export let options = { + stages: [ + { duration: "2m", target: averageVus * 0.5 }, // 20% ของการทดสอบ เพิ่ม VUs เป็น 50% ของค่าเฉลี่ย + { duration: "4m", target: averageVus }, // 40% ของการทดสอบ เพิ่ม VUs เป็น 100% ของค่าเฉลี่ย + { duration: "2m", target: averageVus * 1.5 }, // 20% ของการทดสอบ เพิ่ม VUs เป็น 150% ของค่าเฉลี่ย + { duration: "2m", target: 0 }, // ลด VUs ลงมาเป็น 0 + ], + thresholds: { + errors: ["rate<0.01"], // อัตรา error ต้องน้อยกว่า 1% + http_req_duration: ["p(95)<2000"], // 95% ของ requests ควรใช้เวลาไม่เกิน 2 วินาที + }, +}; + +export default function () { + // ตัวเลือก headers + let headers = { + "Content-Type": "application/json", + Authorization: "Bearer {Token}", + }; + + // ส่ง GET request + let response = http.get("https://{URL}", { headers: headers }); + + // ตรวจสอบการตอบสนอง + check(response, { + "is status 200": (r) => r.status === 200, + }); + + // หน่วงเวลา 1 วินาที + sleep(1); +}