|
@@ -323,43 +323,40 @@ namespace FMSApp.Repositories {
|
|
_logger.LogInformation($"작업시작일이 지나거나 당일인 실행계획 데이터를 작업지시 처리 (처리일 : {DateTime.Now})");
|
|
_logger.LogInformation($"작업시작일이 지나거나 당일인 실행계획 데이터를 작업지시 처리 (처리일 : {DateTime.Now})");
|
|
|
|
|
|
int processCount = 0;
|
|
int processCount = 0;
|
|
- using (var trans = new TransactionScope()) {
|
|
|
|
- if (_workConfigRepository.IsAutoOrder(true)) {
|
|
|
|
- _logger.LogInformation($"자동지시 전역설정 TRUE");
|
|
|
|
- // 전역설정이 자동지시로 되어있을때는 모든 실행계획 자동지시(정기,법정,교육,수시,공사)
|
|
|
|
- var query = from request in _context.FmsWorkRequest
|
|
|
|
- where request.StartWorkDate <= DateTime.Now.Date
|
|
|
|
- && request.WorkProgressId == 1
|
|
|
|
- && _context.FmsWorkOrder.Where(x => x.SiteId == request.SiteId
|
|
|
|
- && x.WorkRequestId == request.WorkRequestId
|
|
|
|
- && x.Title == request.Title).Any() == false
|
|
|
|
- select request;
|
|
|
|
- foreach (var request in query) {
|
|
|
|
- WorkToOrder(request.SiteId, request.WorkRequestId, request.RequestUserId, "");
|
|
|
|
- processCount++;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- _logger.LogInformation($"자동지시 전역설정 FALSE");
|
|
|
|
- // 전역설정이 자동지시로 되어있지 않을때는 정기점검,법정검사,법정교육 (FmsWorkSchedule 등록되어있는 실행계획) 만 자동지시
|
|
|
|
- // 기초계획에 자동지시여부가 true 인것만 자동지시
|
|
|
|
- var query = from schedule in _context.FmsWorkSchedule
|
|
|
|
- join request in _context.FmsWorkRequest on schedule.WorkScheduleId equals request.WorkScheduleId
|
|
|
|
- where schedule.IsUse == true
|
|
|
|
- && request.WorkProgressId == 1
|
|
|
|
- && schedule.IsAutoOrder == true
|
|
|
|
- && (request.StartWorkDate <= DateTime.Now.Date)
|
|
|
|
- && _context.FmsWorkOrder.Where(x => x.SiteId == request.SiteId
|
|
|
|
- && x.WorkRequestId == request.WorkRequestId
|
|
|
|
- && x.Title == request.Title).Any() == false
|
|
|
|
- select request;
|
|
|
|
- foreach (var request in query) {
|
|
|
|
- WorkToOrder(request.SiteId, request.WorkRequestId, request.RequestUserId, "");
|
|
|
|
- processCount++;
|
|
|
|
- }
|
|
|
|
|
|
+ if (_workConfigRepository.IsAutoOrder(true)) {
|
|
|
|
+ _logger.LogInformation($"자동지시 전역설정 TRUE");
|
|
|
|
+ // 전역설정이 자동지시로 되어있을때는 모든 실행계획 자동지시(정기,법정,교육,수시,공사)
|
|
|
|
+ var query = from request in _context.FmsWorkRequest
|
|
|
|
+ where request.StartWorkDate < DateTime.Now.AddDays(1).Date
|
|
|
|
+ && request.WorkProgressId == 1
|
|
|
|
+ && _context.FmsWorkOrder.Where(x => x.SiteId == request.SiteId
|
|
|
|
+ && x.WorkRequestId == request.WorkRequestId
|
|
|
|
+ && x.Title == request.Title).Any() == false
|
|
|
|
+ select request;
|
|
|
|
+ foreach (var request in query.ToList()) {
|
|
|
|
+ WorkToOrder(request.SiteId, request.WorkRequestId, request.RequestUserId, "", true);
|
|
|
|
+ processCount++;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ _logger.LogInformation($"자동지시 전역설정 FALSE");
|
|
|
|
+ // 전역설정이 자동지시로 되어있지 않을때는 정기점검,법정검사,법정교육 (FmsWorkSchedule 등록되어있는 실행계획) 만 자동지시
|
|
|
|
+ // 기초계획에 자동지시여부가 true 인것만 자동지시
|
|
|
|
+ var query = from schedule in _context.FmsWorkSchedule
|
|
|
|
+ join request in _context.FmsWorkRequest on schedule.WorkScheduleId equals request.WorkScheduleId
|
|
|
|
+ where schedule.IsUse == true
|
|
|
|
+ && request.WorkProgressId == 1
|
|
|
|
+ && schedule.IsAutoOrder == true
|
|
|
|
+ && (request.StartWorkDate < DateTime.Now.AddDays(1).Date)
|
|
|
|
+ && _context.FmsWorkOrder.Where(x => x.SiteId == request.SiteId
|
|
|
|
+ && x.WorkRequestId == request.WorkRequestId
|
|
|
|
+ && x.Title == request.Title).Any() == false
|
|
|
|
+ select request;
|
|
|
|
+ foreach (var request in query.ToList()) {
|
|
|
|
+ WorkToOrder(request.SiteId, request.WorkRequestId, request.RequestUserId, "", true);
|
|
|
|
+ processCount++;
|
|
}
|
|
}
|
|
-
|
|
|
|
- trans.Complete();
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
_logger.LogInformation($"처리완료 : {processCount}건");
|
|
_logger.LogInformation($"처리완료 : {processCount}건");
|
|
_logger.LogInformation($"=============================================================================================");
|
|
_logger.LogInformation($"=============================================================================================");
|
|
}
|
|
}
|
|
@@ -370,30 +367,27 @@ namespace FMSApp.Repositories {
|
|
_logger.LogInformation($"작업수행 처리되지 않은 작업대기 목록 자동수행 (처리일시 : {DateTime.Now})");
|
|
_logger.LogInformation($"작업수행 처리되지 않은 작업대기 목록 자동수행 (처리일시 : {DateTime.Now})");
|
|
|
|
|
|
int processCount = 0;
|
|
int processCount = 0;
|
|
- using (var trans = new TransactionScope()) {
|
|
|
|
- if (_workConfigRepository.IsAutoResult(true)) {
|
|
|
|
- _logger.LogInformation($"자동수행 전역설정 TRUE");
|
|
|
|
- var query = from order in _context.FmsWorkOrder
|
|
|
|
- join request in _context.FmsWorkRequest on order.WorkRequestId equals request.WorkRequestId
|
|
|
|
- where request.WorkProgressId == 3
|
|
|
|
- && _context.FmsWorkResult.Where(x => x.SiteId == order.SiteId
|
|
|
|
- && x.WorkRequestId == order.WorkRequestId).Any() == false
|
|
|
|
- select order;
|
|
|
|
- foreach (var order in query) {
|
|
|
|
- WorkToResult(order, new FmsWorkResult {
|
|
|
|
- StartDate = order.StartWorkDate.Date,
|
|
|
|
- EndDate = order.StartWorkDate.Date,
|
|
|
|
- Content = "",
|
|
|
|
- WorkerUserId = order.OrderUserId,
|
|
|
|
- });
|
|
|
|
- processCount++;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- _logger.LogInformation($"자동수행 전역설정 FALSE => 자동수행 안함.");
|
|
|
|
|
|
+ if (_workConfigRepository.IsAutoResult(true)) {
|
|
|
|
+ _logger.LogInformation($"자동수행 전역설정 TRUE");
|
|
|
|
+ var query = from order in _context.FmsWorkOrder
|
|
|
|
+ join request in _context.FmsWorkRequest on order.WorkRequestId equals request.WorkRequestId
|
|
|
|
+ where request.WorkProgressId == 3
|
|
|
|
+ && _context.FmsWorkResult.Where(x => x.SiteId == order.SiteId
|
|
|
|
+ && x.WorkRequestId == order.WorkRequestId).Any() == false
|
|
|
|
+ select order;
|
|
|
|
+ foreach (var order in query.ToList()) {
|
|
|
|
+ WorkToResult(order, new FmsWorkResult {
|
|
|
|
+ StartDate = order.StartWorkDate.Date,
|
|
|
|
+ EndDate = order.StartWorkDate.Date,
|
|
|
|
+ Content = "",
|
|
|
|
+ WorkerUserId = order.OrderUserId,
|
|
|
|
+ }, true);
|
|
|
|
+ processCount++;
|
|
}
|
|
}
|
|
-
|
|
|
|
- trans.Complete();
|
|
|
|
|
|
+ } else {
|
|
|
|
+ _logger.LogInformation($"자동수행 전역설정 FALSE => 자동수행 안함.");
|
|
}
|
|
}
|
|
|
|
+
|
|
_logger.LogInformation($"처리완료 : {processCount}건");
|
|
_logger.LogInformation($"처리완료 : {processCount}건");
|
|
_logger.LogInformation($"=============================================================================================");
|
|
_logger.LogInformation($"=============================================================================================");
|
|
}
|
|
}
|
|
@@ -444,7 +438,7 @@ namespace FMSApp.Repositories {
|
|
_context.SaveChanges();
|
|
_context.SaveChanges();
|
|
|
|
|
|
// 신규 WorkOrderToFacility 생성 From FmsWorkRequestToFacility
|
|
// 신규 WorkOrderToFacility 생성 From FmsWorkRequestToFacility
|
|
- foreach (var facility in persist.FmsWorkRequestToFacility) {
|
|
|
|
|
|
+ foreach (var facility in persist.FmsWorkRequestToFacility.ToList()) {
|
|
_context.FmsWorkOrderToFacility.Add(new FmsWorkOrderToFacility() {
|
|
_context.FmsWorkOrderToFacility.Add(new FmsWorkOrderToFacility() {
|
|
SiteId = facility.SiteId,
|
|
SiteId = facility.SiteId,
|
|
WorkRequestId = facility.WorkRequestId,
|
|
WorkRequestId = facility.WorkRequestId,
|
|
@@ -464,6 +458,9 @@ namespace FMSApp.Repositories {
|
|
}
|
|
}
|
|
|
|
|
|
if (trans != null) trans.Complete();
|
|
if (trans != null) trans.Complete();
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ _logger.LogError(ex, "");
|
|
|
|
+ throw ex;
|
|
} finally {
|
|
} finally {
|
|
if (trans != null) trans.Dispose();
|
|
if (trans != null) trans.Dispose();
|
|
}
|
|
}
|
|
@@ -509,7 +506,7 @@ namespace FMSApp.Repositories {
|
|
_context.SaveChanges();
|
|
_context.SaveChanges();
|
|
|
|
|
|
// 신규 FmsWorkResultToFacility 생성 From FmsWorkOrderToFacility
|
|
// 신규 FmsWorkResultToFacility 생성 From FmsWorkOrderToFacility
|
|
- foreach (var facility in order.FmsWorkOrderToFacility) {
|
|
|
|
|
|
+ foreach (var facility in order.FmsWorkOrderToFacility.ToList()) {
|
|
_context.FmsWorkResultToFacility.Add(new FmsWorkResultToFacility() {
|
|
_context.FmsWorkResultToFacility.Add(new FmsWorkResultToFacility() {
|
|
SiteId = facility.SiteId,
|
|
SiteId = facility.SiteId,
|
|
WorkRequestId = facility.WorkRequestId,
|
|
WorkRequestId = facility.WorkRequestId,
|
|
@@ -519,6 +516,9 @@ namespace FMSApp.Repositories {
|
|
_context.SaveChanges();
|
|
_context.SaveChanges();
|
|
|
|
|
|
if (trans != null) trans.Complete();
|
|
if (trans != null) trans.Complete();
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ _logger.LogError(ex, "");
|
|
|
|
+ throw ex;
|
|
} finally {
|
|
} finally {
|
|
if (trans != null) trans.Dispose();
|
|
if (trans != null) trans.Dispose();
|
|
}
|
|
}
|