@ -5,7 +5,6 @@ import com.emr.dao.BatchApplyMapper;
import com.emr.dao.EmrComomSetMapper ;
import com.emr.dao.EmrComomSetMapper ;
import com.emr.dao.Emr_DictionaryMapper ;
import com.emr.dao.Emr_DictionaryMapper ;
import com.emr.entity.* ;
import com.emr.entity.* ;
import com.emr.util.ExceptionPrintUtil ;
import com.emr.util.ListUtils ;
import com.emr.util.ListUtils ;
import com.emr.util.Setters ;
import com.emr.util.Setters ;
import com.emr.vo.BatchApplyDetailsVo ;
import com.emr.vo.BatchApplyDetailsVo ;
@ -13,11 +12,8 @@ import com.emr.vo.BatchApplyVo;
import com.emr.vo.BatchBorrowingVo ;
import com.emr.vo.BatchBorrowingVo ;
import com.emr.vo.commomSearch.CommomVo ;
import com.emr.vo.commomSearch.CommomVo ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.ibatis.annotations.Param ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.interceptor.TransactionAspectSupport ;
import org.springframework.web.context.request.RequestContextHolder ;
import org.springframework.web.context.request.RequestContextHolder ;
import org.springframework.web.context.request.ServletRequestAttributes ;
import org.springframework.web.context.request.ServletRequestAttributes ;
@ -105,21 +101,21 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService {
}
}
@Override
@Override
public int agreeById ( String ids ) {
public int agreeById ( String ids , Integer batchId ) {
int i = 0 ;
//获取系统当前时间
//获取系统当前时间
SimpleDateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
SimpleDateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
//获取登录用户信息
//获取登录用户信息
HttpServletRequest request = ( ( ServletRequestAttributes ) RequestContextHolder . getRequestAttributes ( ) ) . getRequest ( ) ;
HttpServletRequest request = ( ( ServletRequestAttributes ) RequestContextHolder . getRequestAttributes ( ) ) . getRequest ( ) ;
// 从session获取用户名
// 从session获取用户名
Power_User user = ( Power_User ) request . getSession ( ) . getAttribute ( "CURRENT_USER" ) ;
Power_User user = ( Power_User ) request . getSession ( ) . getAttribute ( "CURRENT_USER" ) ;
//声明一个BatchApplyDetailsVo对象
BatchApplyDetailsVo batchApplyDetailsVo = new BatchApplyDetailsVo ( ) ;
//声明一个BatchApplyDetailsVo集合
//声明一个BatchApplyDetailsVo集合
List < BatchApplyDetailsVo > list = Collections . synchronizedList ( new ArrayList < > ( ) ) ;
List < BatchApplyDetailsVo > list = Collections . synchronizedList ( new ArrayList < > ( ) ) ;
//将字符串转为List<String>在转成List<Integer>
//将字符串转为List<String>在转成List<Integer>
List < Integer > idsList = Arrays . asList ( ids . split ( "," ) ) . stream ( ) . mapToInt ( Integer : : parseInt ) . boxed ( ) . collect ( Collectors . toList ( ) ) ;
List < Integer > idsList = Arrays . asList ( ids . split ( "," ) ) . stream ( ) . mapToInt ( Integer : : parseInt ) . boxed ( ) . collect ( Collectors . toList ( ) ) ;
//遍历审核信息
//遍历审核信息
for ( Integer id : idsList ) {
for ( Integer id : idsList ) {
BatchApplyDetailsVo batchApplyDetailsVo = new BatchApplyDetailsVo ( ) ;
batchApplyDetailsVo . setExamineName ( user . getUserPosition ( ) ) ;
batchApplyDetailsVo . setExamineName ( user . getUserPosition ( ) ) ;
batchApplyDetailsVo . setExamineTime ( fmt . format ( new Date ( ) ) ) ;
batchApplyDetailsVo . setExamineTime ( fmt . format ( new Date ( ) ) ) ;
batchApplyDetailsVo . setApplyStatc ( 1 ) ;
batchApplyDetailsVo . setApplyStatc ( 1 ) ;
@ -128,9 +124,36 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService {
}
}
//给有效时间赋值
//给有效时间赋值
upDateEffectiveTimeList ( list ) ;
upDateEffectiveTimeList ( list ) ;
return batchApplyDetailsMapper . upadteApplyDetailsList ( list ) ;
boolean b = upadteApplyDetais ( list ) ;
if ( b ) {
i = 1 ;
}
//更新审批数量
upDateAgreeNum ( batchId , list . size ( ) ) ;
return i ;
}
}
private void upDateAgreeNum ( int batchId , int readNum ) {
BatchApplyVo batchApplyVo = batchApplyMapper . getreadNum ( batchId ) ;
int i = readNum + batchApplyVo . getReadNum ( ) ;
batchApplyMapper . updateReadNumm ( i , batchId ) ;
// //如果借阅数量跟审批数量一样则改为已审批
if ( batchApplyVo . getBorrowingNum ( ) = = i ) {
batchApplyMapper . updateStatc ( 2 , batchId ) ;
} else {
batchApplyMapper . updateStatc ( 3 , batchId ) ;
}
}
private boolean upadteApplyDetais ( List < BatchApplyDetailsVo > list ) {
boolean flag = false ;
for ( BatchApplyDetailsVo batchApplyDetailsVo : list ) {
batchApplyDetailsMapper . upadteApplyDetails ( batchApplyDetailsVo ) ;
flag = true ;
}
return flag ;
}
private void upDateEffectiveTimeList ( List < BatchApplyDetailsVo > batchApplyDetailsVolist ) {
private void upDateEffectiveTimeList ( List < BatchApplyDetailsVo > batchApplyDetailsVolist ) {
for ( BatchApplyDetailsVo list : batchApplyDetailsVolist ) {
for ( BatchApplyDetailsVo list : batchApplyDetailsVolist ) {