项目那点事
想说几点工作碰到的:
1.首先就是JSP文件中传回的值:""并不是为null。而至于怎么传回null值,还有待实验
2.就是mybatis中insert到数据库中null列值是必须注明jdbcType,比如:一个表的外键值有可能为空(即改表此时没有所关联的表的值)
方法:
#{branch,jdbcType=INTEGER}等等,注意大小写。
3.工数黑名单检查SQL代码:
1 -- -------------------------------------------------------------------------------- 2 -- Routine DDL 3 -- Note: comments before and after the routine body will not be stored by the server 4 -- -------------------------------------------------------------------------------- 5 DELIMITER $$ 6 7 CREATE DEFINER=`root`@`%` PROCEDURE `checkerror2`(startDate date,endDate date) 8 begin 9 declare done int default false; 10 declare staffNum int; 11 declare firstStaff int; 12 13 14 declare curTemp cursor for 15 select staffID from staff where position !='所长' and position !='董事长' and position !='本部长' and position !='经理' and position!='担当经理'and state=1 order by staffID; 16 declare continue handler for not found set done =true; 17 open curTemp; 18 19 set firstStaff=(select staffID from staff where position !='所长' and position !='董事长' and position !='本部长' and position !='经理' and position!='担当经理' and state=1 20 order by staffID limit 1); 21 22 truncate table temp; 23 read_loop:loop 24 fetch curTemp into staffNum; 25 if done then 26 leave read_loop; 27 end if; 28 if staffNum >= firstStaff then 29 set staffNum=(select checkbystaffid(staffNum,startDate,endDate)); 30 end if; 31 end loop; 32 close curTemp; 33 insert into temp (staffID,date,totalTimes) (select m.staffID,m.date,sum(m.times) as totalTimes 34 from manhour m,work_calendar wc,staff s 35 where m.date between startDate and endDate and m.date = wc.date and wc.able=1 36 and s.staffID = m.staffID and s.state = 1 37 group by m.staffID ,m.date 38 having sum(m.times) < 8 or sum(m.times)>24); 39 end
1 CREATE DEFINER=`root`@`%` FUNCTION `checkbystaffid`(staffNum int,sdate date,edate date) RETURNS int(1) 2 begin 3 4 declare done int default false; 5 declare indexdate DATE; 6 7 declare cur1 cursor for 8 select date from work_calendar where date not in (select m.date as mDate 9 from manhour m 10 where m.date between sdate and edate and m.staffID= staffNum 11 group by m.date) and able =1 and date between sdate and edate; 12 13 declare continue handler for not found set done =true; 14 open cur1; 15 16 17 set indexdate = sdate; 18 read_loop:loop 19 fetch cur1 into indexDate; 20 if done then 21 leave read_loop; 22 end if; 23 if indexDate >= sdate then 24 insert into temp (staffID,date) values(staffNum,indexDate); 25 end if; 26 end loop; 27 close cur1; 28 return(staffNum); 29 end