UPDATE dbo.Base_Depart SET DepartCode='None',DepartName='None' WHERE DepartCode='All' GO ALTER TABLE dbo.EMC_Punishment ADD SelectYesNo BIT NULL GO ALTER TABLE dbo.EMC_Punishment ADD Def NVARCHAR(300) NULL GO -- 5.13加:违规关联SES号的填写通知是否发送 ALTER TABLE dbo.EMC_Punishment ADD RelatedSesMailIsSend BIT NULL GO ALTER TABLE dbo.EMC_Punishment ADD CreateDate DATETIME NULL GO UPDATE dbo.EMC_Punishment SET RelatedSesMailIsSend=1 GO ALTER VIEW [dbo].[View_EMC_Punishment] AS /*********扣款视图**********/ SELECT punish.PunishmentId,punish.PunishDate,punish.FO_NO,punish.SES_No,punish.Location,punish.Description,punish.Company, punish.Individual, (ISNULL(punish.Company,0)+ISNULL(punish.Individual,0)) AS Backcharge, punish.CompletionDate,punish.PunishDate AS PunishTime, (CASE WHEN punish.ViolationDegree='1' THEN '一般违章' WHEN punish.ViolationDegree='2' THEN '严重违章' WHEN punish.ViolationDegree='3' THEN '零容忍违章' END) AS ViolationDegree, (CASE WHEN con.Contractor IS NULL THEN con.ContractorCN WHEN con.ContractorCN IS NULL THEN con.Contractor ELSE con.Contractor+con.ContractorCN END)AS Contractor, datas.Contractor AS ContractorId,dis.Discipline AS DisciplineEn,dis.DisciplineCN,con.Contractor AS ContractorEn,con.ContractorCN, (CASE WHEN dis.Discipline IS NULL THEN dis.DisciplineCN WHEN dis.DisciplineCN IS NULL THEN dis.Discipline ELSE dis.Discipline+dis.DisciplineCN END) AS Discipline, datas.Contract_Admin AS Contract_AdminId, u.UserName AS Contract_Admin, u2.UserName AS Main_Coordinator,mcdep.DepartName AS MCDept, u3.UserName AS User_Representative, bycDep.DepartName AS BYCRU,bycuser.UserName AS BYCRULeader, u4.UserName AS Violation_Inspector_Name, viDep.DepartName AS InspectionDep, punish.BYC_RU,punish.Violation_Inspector,punish.ViolationRelatedSes,punish.Flag,punish.SelectYesNo,punish.Def, (CASE WHEN punish.EmailIsSend=1 THEN '是' ELSE '否' END) AS EmailIsSend FROM dbo.EMC_Punishment punish LEFT JOIN dbo.FC_SESRelatedData datas ON datas.FO_NO = punish.FO_NO LEFT JOIN dbo.Base_Contractor AS con ON con.ContractorId = datas.Contractor LEFT JOIN dbo.Base_Discipline AS dis ON dis.DisciplineId = datas.DisciplineId LEFT JOIN dbo.Sys_User AS u ON u.UserId = datas.Contract_Admin LEFT JOIN dbo.Sys_User AS u2 ON u2.UserId = datas.Main_Coordinator LEFT JOIN dbo.Sys_User AS u3 ON u3.UserId=datas.User_Representative LEFT JOIN dbo.Base_Depart mcdep ON mcdep.DepartId = u2.DepartId LEFT JOIN dbo.Base_Depart bycDep ON bycdep.DepartId=punish.BYC_RU LEFT JOIN dbo.Sys_User bycuser ON bycuser.UserId = bycDep.DepartLeader LEFT JOIN dbo.Sys_User AS u4 ON u4.UserId=punish.Violation_Inspector LEFT JOIN dbo.Base_Depart viDep ON viDep.DepartId=u4.DepartId GO