Commit d9246323 authored by solho's avatar solho

Initial commit

parents
select a.*
from esn_Todos a
left join esn_todos_points b on a.sn=b.sn
where b.date_points_settlement between '2021-07-01' and '2021-07-31'
--批次生成
begin tran tran1
declare @dateStart varchar(10)='2021-06-01',@dateEnd varchar(10)='2021-6-30'
--清除結算日期
update esn_todos_points set date_points_settlement=null
from
(
select a.*
from esn_Todos a
left join esn_todos_points b on a.sn=b.sn
where b.date_points_settlement between @dateStart and @dateEnd
and a.sn in(885723,885774,888378,889285,892131,893586,896663,897707,898021,898375,898386,898462,898471,898548,898565,898575,898664,899220,899265,899307,899718,900054,900557,900558,900559,900592,901214,902051,902076,902079,902135,905261,905277,905301,905374,905384,905385,905456,905465,905468,905781,912904,912949,912952,913247,914667)
) as aa
where aa.sn=esn_todos_points.sn
rollback tran tran1
--重置審核
update esn_todos_Flow set Is_Settlement=0,StepType_id=2
from
(
select a.*
from esn_Todos a
left join esn_todos_points b on a.sn=b.sn
left join esn_todos_Flow c on a.sn=c.esn_todos_sn
where b.date_points_settlement between @dateStart and @dateEnd or c.StepType_id=5
) as aa
where aa.sn=esn_todos_Flow.esn_todos_sn
--commit tran tran1
rollback tran tran1
--重置審核 END
--審核資料生成
begin tran tran1
declare @FinishedDateStart varchar(10)='2021-05-01',@FinishedDateEnd varchar(10)='2021-05-31'
truncate table esn_todos_Flow;
truncate table esn_todos_Flow_his;
insert into esn_todos_Flow(esn_todos_sn,StepType_id,StepType_id_Previous,PG_IsConfirm,PE_IsConfirm,Leader_IsConfirm,Description,create_user_id,Create_time,update_user_id,Update_time,Is_Settlement)
select esn_todos_sn=a.sn,StepType_id=5,StepType_id_Previous=5,PG_IsConfirm=1,PE_IsConfirm=0,Leader_IsConfirm=0,Description=''
,create_user_id='C253F126-77AC-41DE-8776-CA1DE5A0680F'
,Create_time=GETDATE(),update_user_id='C253F126-77AC-41DE-8776-CA1DE5A0680F',Update_time=GETDATE(),Is_Settlement=1
from esn_Todos a
left join esn_todos_points b on a.sn=b.sn
left join esn_Todos_auto_points c on a.sn=c.sn
left join evw_Employee d on a.AssignedTo_userid=d.user_id
where a.FinishedDate between @FinishedDateStart and @FinishedDateEnd
and b.date_points_settlement between @FinishedDateStart and @FinishedDateEnd
and (c.points_tobe <>0 or a.Points <>0)
and d.Emp_DS not like '%外包所%'
;
insert into esn_todos_Flow(esn_todos_sn,StepType_id,StepType_id_Previous,PG_IsConfirm,PE_IsConfirm,Leader_IsConfirm,Description,create_user_id,Create_time,update_user_id,Update_time,Is_Settlement)
select esn_todos_sn=a.sn,StepType_id=2,StepType_id_Previous=1,PG_IsConfirm=1,PE_IsConfirm=0,Leader_IsConfirm=0,Description=''
,create_user_id='C253F126-77AC-41DE-8776-CA1DE5A0680F'
,Create_time=GETDATE(),update_user_id='C253F126-77AC-41DE-8776-CA1DE5A0680F',Update_time=GETDATE(),Is_Settlement=0
from esn_Todos a
left join esn_todos_points b on a.sn=b.sn
left join esn_Todos_auto_points c on a.sn=c.sn
left join evw_Employee d on a.AssignedTo_userid=d.user_id
where a.FinishedDate between @FinishedDateStart and @FinishedDateEnd
and isnull(b.date_points_settlement,'')=''
and (c.points_tobe <>0 or a.Points <>0)
and d.Emp_DS not like '%外包所%'
--select * from esn_todos_Flow
commit tran tran1
select * from esn_todos_Flow a 
select * from esn_todos_Flow_StepType a 
--rollback tran tran1
--審核資料生成 END
--批次生成 END
select a.create_user_id,a.*,c.* from esn_todos_Flow a
inner join esn_Todos b on a.esn_todos_sn=b.sn
inner join evw_Employee c on b.AssignedTo_userid=c.user_id
where b.FinishedDate between '2021-02-01' and '2021-03-31'
--批次生成預設關帳資料
truncate table [esn_todos_Settle]
declare @Settle_Date varchar(10)='2021-08-01'
insert into [esn_todos_Settle] (Settle_Date,isClosed,DSNum,DeptNum,ItemNum,update_user_id,update_time,Create_user_id,Create_time)
select @Settle_Date as Settle_Date,1 as isClosed,a.Emp_DSNum as DSNum,'' as DeptNum,'' as ItemNum,'cb76971e-22d1-4f81-ade1-03c280f68cce' as update_user_id
,getdate() as update_time,'cb76971e-22d1-4f81-ade1-03c280f68cce' as Create_user_id,getdate() as Create_time
from [evw_qResult_EmpDS] a
--DSNUM To targetid
begin tran tran1
update esn_todos_Settle set DSNum=s.ID
from (
select a.DSNum ,b.ID from esn_todos_Settle a
left join evw_qResult_EmpDS b on a.DSNum=b.Emp_DSNum
) s
where esn_todos_Settle.DSNum=s.DSNum
select * from esn_todos_Settle
rollback tran tran1
--other
select * from [evw_qResult_EmpDS]
order
SELECT top 1 CONVERT(varchar(7),Settle_Date,126)+'-01' from [esn_todos_Settle] a
left join [evw_qResult_EmpDS] b on a.DSNum=b.Emp_DSNum
left join [evw_qResult_Dept] c on a.DeptNum=c.targetID
left join [evw_qResult_EmpItem] d on a.ItemNum=d.Emp_ItemNum
where 1=1
and isClosed=0 and b.ID in(11328,11329,1101949,1101951,1109009) order by a.Settle_Date
select Settle_Date as 結算日期,isClosed as 已關帳,Emp_DS as 所別 from [esn_todos_Settle] a
left join [evw_qResult_EmpDS] b on a.DSNum=b.Emp_DSNum
left join [evw_qResult_Dept] c on a.DeptNum=c.targetID
left join [evw_qResult_EmpItem] d on a.ItemNum=d.Emp_ItemNum
where 1=1 and isClosed=1 and b.ID in(11328,11329,1101949,1101951,1109009)
select * from [esn_todos_Settle]
/****** SSMS 中 SelectTopNRows 命令的指令碼 ******/
SELECT TOP (1000) [Emp_Item]
,[ID]
,[thisOrder]
,[Description]
,[Emp_ItemNum]
,[Emp_ItemType]
FROM [IPEasy_test].[dbo].[evw_qResult_EmpItem]
/****** SSMS 中 SelectTopNRows 命令的指令碼 ******/
SELECT TOP (1000) [Emp_DS]
,[ID]
,[thisOrder]
,[Emp_DSContury]
,[Emp_DSNum]
FROM [IPEasy_test].[dbo].[evw_qResult_EmpDS]
/****** SSMS 中 SelectTopNRows 命令的指令碼 ******/
SELECT TOP (1000) [targetID]
,[targetType]
,[dept]
FROM [IPEasy_test].[dbo].[evw_qResult_Dept]
select * from [esn_todos_Settle] where 1=1 and DSNum in(11328,11329,1101949,1101951,1109009)
 
