select * from payroll package resto.external.egais.service
import org.joda.time.LocalDate
import org.joda.time.LocalTime
import resto.back.documents.DocumentService
import resto.back.documents.DocumentValidationResult
import resto.back.documents.DocumentsDao
import resto.back.employees.payroll.Payroll
import resto.db.Guid
import resto.db.XMLConverter
import static resto.core.RestoServiceLocator.get
/**
Скрипт для редагування дати зарплатної відомості без перезапуску томкету.
Для дати закінчення буде проставлено час 23:59:59.000.
*/
// ID Платіжної відомості (встановити необхідний)
String payrollIdString = "91baa21f-81c2-483b-8188-bb98dc54a4ca"
// Нижче необхідно заповнити значення дат, які будуть задані відомості.
// Рік початку дій відомості
int dateFrom_Year = 2019
// Місяць початку дії відомості 1-12
int dateFrom_Month = 1
// День початку дії відомості 1-31
int dateFrom_Day = 1
// Рік закінчення дії відомості
int dateTo_Year = 2019
// Місяць закінчення дії відомості 1-12
int dateTo_Month = 1
// День закінчення дії відомості 1-31
int dateTo_Day = 31
Date dateFrom = новий LocalDate(dateFrom_Year, dateFrom_Month, dateFrom_Day).toDate()
Date dateTo = новий LocalDate(dateTo_Year, dateTo_Month, dateTo_Day)
.toLocalDateTime(new LocalTime(23, 59, 59)).toDate()
Guid payrollId = Guid.fromString(payrollIdString.trim())
em.runTransacted() {
DocumentsDao documentsDao = get(DocumentsDao.class)
Payroll originalDocument = documentsDao.getDocument(Payroll.class, payrollId)
if (originalDocument == null) {
out.println(String.format("Payroll %s not found", payrollIdString))
return
}
Payroll document = XMLConverter.INSTANCE.deepClone(originalDocument, false)
document.setDateFrom(dateFrom)
document.setDateTo(dateTo)
DocumentValidationResult result = DocumentService.saveOrUpdateDocumentWithValidation(document, null)
out.println(result)
} delete from payroll where id ='91baa21f-81c2-483b-8188-bb98dc54a4ca' WITH e AS (
SELECT id, revision, deleted, lastModifyNode, type
, COALESCE(
CAST ([xml] as XML).value('(/r/name/customValue)[1]', 'varchar(max)'),
CAST ([xml] as XML).value('(/r/name)[1]', 'varchar(max)')
) name
, CAST (xml як XML).value('(/r/outerEanCode)[1]', 'nvarchar(max)') outerEanCode
,CAST (xml as XML).value('(/r/num)[1]', 'nvarchar(max)') Article
,(CASE CAST ([xml] as XML).value('(/r/outerEconomicActivityNomenclatureCode)[1]', 'varchar(max)')
WHEN '' THEN NULL
ELSE CAST ([xml] as XML).value('(/r/outerEconomicActivityNomenclatureCode)[1]', 'varchar(max)')
END
) outerEconomicActivityNomenclatureCode
,CAST ([xml] as XML) xml
FROM entity
where type in ('Product','OuterEconomicActivityNomenclatureCode')
)
Виберіть e1.name,e1.Article , e2.name як outerEconomicActivityNomenclatureCode ,e2.outerEanCode
from e e1
left join e e2 on e1.outerEconomicActivityNomenclatureCode=e2.id
where e1.type='Product'
--and e2.name is not null -- якщо потрібно лише за позиціями кодами, рядок розкоментувати. update OrderPaymentEvent
set numGuests = 1
where numGuests > 1000
and date between '20180501' and '20180510' select CAST ([xml] as XML).value('(/r/userCreatedId)[1]', 'varchar(max)') userCreatedId
,CAST ([xml] as XML).value('(/r/userModifiedId)[1]', 'varchar(max)') userModifiedId
,CAST ([xml] as XML).value('(/r/description)[1]', 'varchar(max)') description
, CAST ([xml] as XML),
* від entity
where type ='IikoNewsItem'
select
COALESCE(
CAST ([xml] as XML).value('(/r/name/customValue)[1]', 'varchar(max)'),
CAST ([xml] as XML).value('(/r/name)[1]', 'varchar(max)')
) name
from entity
where id=' userCreatedId із запиту вище' truncate table AccountingTransactionSumm update AbstractDeliveryOrder
set deliveryStatus = 3, closeTime = GETDATE(), actualTime = GETDATE()
where deliveryDate < DATEADD(dd, -1, GETDATE()) and deliveryStatus not in (3,4)
select DeliveryStopListItem.product, DeliveryStopListItem.balance,
(select SUBSTRING(entity.xml, (CHARINDEX('<customValue>', entity.xml) + 13), ( CHARINDEX('</customValue>', entity.xml) - CHARINDEX('<customValue>', entity.xml) - 13 ) ) )
from DeliveryStopListItem
join entity on DeliveryStopListItem.product = entity.id
where DeliveryStopListItem.deleted = 0 delete from entity where type='DiscountCard' select * into eae_bak from EmployeeAttendanceEntry
delete from EmployeeAttendanceEntry
where personalSessionEnd is NULL
and dateto is null
and personalSessionStart <'20170901'
Update EmployeeAttendanceEntry
set dateTo = personalSessionEnd
where personalSessionEnd is Not NULL
and dateto is null
and personalSessionStart <'20170901' select * into eae_bak from EmployeeAttendanceEntry
delete from EmployeeAttendanceEntry
where personalSessionEnd is NULL
and dateto is null
and personalSessionStart <'20210301'
Update EmployeeAttendanceEntry
set dateTo = personalSessionEnd
where personalSessionEnd is Not NULL
and dateto is null
and personalSessionStart <'20210301'
delete from EmployeeAttendanceEntry
where
dateTo-dateFrom>5 and dateTo>'20210301' and comment like '%3 дн.' select * into eae_bak from EmployeeAttendanceEntry
delete from EmployeeAttendanceEntry
where personalSessionEnd is NULL
and dateto is null
and personalSessionStart <'20210301'
Update EmployeeAttendanceEntry
set dateTo = personalSessionEnd
where personalSessionEnd is Not NULL
and dateto is null
and personalSessionStart <'20210301'
delete from EmployeeAttendanceEntry
where
dateTo-dateFrom>5 and dateTo>'20210301' and comment like '%3 дн.'