sql Criaçãoauditorias MonteSerrat V2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Criaçãoauditorias MonteSerrat V2相关的知识,希望对你有一定的参考价值。
--select top 100 * from tm.task where name like '%audit%' order by 1 desc
--select * from ra.BusinessStructureList order by 1 desc
--select top 100 * from tm.schedconfig order by 1 desc
--### Após configurar tm.SchedConfig, SOMENTE SE PRECISAR LIBERAR TAREFA URGENTE, chamar serviço abaixo:
--### http://54.94.177.227:8081/MRS.Services/TaskJobService/CreateScheduledTasks
--begin tran / commit / rollback
--### PREENCHER ###
DECLARE @RetailStoreId VARCHAR(18) SET @RetailStoreId='S0004'
DECLARE @Data VARCHAR(18) SET @Data = '2017-06-14'
--### NÃO PREENCHER - É AUTOMÁTICO ###
DECLARE @Name VARCHAR(100) SET @Name = 'Auditoria de Preço - ' + @RetailStoreId + ' - ' + @Data
DECLARE @Description VARCHAR(256) SET @Description = @Name
DECLARE @TaskStartDate DATETIME SET @TaskStartDate = @Data + ' 03:00:00.000' -- Exemplo: 2017-06-09 03:00:00.000 (UTC!!) - Horário que tarefa deve ser iniciada/disponibilizada
DECLARE @TaskEndDate DATETIME SET @TaskEndDate = @Data + ' 23:30:00.000' -- Exemplo: 2017-06-09 23:30:00.000 (UTC!!!) - Horário que tarefa deve ser finalizada
DECLARE @DayOfWeek VARCHAR(1) SET @DayOfWeek = DATEPART(dw, @Data)-1
DECLARE @DayOfMonth VARCHAR(2) SET @DayOfMonth = DATEPART(d, @Data)
DECLARE @Month VARCHAR(2) SET @Month = DATEPART(m, @Data)
--### MONTA CRONTAB ###
DECLARE @CrontabExpression VARCHAR(256)
SET @CrontabExpression = '0 3 ' + @DayOfMonth + ' ' + @Month + ' ' + @DayOfWeek -- Exemplo: 0 3 9 6 5 (0=minuto, 3=hora, 9=dia do mês, 6=mes, 5=dia da semana sendo 5 sexta)
-- ### MONTA LOCATIONLIST ###
DECLARE @LocationListId NUMERIC(10,0)
SET @LocationListId=(
CASE
WHEN @RetailStoreId='S0001' THEN (SELECT LocationListId FROM tm.LocationList WHERE Description='Loja Monte Serrat 1')
WHEN @RetailStoreId='S0002' THEN (SELECT LocationListId FROM tm.LocationList WHERE Description='Loja Monte Serrat 2')
WHEN @RetailStoreId='S0004' THEN (SELECT LocationListId FROM tm.LocationList WHERE Description='Loja Monte Serrat 4')
END
)
-- ### MONTA ITEMGROUP ###
DECLARE @ItemGroupId INT
SET @ItemGroupId = (SELECT ItemGroupId FROM ra.ItemGroup WHERE Name LIKE '%' + @RetailStoreId + '%' + @Data + '%')
-- ### INSERE AGENDAMENTO ###
INSERT INTO [tm].[SchedConfig] ([ActionId],[Name],[Description],[Status],[CrontabExpression],[TaskStartDate],[TaskEndDate]
,[CreateUser],[CreateDate],[LastUpdateUser],[LastUpdateDate],[ChecklistId],[LocationListId],[BusinessStructureId]
,[TargetProfileId],[ItemGroupId],[StoreSectionId],[Scope],[ResolutionType],[SharedCloseType],[IsItemGroupOriented],[GenerateTaskByDepartment])
VALUES
(1, --<ActionId, numeric(10,0),>
@Name, --<Name, varchar(100),>
@Description, --<Description, varchar(256),>
'A', --<Status, char(1),>
@CrontabExpression, --<CrontabExpression, varchar(256),>
@TaskStartDate, --<TaskStartDate, datetime,>
@TaskEndDate, --<TaskEndDate, datetime,>
'admbo', --<CreateUser, varchar(60),>
GETDATE(), --<CreateDate, datetime,>
'admbo', --<LastUpdateUser, varchar(60),>
GETDATE(), --<LastUpdateDate, datetime,>
NULL, --<ChecklistId, numeric(10,0),>
@LocationListId, --<LocationListId, numeric(10,0),>
NULL, --<BusinessStructureId, numeric(10,0),>
82, --<TargetProfileId, numeric(10,0),>
@ItemGroupId, --<ItemGroupId, numeric(10,0),>
2, --<StoreSectionId, numeric(10,0),>
'S', --<Scope, varchar(50),>
NULL, --<ResolutionType, varchar(10),>
NULL, --<SharedCloseType, varchar(10),>
1, --<IsItemGroupOriented, numeric(1,0),>
0 --<GenerateTaskByDepartment, numeric(1,0),>
)
GO
以上是关于sql Criaçãoauditorias MonteSerrat V2的主要内容,如果未能解决你的问题,请参考以下文章
sql 蒙特塞拉特 - Criação手册Inventário#tags:monteserrat
markdown Criaçãoeconfiguraçãodeconta