update [esn_todos_Settle] set isClosed=true , update_user_id=@update_user_id ,update_time=GETDATE()
where id=@id
SELECT top 1 CONVERT(varchar(7),Settle_Date,126) Settle_Month from [esn_todos_Settle] a left join [evw_qResult_EmpDS] b on a.DSNum=b.Emp_DSNum left join [evw_qResult_Dept] c on a.DeptNum=c.targetID left join [evw_qResult_EmpItem] d on a.ItemNum=d.Emp_ItemNum where 1=1 and isClosed=0 and b.ID in(11328,11329,1101949,1101951,1109009)
\ No newline at end of file
This diff is collapsed.
/****** Object: UserDefinedFunction [dbo].[f_GetMultiplyingPoints_cn] Script Date: 2021/5/28 上午 10:24:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description,绩效系数提成_CN >
-- =============================================
Create FUNCTION [dbo].[f_GetMultiplyingPoints_cn]
(
@point float
)
RETURNS float
AS
BEGIN
DECLARE @rpoint FLOAT;
Set @rpoint= ROUND(CASE
WHEN @point <= 4.0 THEN @point * 800
WHEN @point > 4.0 and @point<=8.0 THEN @point*900-400
WHEN @point > 8.0 and @point<=10.0 THEN @point*1000-1200
WHEN @point > 10.0 and @point<=12.0 THEN @point*1100-2200
WHEN @point > 12.0 and @point<=14.0 THEN @point*1200-3400
WHEN @point > 14 THEN @point*1300-4800
END, 2) ;
RETURN(@rpoint)
END
GO
USE [IPEasy_test]
GO
/****** Object: UserDefinedFunction [dbo].[f_GetNewMultiplyingPoints_sol] Script Date: 2021/10/20 下午 04:55:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Penny>
-- Create date: <2021-04-01>
-- Description: <計算點數加乘 >
-- =============================================
Create FUNCTION [dbo].[f_GetNewMultiplyingPoints_sol]
(
@i_user_id varchar(255),
@i_is_engineer int,
@i_is_sales int,
@i_acting_points float,
@i_non_acting_points float
)
RETURNS @TABLE TABLE (user_id varchar(255),acting_points int, non_acting_points int)
as
begin
declare @i_points float,
--@v_is_engineer int,
--@v_is_sales int,
--工程師
@v_first_range float,
@v_second_range float,
@v_first_range_points float,
@v_second_range_points float,
--業務
@weighting1 float = 1.15,
@weighting2 float = 1.3,
@bracket1 int = 6000,
@bracket2 int= 8000,
--加乘點數
@o_multiplying_points float,
@o_acting_points float,
@o_non_acting_points float;
set @i_points = isnull(@i_acting_points,0) + isnull(@i_non_acting_points,0)
if @i_points = 0
begin
insert @TABLE
(user_id,acting_points,non_acting_points)
values (@i_user_id,@o_acting_points,@o_non_acting_points);
end
else
begin
--select
--@v_is_engineer = is_engineer,
--@v_is_sales = is_sales
--from evw_ehr_employee_zh_tw
--where wade_user_id = @i_user_id;
if @i_is_sales = 1
begin
set @o_multiplying_points= round(case when @i_points <= @bracket1 then @i_points
when @i_points <= @bracket2 then @bracket1 + @weighting1 * (@i_points - @bracket1)
else @bracket1 + (@bracket2 - @bracket1) * @weighting1 + (@i_points - @bracket2) * @weighting2
end, 0);
end
else
begin
set @v_first_range = 6500;
set @v_second_range = 8500;
set @v_first_range_points = case when @i_points > 0 and @v_first_range > 0 and @i_points > @v_second_range then @v_second_range - @v_first_range
when @i_points > 0 and @v_first_range > 0 and @i_points > @v_first_range and @i_points <= @v_second_range then @i_points - @v_first_range
else 0 end;
set @v_second_range_points = case when @i_points > 0 and @v_first_range > 0 and @i_points > @v_second_range then @i_points - @v_second_range
else 0 end
set @o_multiplying_points = case when @i_points <= 6500 then @i_points
when @i_points > @v_first_range then @v_first_range + @v_first_range_points * 1.15 + @v_second_range_points * 1.3
when @i_points is null then null
else @i_points end;
end
set @o_multiplying_points = round(@o_multiplying_points,0)
set @o_acting_points = case when @o_multiplying_points is null then null
when isnull(@i_acting_points,0) = 0 then null
else @o_multiplying_points * (@i_acting_points / @i_points)
end
set @o_acting_points = round(isnull(@o_acting_points,0),0)
set @o_non_acting_points = case when @o_multiplying_points is null then null
when isnull(@i_non_acting_points,0) = 0 then null
else @o_multiplying_points - @o_acting_points
end
insert @TABLE
(user_id,acting_points,non_acting_points)
values (@i_user_id,@o_acting_points,@o_non_acting_points);
end
return
end
GO
--IF OBJECT_ID('tempdb..#tmp', 'U') IS NOT NULL DROP TABLE #tmp
IF OBJECT_ID('tempdb..#tmp2', 'U') IS NOT NULL DROP TABLE #tmp2
-- select a.case_id into #tmp from p_proc_info a
-- group by case_id
-- EXCEPT
-- select a.case_id from esn_todos a
-- group by a.case_id
select b.*,
point_list_id,eflow_id,d.user_id,user_level,input_date,audit_type_id,status,point_num,currency_id,point_type,part_owner_id,point_note,point_bonus_time,work_type_id,work_type_num,work_coefficient,cus_coefficient
,d.user_name as AssignedTo,d.cn_name as AssignedTo_Name,ec.FlowKey as PatentType,ec.Names as PatentType_Name,
into #tmp2 from #tmp a
inner join p_proc_info b on a.case_id=b.case_id
inner join evw_p_case_info pci on pci.case_id=a.case_id
inner join p_proc_point_list c on b.proc_id=c.proc_id
inner join esn_category ec on ParentID='PatentType' AND ec.QryKey1=pci.apply_type_id
left join s_user_info d on d.user_id=c.user_id
where c.point_num > 0
select * from #tmp2
--and
--c.proc_id in(
--'AD58075C-BC5E-476E-B7A2-140C316B33F3','B595EC03-AEC0-46CA-B01C-1F0B73AEE9CB','E35D1FD1-7FB1-4666-B685-D3C5DB1F59BA','5C3FCFF2-EB85-4A25-9BED-F6759B479F31','C67BF38A-2016-4BFF-AF78-EC669AB785D1','448CEEB4-B254-4ACC-AF98-520C889E94B8','A71AE4D3-B65A-4653-9148-993CED499478','35172890-1843-41E2-83DE-35AA6F7EFE46','8B513B48-3114-4476-B3B8-12E034CBE4B1','C9C84A83-D0A3-48A4-A4F5-7FD1D54A33E7','E37A09F8-8834-4220-A70F-805B30C5354B','71F9A510-5C6F-4B5D-9230-CACC078E859C','BD389D94-0552-49A2-9868-1C85C53E7CBD','EDFF2A48-6DE6-443B-8B82-61E9E0C32ACD','A3E65682-F660-4AF7-944C-314556776E5F','61187307-69DA-4C5B-B942-1B05B5CAB3A7','05FC9C85-7B83-4395-A120-6534B5A3A8C8','1C771658-21CC-43F9-93CB-DC79652FF7E0','83C90F12-E208-4F2F-AD89-2DD569179034','A7253FF9-3C63-48CB-AA23-47E68FDFCAC1','AD57EF9D-EA28-496E-996D-13ACBE4826B1','8D309415-2270-401A-8483-E77E0E08CAD6','FAD25842-DCA5-4AB3-B088-B31991679D8B','140ED335-0982-40F5-8EC9-13532A845290'
--)
order by proc_id
insert into esn_todos_tmp
(
proc_id,SubSeq,CaseType,CaseType_Name,CaseNo,TaskDescription,StartDate2,StartDate2_c10,LegalDueDate,LegalDueDate_c10
,AttorneyDueDate,AttorneyDueDate_c10,FinishedDate,FinishedDate_c10,AssignedTo_userid,AssignedTo,AssignedTo_Name,PointsType
,Points,ExchangeRate,Matter,Matter_Name,PatentType,PatentType_Name,ToDosStatus,ToDosStatus_Name,Status,Status_Name,AssignStatus
,AssignStatus_name,Memo,Create_Userid,Create_User,Create_time,Update_Userid,Update_User,Update_time,IPS_FlowKey
,IPS_ParentId,case_id,date_point_settlement
)
select a.proc_id,a.case_type_Code as CaseType ,a.case_type_zh_tw as CaseType_Name, a.Case_Volume as caseno ,'完成初稿' as TaskDescription,a.create_time as StartDate2,a.create_time_c10 as StartDate2_c10,a.legal_due_date, a.LegalDueDate_c10
,a.int_due_date as AttorneyDueDate ,a.int_due_date_c10 as AttorneyDueDate_c10 ,a.back_date as FinishedDate,a.AssignedTo_userid,a.AssignedTo,a.AssignedTo_Name
,a.point_type as PointsType,a.point_num as Points,'as' as ExchangeRate, 'tudfutut' as esn_to
from #tmp2 a
select * from esn_todos_tmp
select * from esn_Todos a
where AssignedTo_Name like '%LISA%' and case_id='TP200020CN'
This diff is collapsed.
begin tran tran1;
UPDATE esn_todos
SET
FinishedDate = '2018/11/14',
finishedDate_c10 = '2018-11-13',
ToDosStatus = 'TDS02',
ToDosStatus_Name = '已完成',
Update_Userid = 'cb76971e-22d1-4f81-ade1-03c280f68cce',
Update_User = '何震中',
Update_time = '2020/04/23 09:49:49'
WHERE SN IN(537183);
SELECT SN,
taskdescription AS taskName,
proc_ID,
FinishedDate,
ToDosStatus_Name
FROM esn_todos
WHERE SN IN(537183);
UPDATE p_proc_info
SET
finish_date = '2018/11/13'
WHERE proc_id = 'AC7BA60F-2393-4C2B-AFA4-6F1C1617E4D4';
WAITFOR DELAY '00:00:15';
begin tran tran2;
UPDATE esn_todos
SET
FinishedDate = '2018/11/1',
finishedDate_c10 = '2018-11-13',
ToDosStatus = 'TDS02-test',
ToDosStatus_Name = '已完成',
Update_Userid = 'cb76971e-22d1-4f81-ade1-03c280f68cce',
Update_User = '何震中',
Update_time = '2020/04/23 09:49:49'
WHERE SN IN(537183);
SELECT SN,
taskdescription AS taskName,
proc_ID,
FinishedDate,
ToDosStatus_Name
FROM esn_todos
WHERE SN IN(537183);
--UPDATE p_proc_info
-- SET
-- finish_date = '2018/11/13'
--WHERE proc_id = 'AC7BA60F-2393-4C2B-AFA4-6F1C1617E4D4';
WAITFOR DELAY '00:00:15';
rollback tran tran1;
rollback tran tran2;
SELECT cntr_value AS NumOfDeadLocks,a.*
FROM sys.dm_os_performance_counters a
WHERE object_name = 'SQLServer:Locks'
AND counter_name = 'Number of Deadlocks/sec'
AND instance_name = '_Total'
select * from sys.dm_tran_locks
SELECT request_session_id AS spid,
resource_type AS rt,
resource_databASe_id AS rdb,
(CASE resource_type
WHEN 'OBJECT' then object_name(resource_ASsociated_entity_id)
WHEN 'DATABASE' then '<db_name>'
ELSE
(SELECT object_name(object_id) FROM sys.partitions
WHERE hobt_id = resource_ASsociated_entity_id) END) AS objname,
resource_description AS rd,
request_mode AS rm,
request_status AS rs
FROM sys.dm_tran_locks
select substring(CaseNo,1,9),COUNT(distinct substring(CaseNo,1,7)) from esn_Todos a
where a.CaseNo like 'TP20000%'
group by substring(CaseNo,1,3), substring(CaseNo,1,9)
select * from p_proc_info a
where a.proc_id='d40cf158-f34b-438e-8143-c29be26e5b3c'
select * from esn_todos a
where a.CaseNo='TP190155-TW'
select a.create_time,a.finish_date, ips.status_code,ips.proc_status_zh_tw as "狀態(父)" ,c.case_volume as 案號,icp.ctrl_proc_zh_tw as "處理事項名稱(父)"
,icp.country_id,b.ToDosStatus,b.ToDosStatus_Name, b.TaskDescription as "處理事項名稱(子)" from p_proc_info a
left join esn_Todos b on a.proc_id=b.proc_id
left join evw_p_case_info c on a.case_id=c.case_id
left join i_proc_status ips on a.proc_status_id =ips.proc_status_id
left join i_ctrl_proc icp on a.ctrl_proc_id =icp.ctrl_proc_id
where b.ToDosStatus='TDS01' and ips.proc_status_zh_tw like '結%'
Begin tran tran1;
with CTE as (
select
b.sn,a.proc_id,a.create_time,a.finish_date, ips.status_code,ips.proc_status_zh_tw as "狀態(父)" ,c.case_volume as 案號,icp.ctrl_proc_zh_tw as "處理事項名稱(父)"
,icp.country_id,b.ToDosStatus,b.ToDosStatus_Name, b.TaskDescription as "處理事項名稱(子)"
from p_proc_info a
left join esn_Todos b on a.proc_id=b.proc_id
left join evw_p_case_info c on a.case_id=c.case_id
left join i_proc_status ips on a.proc_status_id =ips.proc_status_id
left join i_ctrl_proc icp on a.ctrl_proc_id =icp.ctrl_proc_id
where b.ToDosStatus='TDS01' and ips.proc_status_zh_tw like '結%'
--order by b.sn
)
--select a.* from esn_Todos a
-- inner join CTE b on a.sn=b.sn
update esn_todos set ToDosStatus='TDS03',ToDosStatus_Name='結案'
From esn_todos a inner join CTE b on a.sn=b.sn
;
--commit tran tran1;
rollback tran tran1;
:on error
select top 100 * from esn_todos
\ No newline at end of file
with tempt as(
select top 1000
a.case_volume,b.CaseNo--,SUBSTRING(a.case_volume ,9,3),SUBSTRING(a.case_volume ,1,8)
--a.*,b.CaseNo
from p_case_info a
left join evw_qresult_caselevel b on SUBSTRING(a.case_volume ,1,8)=SUBSTRING(b.CaseNo ,1,8) and right(a.case_volume,2)=right(b.CaseNo,2)
where CHARINDEX('-', a.case_volume,0)=0 and CHARINDEX('-', b.CaseNo,0)>0
)
--查詢
select * from q_result_text a
inner join tempt on a.text=tempt.CaseNo
--修改
update q_result_text set text=tempt.case_volume
where text=tempt.CaseNo
select a.sn,a.CaseNo as 案號,c.ctrl_proc_zh_cn '處理事項(父)',a.TaskDescription as '處理事項(子)',a.FinishedDate 完成日 ,
a.AssignedTo_Name 承辦人,a.PointsType,a.points, * from esn_Todos a
left join p_proc_info b on a.proc_id=b.proc_id
left join i_ctrl_proc c on b.ctrl_proc_id=c.ctrl_proc_id
where a.FinishedDate between '2021-03-01' and '2021-03-31' and TaskDescription='點數補正' and PointsType='MP'
update esn_Todos set PointsType='POINT'
where FinishedDate between '2021-03-01' and '2021-03-31'and TaskDescription='點數補正' and PointsType='MP'
--清除非法資料
begin tran tran1
delete a from esn_todos_Flow_his a
select * from esn_todos_Flow_his a
left join esn_todos_Flow b on a.Flow_id=b.id
where
((a.FromType_id=3 and a.ToType_id=4) or (a.FromType_id=4 and a.ToType_id=4)) --只取 主管->審核完成,審核完成->審核完成
and ConfirmUserClass <> 'Leader'
order by Update_time desc
and
b.esn_todos_sn in(959085,901646,901640,951854,941535,880299,897526,932877,944275,944277,947256,947257,955381,954899,948130,948999,958248,957957,955374,956797,956795,955372,907294,909427,935342,923075,943083,920994,945659,957667,947563,950926,934931,957865,954381,945671,957924,946690,945397,959423,917332,942126,924128,940621,942741,944818,947694,947344,955548,959414,943955,946379,946385,947205,947211,948377,950172,950175,953883,954266,955221,908977,943588,947247,932878,958072,924007,932771,905494,948361,934211,954404,954114,914067,940944,961733,958429,959428,959383,959391,923987,939734,948629,956097,956100,956103,956106,956109,956112,956115,956118,956121,956124,951677,949579,955471,955141,949857)
update esn_todos_Flow
set StepType_id=3,StepType_id_Previous=2
where
--StepType_id=4 and StepType_id_Previous=4 --只取 前步與現在皆是審核完成
--and
esn_todos_sn in(959085,901646,901640,951854,941535,880299,897526,932877,944275,944277,947256,947257,955381,954899,948130,948999,958248,957957,955374,956797,956795,955372,907294,909427,935342,923075,943083,920994,945659,957667,947563,950926,934931,957865,954381,945671,957924,946690,945397,959423,917332,942126,924128,940621,942741,944818,947694,947344,955548,959414,943955,946379,946385,947205,947211,948377,950172,950175,953883,954266,955221,908977,943588,947247,932878,958072,924007,932771,905494,948361,934211,954404,954114,914067,940944,961733,958429,959428,959383,959391,923987,939734,948629,956097,956100,956103,956106,956109,956112,956115,956118,956121,956124,951677,949579,955471,955141,949857)
rollback tran tran1
--commit tran tran1
--清除非法資料 END
select * from esn_todos_Flow a
where a.esn_todos_sn=959085
return
--select d.sn,a.case_volume,c.ctrl_proc_zh_cn,d.TaskDescription,d.Points,d.AssignedTo_Name,d.AssignStatus_name,d.FinishedDate,f.Step_Text,
--f1.Step_Text,f2.Step_Text,g.cn_name,ee.Create_time
select d.sn
from p_case_info a
inner join p_proc_info b on a.case_id = b.case_id
inner join i_ctrl_proc c on b.ctrl_proc_id = c.ctrl_proc_id
inner join esn_Todos d on a.case_id = d.case_id and b.proc_id = d.proc_id and d.active = 1
inner join esn_todos_Flow e on d.sn = e.esn_todos_sn
inner join esn_todos_Flow_his ee on e.id = ee.Flow_id
inner join esn_todos_Flow_StepType f on e.StepType_id = f.id
inner join esn_todos_Flow_StepType f1 on ee.FromType_id = f1.id
inner join esn_todos_Flow_StepType f2 on ee.ToType_id = f2.id
inner join s_user_info g on ee.ConfirmUserId = g.user_id
where d.FinishedDate >= '2021-09-01' and
f.Step_Text = '審核完成' and
f1.Step_Text = '主管審核中' and
f2.Step_Text = '審核完成' and
ee.ConfirmUserId not in
(select user_id
from evw_dept_manager
where dept like '%專利%'
group by name,user_id
union
select a.user_id
from s_user_code_role a
where a.role_name = 'dept_manager'
group by a.user_id)
order by ee.Create_time asc
\ No newline at end of file
This diff is collapsed.
--alter FUNCTION [dbo].efn_GetExecSql_Table(@sql_string VARCHAR(max) )
--RETURNS @TABLE TABLE (cur_EmpName VARCHAR(30) )
--AS
--BEGIN
-- --@p_Case_Type varchar(1) --ץO(P=MQ, T=Ӽ, C=v)
-- INSERT INTO @TABLE
-- Select cur_EmpName from evw_Employee
-- RETURN
--END
select cur_EmpName into #tempt from evw_Employee
truncate table #tempt
declare @sql nvarchar(max)='Select cur_EmpName from evw_Employee'
insert into #tempt
EXEC SP_EXECUTESQL @sql;
select a.* from p_agency_list a
inner join p_case_info b on a.obj_id=b.case_id
where b.case_volume ='TP161143-EU'
where case_volume_agency like '%P406550EP/JAR%'
\ No newline at end of file
BUSE [IPEasy_test_bk] BUSE [IPEasy_test_bk]
USE [IPEasy_test]
GO
/****** Object: View [dbo].[evw_esn_todos] Script Date: 2021/11/16 下午 05:40:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[evw_esn_todos]
AS
SELECT a.sn, a.proc_id, a.SubSeq, a.CaseType, a.CaseType_Name, a.CaseNo, a.TaskDescription, a.StartDate2, a.StartDate2_c10,
a.LegalDueDate_c10, a.AttorneyDueDate, a.AttorneyDueDate_c10, a.FinishedDate, a.FinishedDate_c10,
a.AssignedTo_userid, a.AssignedTo, a.AssignedTo_Name, a.Points, CASE WHEN (ISNULL(points, 0) <> 0 AND
ISNULL(PointsType, '') <> 'MP') AND ISNULL(exchangeRate, 0) = 0 THEN 1 ELSE ISNULL(exchangeRate, 0)
END AS exchangeRate, a.Matter, a.Matter_Name, a.PatentType, a.PatentType_Name, a.ToDosStatus_Name,
a.AssignStatus, a.AssignStatus_name, a.Memo, a.case_id, a.date_points_settlement, a.LegalDueDate, a.ToDosStatus,
a.PointsType, a.CustDueDate, a.TaskClass_id, b.Names AS ecNames, b.FlowKey AS ecFlowKey,
case when isnull(eb.bcName,'')='' then '點數' else eb.bcName end as bcName
FROM dbo.esn_Todos AS a LEFT OUTER JOIN
dbo.esn_category AS b ON b.ParentId = 'subtodos' AND a.TaskClass_id = b.FlowKey
left join esn_BaseCode eb on eb.SubID=a.PointsType and eb.ParentID='pointstype'
WHERE (a.active = 1)
GO
USE [IPEasy]
GO
/****** Object: View [dbo].[evw_qresult_caseispriority] Script Date: 2020/1/10 上午 10:32:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* questionID=11503=案件編號 */
CREATE VIEW [dbo].[evw_qresult_caseispriority]
AS
SELECT b.text AS CaseNo, CASE WHEN ISNULL(v2.Name, '') = '是' THEN 'Y' ELSE 'N' END AS IsPriority, ISNULL(v2.Name, '')
AS IsPriorityDesc
FROM dbo.q_result AS a INNER JOIN
dbo.q_result_text AS b ON a.answerID = b.id INNER JOIN
dbo.q_result AS qr2 ON qr2.active = 1 AND qr2.targetID = a.targetID AND qr2.targetType = a.targetType AND
qr2.questionID IN (1532759) INNER JOIN
dbo.q_namespace AS v2 ON v2.ID = qr2.answerID
WHERE (a.active = 1) AND (a.QrID = 243) AND (a.questionID IN (11503))
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "a"
Begin Extent =
Top = 6
Left = 38
Bottom = 136
Right = 259
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "b"
Begin Extent =
Top = 6
Left = 297
Bottom = 119
Right = 462
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "qr2"
Begin Extent =
Top = 6
Left = 500
Bottom = 136
Right = 721
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "v2"
Begin Extent =
Top = 6
Left = 759
Bottom = 136
Right = 924
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'evw_qresult_caseispriority'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'evw_qresult_caseispriority'
GO
USE [IPEasy]
GO
/****** Object: View [dbo].[evw_qresult_caselevel] Script Date: 2020/1/10 上午 10:32:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* questionID=11503=案件編號 */
CREATE VIEW [dbo].[evw_qresult_caselevel]
AS
SELECT b.text AS CaseNo, CASE ISNULL(v2.Name, '')
WHEN '重要專利' THEN '1' WHEN '常規專利' THEN '2' ELSE '' END AS CaseLevel, ISNULL(v2.Name, '')
AS CaseLevelDesc
FROM dbo.q_result AS a INNER JOIN
dbo.q_result_text AS b ON a.answerID = b.id INNER JOIN
dbo.q_result AS qr2 ON qr2.active = 1 AND qr2.targetID = a.targetID AND qr2.targetType = a.targetType AND
qr2.questionID IN (11369) INNER JOIN
dbo.q_namespace AS v2 ON v2.ID = qr2.answerID
WHERE (a.active = 1) AND (a.QrID = 243) AND (a.questionID IN (11503))
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "a"
Begin Extent =
Top = 6
Left = 38
Bottom = 136
Right = 259
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "b"
Begin Extent =
Top = 6
Left = 297
Bottom = 119
Right = 462
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "qr2"
Begin Extent =
Top = 6
Left = 500
Bottom = 136
Right = 721
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "v2"
Begin Extent =
Top = 6
Left = 759
Bottom = 136
Right = 924
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
Begin ColumnWidths = 9
Width = 284
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'evw_qresult_caselevel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'evw_qresult_caselevel'
GO
USE [IPEasy]
GO
/****** Object: View [dbo].[evw_s_user_info] Script Date: 2020/1/2 ¤U¤È 06:03:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--DROP VIEW dbo.evw_s_user_info;
CREATE VIEW [dbo].[evw_s_user_info]
AS
--­û¤u¸ê®Æ
SELECT a.user_id, a.user_type, a.user_name, a.cn_name, a.en_name, a.user_pass, a.first_name, a.last_name, a.user_code, a.gender, a.email, a.birthday, a.specialty,
a.rank_id, dbo.efn_GetIDName(a.rank_id,'rank_id','') as rank_zh_tw, a.tel, a.mobile, a.fax, a.contact_address, a.dept_id, b1.dept_name, b1.dept_full_name, a.agent_id, dbo.efn_GetIDName(a.agent_id,'agent_id','') as agent_name_cn,
a.is_enabled, a.language, a.create_user_id, dbo.efn_GetIDName(a.create_user_id,'user_id','') as create_user_name, a.create_time, a.update_user_id, dbo.efn_GetIDName(a.update_user_id,'user_id','') as update_user_name, a.update_time,
a.remark, a.work_site, a.is_outer_user, a.revise_user, a.pwd_update_time, a.position_id, a.id_number, a.hiredate, a.post_status, a.fav_cols, a.ts_customer_id, a.auth_case_user, a.wx_name, a.wx_openid, a.err_pwdtimes
FROM s_user_info a
LEFT join s_dept_info b1 on a.dept_id = b1.dept_id
GO
B Alter PROCEDURE [dbo].[rpt_CustCaseTot] ( B Alter PROCEDURE [dbo].[rpt_CustCaseTot] (
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Balter PROCEDURE [dbo].[rpt_CustCaseTot_Week] ( Balter PROCEDURE [dbo].[rpt_CustCaseTot_Week] (
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
BUSE [IPEasy_test] BUSE [IPEasy_test]
This diff is collapsed.
BALTER PROCEDURE [dbo].[rpt_NotFinishPoint] BALTER PROCEDURE [dbo].[rpt_NotFinishPoint]
This diff is collapsed.
This diff is collapsed.
BALTER procedure [dbo].[rpt_PerformanceMonth] BALTER procedure [dbo].[rpt_PerformanceMonth]
BUSE [IPEasy] BUSE [IPEasy]
BUSE [IPEasy] BUSE [IPEasy]
Balter procedure [dbo].[rpt_PerformanceMonth_Flow] Balter procedure [dbo].[rpt_PerformanceMonth_Flow]
BUSE [IPEasy] BUSE [IPEasy]
BUSE [IPEasy_test] BUSE [IPEasy_test]
This diff is collapsed.
This diff is collapsed.
Alter PROCEDURE sp_Edit_esn_kpi_tg(@p_Kpi_year varchar(4),@p_kpi_Applicant varchar(50),@p_Qry_CustNM varchar(45),@p_CN_QN int,@p_PCT_AP int,@p_CN_AP int,
@p_JP_AP int,@p_US_AP int,@p_EP_AP int,@p_RU_AP int,@p_KR_AP int,@p_IN_AP int,@p_Is_Enabled varchar(1),@p_Update_userID varchar(45),@p_Update_username varchar(45)
)
AS
BEGIN
IF EXISTS(select 1 from esn_kpi_tg where kpi_year=@p_Kpi_year and kpi_Applicant=@p_kpi_Applicant)
BEGIN
update esn_kpi_tg SET CN_QN=@p_CN_QN, PCT_AP=@p_PCT_AP, CN_AP=@p_CN_AP, JP_AP=@p_JP_AP, US_AP=@p_US_AP, EP_AP=@p_EP_AP, RU_AP=@p_RU_AP,
KR_AP=@p_KR_AP, IN_AP=@p_IN_AP, Is_Enabled=@p_Is_Enabled, Update_userID=@p_Update_userID, update_time=getdate(),Update_username=@p_Update_username
WHERE Kpi_year=@p_Kpi_year and kpi_Applicant=@p_kpi_Applicant
print(@p_Kpi_year+'-'+@p_kpi_Applicant)
END
ELSE
BEGIN
insert esn_kpi_tg
select @p_Kpi_year as kpi_year, @p_kpi_Applicant as kpi_Applicant, @p_Qry_CustNM as Qry_CustNM, @p_CN_QN as CN_QN,
@p_PCT_AP as PCT_AP, @p_CN_AP as CN_AP, @p_JP_AP as JP_AP, @p_US_AP as US_AP, @p_EP_AP as EP_AP, @p_RU_AP as RU_AP, @p_KR_AP as KR_AP,
@p_IN_AP as IN_AP, @p_Is_Enabled as Is_Enabled, @p_Update_userID as Update_userID, getdate() as update_time,@p_Update_username as Update_username ;
END
select * from esn_kpi_tg where kpi_year=@p_Kpi_year and kpi_Applicant=@p_kpi_Applicant;
END
GO
sp_Edit_esn_kpi_tg '2019','89FC21BA-0112-4DAF-A98D-053F52DF7920','?P','500','150','400','0','100','0','0','0','0','','solho',''
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment