Merge branch 'develop' into work
This commit is contained in:
commit
c56e3b06b9
12 changed files with 849 additions and 29 deletions
46
.github/workflows/build-local.yaml
vendored
Normal file
46
.github/workflows/build-local.yaml
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# use for local build with act
|
||||||
|
name: build-local
|
||||||
|
run-name: build-local ${{ github.actor }}
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.frappet.com
|
||||||
|
IMAGE_NAME: demo/bma-ehr-metadata-service
|
||||||
|
jobs:
|
||||||
|
# act workflow_dispatch -W .github/workflows/build-local.yaml --input IMAGE_VER=test-v6.1
|
||||||
|
build-local:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# skip Set up QEMU because it fail on act and container
|
||||||
|
- name: Gen Version
|
||||||
|
id: gen_ver
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
||||||
|
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
|
||||||
|
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: Test 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
|
||||||
|
load: true
|
||||||
|
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||||
87
.github/workflows/release_command.yaml
vendored
Normal file
87
.github/workflows/release_command.yaml
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
name: release-dev
|
||||||
|
run-name: release-dev ${{ github.actor }}
|
||||||
|
on:
|
||||||
|
# push:
|
||||||
|
# tags:
|
||||||
|
# - 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
# tags-ignore:
|
||||||
|
# - '2.*'
|
||||||
|
# Allow run workflow manually from Action tab
|
||||||
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.frappet.com
|
||||||
|
IMAGE_NAME: ehr/bma-ehr-command-service
|
||||||
|
DEPLOY_HOST: frappet.com
|
||||||
|
COMPOSE_PATH: /home/frappet/docker/bma-ehr-command
|
||||||
|
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
||||||
|
release-dev:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# skip Set up QEMU because it fail on act and container
|
||||||
|
- name: Gen Version
|
||||||
|
id: gen_ver
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
||||||
|
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
|
||||||
|
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: Test 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.Command.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: 22
|
||||||
|
script: |
|
||||||
|
cd "${{env.COMPOSE_PATH}}"
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||||
|
- uses: snow-actions/line-notify@v1.1.0
|
||||||
|
if: success()
|
||||||
|
with:
|
||||||
|
access_token: ${{ env.TOKEN_LINE }}
|
||||||
|
message: |
|
||||||
|
-Success✅✅✅
|
||||||
|
Image: ${{env.IMAGE_NAME}}
|
||||||
|
Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
By: ${{secrets.DOCKER_USER}}
|
||||||
|
- uses: snow-actions/line-notify@v1.1.0
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
access_token: ${{ env.TOKEN_LINE }}
|
||||||
|
message: |
|
||||||
|
-Failure❌❌❌
|
||||||
|
Image: ${{env.IMAGE_NAME}}
|
||||||
|
Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
By: ${{secrets.DOCKER_USER}}
|
||||||
|
|
@ -7,6 +7,8 @@ namespace BMA.EHR.Application.Common.Interfaces
|
||||||
{
|
{
|
||||||
DbSet<T> Set<T>() where T : class;
|
DbSet<T> Set<T>() where T : class;
|
||||||
|
|
||||||
|
void Attatch<T>(T entity) where T : class;
|
||||||
|
|
||||||
Task<int> SaveChangesAsync();
|
Task<int> SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Requests.Commands;
|
||||||
using BMA.EHR.Domain.Models.Commands.Core;
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Models.Placement;
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Transactions;
|
||||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Commands
|
namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
@ -39,11 +42,44 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
return await _dbContext.Set<Command>()
|
return await _dbContext.Set<Command>()
|
||||||
.Include(x => x.Placement)
|
.Include(x => x.Placement)
|
||||||
.Include(x => x.CommandType)
|
.Include(x => x.CommandType)
|
||||||
|
.Include(x => x.Documents)
|
||||||
|
.Include(x => x.Receivers)
|
||||||
|
.Include(x => x.CommandStatus)
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<IReadOnlyList<Command>> GetAllAsync()
|
||||||
|
{
|
||||||
|
return await _dbContext.Set<Command>()
|
||||||
|
.Include(x => x.Placement)
|
||||||
|
.Include(x => x.CommandType)
|
||||||
|
.Include(x => x.CommandStatus)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<Command> AddAsync(Command command)
|
||||||
|
{
|
||||||
|
var status = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == 1);
|
||||||
|
command.CommandStatus = status!;
|
||||||
|
_dbContext.Attatch(status!);
|
||||||
|
|
||||||
|
return await base.AddAsync(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<Command> UpdateAsync(Command entity)
|
||||||
|
{
|
||||||
|
// attatch
|
||||||
|
_dbContext.Attatch(entity.CommandStatus);
|
||||||
|
_dbContext.Attatch(entity.CommandType);
|
||||||
|
_dbContext.Attatch(entity.Placement);
|
||||||
|
|
||||||
|
return await base.UpdateAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " Command Receiver "
|
||||||
|
|
||||||
public async Task<List<CommandReceiver>> GetReceiverByCommmandIdAsync(Guid Id)
|
public async Task<List<CommandReceiver>> GetReceiverByCommmandIdAsync(Guid Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -135,6 +171,89 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<CommandReceiver?> GetCommandReceiverAsync(Guid personalId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var receiver = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
|
||||||
|
if (receiver == null)
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
|
return receiver;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SwapReceiverOrderAsync(Guid personalId, string direction)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var current = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
|
||||||
|
if (current == null)
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
|
var currentSeq = current.Sequence;
|
||||||
|
|
||||||
|
switch (direction.Trim().ToLower())
|
||||||
|
{
|
||||||
|
case "up":
|
||||||
|
{
|
||||||
|
// get prev record
|
||||||
|
var prev = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.OrderByDescending(x => x.Sequence)
|
||||||
|
.Where(x => x.Sequence < currentSeq)
|
||||||
|
.Take(1)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (prev != null)
|
||||||
|
{
|
||||||
|
var prevSeq = prev.Sequence;
|
||||||
|
|
||||||
|
current.Sequence = prevSeq;
|
||||||
|
prev.Sequence = currentSeq;
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "down":
|
||||||
|
{
|
||||||
|
// get next record
|
||||||
|
var next = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.OrderBy(x => x.Sequence)
|
||||||
|
.Where(x => x.Sequence > currentSeq)
|
||||||
|
.Take(1)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (next != null)
|
||||||
|
{
|
||||||
|
var nextSeq = next.Sequence;
|
||||||
|
|
||||||
|
current.Sequence = nextSeq;
|
||||||
|
next.Sequence = currentSeq;
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: throw new Exception("Invalid swap direction!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public async Task<List<CommandDeployment>> GetDeploymentByCommandIdAsync(Guid id)
|
public async Task<List<CommandDeployment>> GetDeploymentByCommandIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -314,6 +433,54 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
||||||
#region " Documents "
|
#region " Documents "
|
||||||
|
|
||||||
|
public async Task<List<CommandDocument>> GetExistDocument(Guid id, string category)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _dbContext.Set<Command>()
|
||||||
|
.Include(x => x.Documents)
|
||||||
|
.ThenInclude(x => x.Document)
|
||||||
|
.FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
// insert new record to comand Document
|
||||||
|
var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||||
|
|
||||||
|
return exist;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UploadDocument(Guid id, string category, CommandDocument document)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _dbContext.Set<Command>().Include(x => x.Documents).FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
// insert new record to comand Document
|
||||||
|
var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||||
|
if (exist.Any())
|
||||||
|
{
|
||||||
|
_dbContext.Set<CommandDocument>().RemoveRange(exist);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert new Record
|
||||||
|
command.Documents.Add(document);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<CommandDocument>> GetCommandDocumentAsync(Guid id)
|
public async Task<List<CommandDocument>> GetCommandDocumentAsync(Guid id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -334,12 +501,116 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " Change Command Status "
|
||||||
|
|
||||||
|
public async Task GotoNextStateAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _dbContext.Set<Command>().Include(c => c.CommandStatus).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
var notProcess = new int[] { 4, 5 };
|
||||||
|
|
||||||
|
if (!notProcess.Contains(command.CommandStatus.Sequence))
|
||||||
|
{
|
||||||
|
var nextStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == command.CommandStatus.Sequence + 1);
|
||||||
|
command.CommandStatus = nextStatus!;
|
||||||
|
_dbContext.Attatch(nextStatus!);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GotoPrevStateAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _dbContext.Set<Command>().Include(c => c.CommandStatus).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
var notProcess = new int[] { 1, 5 };
|
||||||
|
|
||||||
|
if (!notProcess.Contains(command.CommandStatus.Sequence))
|
||||||
|
{
|
||||||
|
var nextStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == command.CommandStatus.Sequence - 1);
|
||||||
|
command.CommandStatus = nextStatus!;
|
||||||
|
_dbContext.Attatch(nextStatus!);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Change Detail Sequence "
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Placement "
|
||||||
|
|
||||||
|
public async Task UpdatePlacementSalaryAsync(Guid placementProfileId, UpdatePlacementSalaryRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var placementProfile = await _dbContext.Set<PlacementProfile>()
|
||||||
|
.FirstOrDefaultAsync(p => p.Id == placementProfileId);
|
||||||
|
|
||||||
|
if (placementProfile == null)
|
||||||
|
throw new Exception($"Invalid placement profile: {placementProfileId}");
|
||||||
|
|
||||||
|
placementProfile.Amount = req.SalaryAmount;
|
||||||
|
placementProfile.PositionSalaryAmount = req.PositionSalaryAmount;
|
||||||
|
placementProfile.MouthSalaryAmount = req.MonthSalaryAmount;
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<PositionPath>> GetPlacementPositionPath(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _dbContext.Set<PlacementProfile>()
|
||||||
|
.Include(x => x.PositionPath)
|
||||||
|
.Include(x => x.Placement)
|
||||||
|
.Where(x => x.Placement!.Id == id)
|
||||||
|
.Where(x => x.PositionPath != null)
|
||||||
|
.Select(x => x.PositionPath)
|
||||||
|
.Distinct()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return data!;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate)
|
public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = await _dbContext.Set<Command>().FirstOrDefaultAsync(x => x.Id == id);
|
var command = await _dbContext.Set<Command>().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
if(command == null)
|
if (command == null)
|
||||||
throw new Exception(GlobalMessages.CommandNotFound);
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
command.CommandExcecuteDate = signDate;
|
command.CommandExcecuteDate = signDate;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
@ -49,12 +50,12 @@ namespace BMA.EHR.Application.Repositories
|
||||||
|
|
||||||
public virtual async Task<T> AddAsync(T entity)
|
public virtual async Task<T> AddAsync(T entity)
|
||||||
{
|
{
|
||||||
//if (entity is IAuditableEntity)
|
if (entity is EntityBase)
|
||||||
//{
|
{
|
||||||
// (entity as IAuditableEntity).CreatedUserId = Guid.Parse(UserId);
|
(entity as EntityBase).CreatedUserId = UserId!;
|
||||||
// (entity as IAuditableEntity).CreatedUserFullName = FullName;
|
(entity as EntityBase).CreatedFullName = FullName!;
|
||||||
// (entity as IAuditableEntity).CreatedDate = DateTime.Now;
|
(entity as EntityBase).CreatedAt = DateTime.Now;
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
await _dbSet.AddAsync(entity);
|
await _dbSet.AddAsync(entity);
|
||||||
|
|
@ -65,12 +66,12 @@ namespace BMA.EHR.Application.Repositories
|
||||||
|
|
||||||
public virtual async Task<T> UpdateAsync(T entity)
|
public virtual async Task<T> UpdateAsync(T entity)
|
||||||
{
|
{
|
||||||
//if (entity is IAuditableEntity)
|
if (entity is EntityBase)
|
||||||
//{
|
{
|
||||||
// (entity as IAuditableEntity).ModifiedUserId = Guid.Parse(UserId);
|
(entity as EntityBase).LastUpdateUserId = UserId!;
|
||||||
// (entity as IAuditableEntity).ModifiedUserFullName = FullName;
|
(entity as EntityBase).LastUpdateFullName = FullName!;
|
||||||
// (entity as IAuditableEntity).ModifiedDate = DateTime.Now;
|
(entity as EntityBase).LastUpdatedAt = DateTime.Now;
|
||||||
//}
|
}
|
||||||
|
|
||||||
_dbSet.Update(entity);
|
_dbSet.Update(entity);
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace BMA.EHR.Application.Requests.Commands
|
||||||
|
{
|
||||||
|
public class UpdatePlacementSalaryRequest
|
||||||
|
{
|
||||||
|
public double SalaryAmount { get; set; } = 0;
|
||||||
|
|
||||||
|
public double PositionSalaryAmount { get; set; } = 0;
|
||||||
|
|
||||||
|
public double MonthSalaryAmount { get; set; } = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,6 +39,18 @@
|
||||||
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="wwwroot\index.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\keycloak.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\keycloak.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="SeedCommand.xlsx">
|
<None Update="SeedCommand.xlsx">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using BMA.EHR.Application.Repositories;
|
using Amazon.S3.Model.Internal.MarshallTransformations;
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
|
using BMA.EHR.Application.Requests.Commands;
|
||||||
using BMA.EHR.Command.Service.Requests;
|
using BMA.EHR.Command.Service.Requests;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
|
|
@ -31,6 +33,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
private readonly MinIOService _documentService;
|
private readonly MinIOService _documentService;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
private readonly PrefixRepository _prefixRepository;
|
private readonly PrefixRepository _prefixRepository;
|
||||||
|
private readonly CommandTypeRepository _commandTypeRepository;
|
||||||
|
private readonly CommandStatusRepository _commandStatusRepository;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -41,7 +45,9 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
ApplicationDBContext context,
|
ApplicationDBContext context,
|
||||||
MinIOService documentService,
|
MinIOService documentService,
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
GenericRepository<Guid, Prefix> prefixRepository)
|
PrefixRepository prefixRepository,
|
||||||
|
CommandTypeRepository commandTypeRepository,
|
||||||
|
CommandStatusRepository commandStatusRepository)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
@ -49,6 +55,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_placementRepository = placementRepository;
|
_placementRepository = placementRepository;
|
||||||
_prefixRepository = prefixRepository;
|
_prefixRepository = prefixRepository;
|
||||||
|
_commandTypeRepository = commandTypeRepository;
|
||||||
|
_commandStatusRepository = commandStatusRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -68,6 +76,9 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// แสดงปีเป็นปีพุทธศักราช โดยดึงจากข้อมูลที่มีในระบบ
|
/// แสดงปีเป็นปีพุทธศักราช โดยดึงจากข้อมูลที่มีในระบบ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ถ้าไม่มีข้อมูลเลยจะ default ปีปัจจุบันให้ 1 รายการ
|
||||||
|
/// </remarks>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -76,22 +87,153 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<ResponseObject>> GetFiscal()
|
public async Task<ActionResult<ResponseObject>> GetFiscalAsync()
|
||||||
{
|
{
|
||||||
var data = await _repository.GetAllAsync();
|
var data = await _repository.GetAllAsync();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
var _data = data.GroupBy(x => x.CommandYear).Select(x => new
|
var _data = data.GroupBy(x => x.CommandYear).Select(x => new
|
||||||
{
|
{
|
||||||
Id = x.FirstOrDefault().CommandYear,
|
Id = x.FirstOrDefault().CommandYear.ToInteger().ToCeYear(),
|
||||||
Name = x.FirstOrDefault().CommandYear + 543,
|
Name = x.FirstOrDefault().CommandYear.ToInteger().ToThaiYear(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
if (_data == null || _data.Count == 0)
|
||||||
|
{
|
||||||
|
_data!.Add(new
|
||||||
|
{
|
||||||
|
Id = DateTime.Now.Year,
|
||||||
|
Name = DateTime.Now.Year.ToThaiYear()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Success(_data);
|
return Success(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success(data);
|
return Success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// แสดงประเภทคำสั่ง โดยดึงจากข้อมูลที่มีในระบบ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("order-type")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetCommandTypeAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = (await _commandTypeRepository.GetAllAsync()).OrderBy(x => x.CommandCode);
|
||||||
|
|
||||||
|
return Success(data);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ตรวจสอบความพร้อมในการออกคำสั่ง
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns>
|
||||||
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("ready/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> CheckReadyToExcecuteAsync(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _repository.GetByIdAsync(orderId);
|
||||||
|
if (command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
var cover = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_COVER);
|
||||||
|
var attatchment = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_ATTACHMENT);
|
||||||
|
|
||||||
|
if (command.CommandNo != "" &&
|
||||||
|
command.CommandYear != null &&
|
||||||
|
command.CommandExcecuteDate != null &&
|
||||||
|
cover != null &&
|
||||||
|
attatchment != null)
|
||||||
|
{
|
||||||
|
return Success(new { result = "Y" });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return Success(new { result = "N" });
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เปลี่ยน status ของคำสั่งไปขั้นตอนถัดไป
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns>
|
||||||
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("next/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GoToNextState(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _repository.GotoNextStateAsync(orderId);
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เปลี่ยน status ของคำสั่งไปขั้นตอนก่อนหน้า
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns>
|
||||||
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("prev/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GoToPrevState(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _repository.GotoPrevStateAsync(orderId);
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PM7-19 : หน้าจอรายการออกคำสั่ง
|
/// PM7-19 : หน้าจอรายการออกคำสั่ง
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -110,6 +252,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
var data = (await _repository.GetAllAsync())
|
var data = (await _repository.GetAllAsync())
|
||||||
.Select(d => new
|
.Select(d => new
|
||||||
{
|
{
|
||||||
|
OrderId = d.Id,
|
||||||
OrderName = d.CommandSubject,
|
OrderName = d.CommandSubject,
|
||||||
OrderNo = d.CommandNo,
|
OrderNo = d.CommandNo,
|
||||||
FiscalYear = d.CommandYear,
|
FiscalYear = d.CommandYear,
|
||||||
|
|
@ -170,7 +313,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpGet("{orderId}")]
|
[HttpGet("detail/{orderId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -193,7 +336,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
orderBy = data.IssuerOrganizationId,
|
orderBy = data.IssuerOrganizationId,
|
||||||
signatoryBy = data.AuthorizedUserFullName,
|
signatoryBy = data.AuthorizedUserFullName,
|
||||||
signatoryPosition = data.AuthorizedPosition,
|
signatoryPosition = data.AuthorizedPosition,
|
||||||
examRound = data.Placement.Round,
|
examRound = data.Placement.Id,
|
||||||
registerPosition = "",
|
registerPosition = "",
|
||||||
conclusionRegisterNo = data.ConclusionRegisterNo,
|
conclusionRegisterNo = data.ConclusionRegisterNo,
|
||||||
conclusionRegisterDate = data.ConclusionRegisterDate,
|
conclusionRegisterDate = data.ConclusionRegisterDate,
|
||||||
|
|
@ -217,7 +360,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost]
|
[HttpPost("detail")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -239,7 +382,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
ConclusionRegisterNo = req.conclusionRegisterNo,
|
ConclusionRegisterNo = req.conclusionRegisterNo,
|
||||||
ConclusionRegisterDate = req.conclusionRegisterDate,
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
||||||
ConclusionResultNo = req.conclusionResultNo,
|
ConclusionResultNo = req.conclusionResultNo,
|
||||||
ConclusionResultDate = req.conclusionResultDate
|
ConclusionResultDate = req.conclusionResultDate,
|
||||||
|
CommandAffectDate = req.orderDate
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = await _repository.AddAsync(inserted);
|
var result = await _repository.AddAsync(inserted);
|
||||||
|
|
@ -252,6 +396,57 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("detail/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PutAsync(Guid orderId, [FromBody] CreateCommandRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var order = await _repository.GetByIdAsync(orderId);
|
||||||
|
if (order == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
||||||
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
||||||
|
var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
||||||
|
|
||||||
|
order.CommandNo = req.orderNo.ToString();
|
||||||
|
order.CommandYear = req.orderYear.ToString();
|
||||||
|
order.CommandSubject = req.orderTitle;
|
||||||
|
order.PositionName = req.registerPosition;
|
||||||
|
order.CommandType = commandType!;
|
||||||
|
order.IssuerOrganizationId = req.orderBy;
|
||||||
|
order.AuthorizedUserFullName = req.signatoryBy;
|
||||||
|
order.AuthorizedPosition = req.signatoryPosition;
|
||||||
|
order.Placement = placement!;
|
||||||
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
||||||
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
||||||
|
order.ConclusionResultNo = req.conclusionResultNo;
|
||||||
|
order.ConclusionResultDate = req.conclusionResultDate;
|
||||||
|
order.CommandStatus = status!;
|
||||||
|
order.CommandAffectDate = req.orderDate;
|
||||||
|
|
||||||
|
var result = await _repository.UpdateAsync(order);
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PM7-24 : dropdown รอบการสอบ หน้ารายละเอียดการออกคำสั่ง
|
/// PM7-24 : dropdown รอบการสอบ หน้ารายละเอียดการออกคำสั่ง
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -543,17 +738,17 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = await _repository.GetByIdAsync(orderId);
|
var command = await _repository.GetByIdAsync(orderId);
|
||||||
if(command == null)
|
if (command == null)
|
||||||
throw new Exception(GlobalMessages.CommandNotFound);
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
var documents = await _repository.GetCommandDocumentAsync(orderId);
|
var documents = await _repository.GetCommandDocumentAsync(orderId);
|
||||||
var cover = documents.Where(x => x.Category.Trim().ToLower() == "cover").FirstOrDefault();
|
var cover = documents.Where(x => x.Category.Trim().ToLower() == GlobalConstants.TYPE_COVER).FirstOrDefault();
|
||||||
var attach = documents.Where(x => x.Category.Trim().ToLower() == "attachment").FirstOrDefault();
|
var attach = documents.Where(x => x.Category.Trim().ToLower() == GlobalConstants.TYPE_ATTACHMENT).FirstOrDefault();
|
||||||
|
|
||||||
var result = new
|
var result = new
|
||||||
{
|
{
|
||||||
orderNo=command.CommandNo,
|
orderNo = command.CommandNo,
|
||||||
orderYear=command.CommandYear,
|
orderYear = command.CommandYear,
|
||||||
signDate = command.CommandExcecuteDate,
|
signDate = command.CommandExcecuteDate,
|
||||||
orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId),
|
orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId),
|
||||||
attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId),
|
attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId),
|
||||||
|
|
@ -567,6 +762,109 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-35 : อัปโหลดไฟล์คำสั่ง
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("attachment/order-file/{orderId}"), DisableRequestSizeLimit]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UploadCommandCoverAsync(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// check upload file
|
||||||
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||||
|
{
|
||||||
|
return Error(GlobalMessages.NoFileToUpload);
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = Request.Form.Files[0];
|
||||||
|
|
||||||
|
// get exit file
|
||||||
|
var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_COVER);
|
||||||
|
|
||||||
|
// delete exist document from s3
|
||||||
|
foreach (var doc in docs)
|
||||||
|
{
|
||||||
|
await _documentService.DeleteFileAsync(doc.Document.ObjectRefId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// upload new document to s3
|
||||||
|
var cover = await _documentService.UploadFileAsync(file);
|
||||||
|
|
||||||
|
// create new CommandDocumentEntity
|
||||||
|
var commandDoc = new CommandDocument
|
||||||
|
{
|
||||||
|
Category = GlobalConstants.TYPE_COVER,
|
||||||
|
Document = cover,
|
||||||
|
};
|
||||||
|
|
||||||
|
// send to repo to save in database
|
||||||
|
await _repository.UploadDocument(orderId, GlobalConstants.TYPE_COVER, commandDoc);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-36 : อัปโหลดไฟล์เอกสารแนบท้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("attachment/file/{orderId}"), DisableRequestSizeLimit]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UploadCommandAttachmentAsync(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// check upload file
|
||||||
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||||
|
{
|
||||||
|
return Error(GlobalMessages.NoFileToUpload);
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = Request.Form.Files[0];
|
||||||
|
|
||||||
|
// get exit file
|
||||||
|
var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_ATTACHMENT);
|
||||||
|
|
||||||
|
// delete exist document from s3
|
||||||
|
foreach (var doc in docs)
|
||||||
|
{
|
||||||
|
await _documentService.DeleteFileAsync(doc.Document.ObjectRefId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// upload new document to s3
|
||||||
|
var cover = await _documentService.UploadFileAsync(file);
|
||||||
|
|
||||||
|
// create new CommandDocumentEntity
|
||||||
|
var commandDoc = new CommandDocument
|
||||||
|
{
|
||||||
|
Category = GlobalConstants.TYPE_ATTACHMENT,
|
||||||
|
Document = cover,
|
||||||
|
};
|
||||||
|
|
||||||
|
// send to repo to save in database
|
||||||
|
await _repository.UploadDocument(orderId, GlobalConstants.TYPE_ATTACHMENT, commandDoc);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -594,6 +892,81 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// บันทึกข้อมูลเงินเดือนสำหรับผู้บรรจุ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("salary/{id}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdatePlacementSalaryAsync(Guid personalId, [FromBody] UpdatePlacementSalaryRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var receiver = await _repository.GetCommandReceiverAsync(personalId);
|
||||||
|
|
||||||
|
if (receiver == null)
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
|
await _repository.UpdatePlacementSalaryAsync(personalId, req);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// สลับลำดับข้อมูลในบัญชีแนบท้ายขึ้น
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("swap/up/{personalId}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> SwapUpReceiverOrderAsync(Guid personalId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _repository.SwapReceiverOrderAsync(personalId, "up");
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// สลับลำดับข้อมูลในบัญชีแนบท้ายลง
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("swap/down/{personalId}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> SwapDownReceiverOrderAsync(Guid personalId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _repository.SwapReceiverOrderAsync(personalId, "down");
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
public int orderYear { get; set; }
|
public int orderYear { get; set; }
|
||||||
|
|
||||||
|
public DateTime orderDate { get; set; }
|
||||||
|
|
||||||
public Guid orderBy { get; set; }
|
public Guid orderBy { get; set; }
|
||||||
|
|
||||||
public string signatoryBy { get; set; }
|
public string signatoryBy { get; set; }
|
||||||
|
|
|
||||||
8
BMA.EHR.Domain/Shared/GlobalConstants.cs
Normal file
8
BMA.EHR.Domain/Shared/GlobalConstants.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BMA.EHR.Domain.Shared
|
||||||
|
{
|
||||||
|
public class GlobalConstants
|
||||||
|
{
|
||||||
|
public static readonly string TYPE_ATTACHMENT = "attachment";
|
||||||
|
public static readonly string TYPE_COVER = "cover";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
public static readonly string FileNotFoundOnServer = "ไม่พบไฟล์ในระบบ!!";
|
public static readonly string FileNotFoundOnServer = "ไม่พบไฟล์ในระบบ!!";
|
||||||
|
|
||||||
|
public static readonly string NoFileToUpload = "ไม่พบไฟล์ที่ทำการอัพโหลด!";
|
||||||
|
|
||||||
#region " Meta Data "
|
#region " Meta Data "
|
||||||
|
|
||||||
public static readonly string DataExist5 = "เนื่องจากมีการกำหนดวันหยุดในการทำงาน 5 วันอยู่";
|
public static readonly string DataExist5 = "เนื่องจากมีการกำหนดวันหยุดในการทำงาน 5 วันอยู่";
|
||||||
|
|
|
||||||
|
|
@ -317,5 +317,10 @@ namespace BMA.EHR.Infrastructure.Persistence
|
||||||
{
|
{
|
||||||
return base.SaveChangesAsync();
|
return base.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Attatch<T>(T entity) where T : class
|
||||||
|
{
|
||||||
|
Attach(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue