@ -14,7 +14,6 @@ import com.msdw.tms.entity.XlsxTemplateEntity;
import com.msdw.tms.entity.response.CommonCode ;
import com.msdw.tms.entity.vo.StaffExportVo ;
import com.msdw.tms.entity.vo.StaffVo ;
import com.msdw.tms.entity.vo.StudentImportFailureVo ;
import com.msdw.tms.service.AliyunOssService ;
import com.msdw.tms.service.SystemSetttingService ;
import com.msdw.tms.service.XlsxTemplateService ;
@ -22,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.core.io.ClassPathResource ;
import org.springframework.core.io.FileSystemResource ;
import org.springframework.data.redis.core.StringRedisTemplate ;
import org.springframework.data.redis.core.ValueOperations ;
import org.springframework.stereotype.Service ;
@ -30,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource ;
import javax.servlet.http.HttpServletResponse ;
import java.io.FileInputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.util.* ;
@ -67,7 +68,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
return R . error ( 400 , "手机号不能重复" ) ;
}
}
List < String > resultA = userInfoDao . queryAccount ( account ) ;
List < StaffVo > resultA = userInfoDao . queryAccount ( account ) ;
// List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if ( resultA . size ( ) > 0 ) {
return R . error ( 400 , "账号不能重复" ) ;
@ -124,29 +125,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
String workNumber = staffVo . getWorkNumber ( ) ;
List < StaffEntity > staff = staffVo . getStaff ( ) ; //获取员工数据
List < String > result = userInfoDao . queryAccount ( account ) ;
String roleIds = result . get ( 0 ) ;
StaffVo result = userInfoDao . queryAccountUpdate ( staffVo . getUserId ( ) ) ;
// String roleIds = result.get(0).getRoleId();
// StaffVo staffVo1 = result.get(0);
String roleIds = result . getRoleId ( ) ;
String [ ] splitOld = staffVo . getRoleId ( ) . split ( "," ) ;
String [ ] splitNew = roleIds . split ( "," ) ;
if ( splitOld . length = = splitNew . length ) {
for ( int i = 0 ; i < = splitNew . length ; i + + ) {
if ( splitOld . length = = splitNew . length & & splitNew . length < 2 ) {
for ( int i = 0 ; i < splitNew . length ; i + + ) {
// for (int i = 0;i<splitNew.length+1;i++){
boolean a = systemSetttingDao . updateStaff ( staff . get ( i ) ) ;
if ( ! a ) { throw new RuntimeException ( ) ; }
}
} else if ( splitNew . length > splitOld . length ) {
boolean a = systemSetttingDao . updateStaff ( staff . get ( 0 ) ) ;
boolean b = systemSetttingDao . addStaff ( staff . get ( 1 ) , staffVo . getUserId ( ) ) ;
StaffEntity staffEntity = staff . get ( 1 ) ;
staffEntity . setUserId ( staffVo . getUserId ( ) ) ;
boolean b = systemSetttingDao . addStaffUpdata ( staffEntity ) ;
if ( ! a | ! b ) { throw new RuntimeException ( ) ; }
} else {
} else if ( splitNew . length < splitOld . length ) {
boolean a = systemSetttingDao . deleteStaffOnly ( staffVo . getUserId ( ) ) ; //删除roleId最大的数据
staffVo . setStaffRoleId ( Integer . parseInt ( staffVo . getRoleId ( ) ) ) ;
boolean b = systemSetttingDao . updateStaffOnly ( staffVo ) ; //修改仅剩的数据
} else {
return R . error ( 400 , "不存在此账号" ) ;
}
userInfoDao . setNUM ( staffVo . getUserId ( ) ) ; //重置账号、手机号码为00
// systemSetttingDao.deleteStaffInfo(staffVo.getUserId());//
List < String > resultA = userInfoDao . queryAccount ( account ) ;
List < StaffVo > resultA = userInfoDao . queryAccount ( account ) ;
List < Integer > resultW = systemSetttingDao . queryWorkNumber ( workNumber ) ;
if ( phone ! = null & & phone ! = "" ) {
List < Integer > resultP = userInfoDao . queryPhone ( phone ) ;
@ -225,7 +232,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
int size = staffs . size ( ) ;
Long ii = 1L ;
try {
for ( int i = 0 ; i < size ; i + + ) {
for ( int i = 0 ; i < staffs . s ize ( ) ; i + + ) {
StaffVo staffVo = staffs . get ( i ) ;
String phone = staffVo . getPhone ( ) ;
String workNumber = staffVo . getWorkNumber ( ) ;
@ -234,31 +241,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
staff . setSchoolId ( ConstantUtils . Keda_schoolId ) ; //设定科大学校id
String schoolAppellationName = staffVo . getSchoolAppellationName ( ) ;
List < Integer > resultW = systemSetttingDao . queryWorkNumber ( workNumber ) ;
List < String > resultA = userInfoDao . queryAccount ( account ) ;
List < StaffVo > resultA = userInfoDao . queryAccount ( account ) ;
List < StaffVo > resultU = userInfoDao . queryUserInfo ( staffVo ) ;
if ( resultU . size ( ) > 0 ) { //重复的数据
StaffExportVo vo = new StaffExportVo ( ) ;
vo . setFailureMsg ( "用户信息已存在" ) ;
+ + ii ;
vo . setIndex ( ii ) . setUserName ( staff . getUserName ( ) ) . setAccount ( staff . getAccount ( ) ) . setRole ( staff . getRole ( ) ) . setWorkNumber ( staff . getWorkNumber ( ) ) . setStaffGradeName ( staff . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staff . getStaffProfessionalArchitectureName ( ) ) . setPhone ( staff . getPhone ( ) ) . setEmail ( staff . getEmail ( ) ) . setSchoolAppellationName ( staff . getSchoolAppellationName ( ) ) ;
vo . setIndex ( ii ) . setUserName ( staffVo . getUserName ( ) ) . setAccount ( staffVo . getAccount ( ) ) . setRole ( staffVo . getRole ( ) ) . setWorkNumber ( staffVo . getWorkNumber ( ) ) . setStaffGradeName ( staffVo . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staffVo . getStaffProfessionalArchitectureName ( ) ) . setStaffGradeNameTwo ( staffVo . getStaffGradeNameTwo ( ) ) . setStaffProfessionalArchitectureNameTwo ( staffVo . getStaffProfessionalArchitectureNameTwo ( ) ) . set Phone ( staffVo . getPhone ( ) ) . setEmail ( staffVo . getEmail ( ) ) . setSchoolAppellationName ( staffVo . getSchoolAppellationName ( ) ) ;
staffs . remove ( i ) ;
i - - ;
failVo1 . add ( vo ) ;
continue ;
}
if ( resultW . size ( ) > 0 ) {
StaffExportVo vo = new StaffExportVo ( ) ;
vo . setFailureMsg ( "重复的工号" ) ;
+ + ii ;
vo . setIndex ( ii ) . setUserName ( staff . getUserName ( ) ) . setAccount ( staff . getAccount ( ) ) . setRole ( staff . getRole ( ) ) . setWorkNumber ( staff . getWorkNumber ( ) ) . setStaffGradeName ( staff . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staff . getStaffProfessionalArchitectureName ( ) ) . setPhone ( staff . getPhone ( ) ) . setEmail ( staff . getEmail ( ) ) . setSchoolAppellationName ( staff . getSchoolAppellationName ( ) ) ;
vo . setIndex ( ii ) . setUserName ( staffVo . getUserName ( ) ) . setAccount ( staffVo . getAccount ( ) ) . setRole ( staffVo . getRole ( ) ) . setWorkNumber ( staffVo . getWorkNumber ( ) ) . setStaffGradeName ( staffVo . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staffVo . getStaffProfessionalArchitectureName ( ) ) . setStaffGradeNameTwo ( staffVo . getStaffGradeNameTwo ( ) ) . setStaffProfessionalArchitectureNameTwo ( staffVo . getStaffProfessionalArchitectureNameTwo ( ) ) . set Phone ( staffVo . getPhone ( ) ) . setEmail ( staffVo . getEmail ( ) ) . setSchoolAppellationName ( staffVo . getSchoolAppellationName ( ) ) ;
staffs . remove ( i ) ;
i - - ;
failVo1 . add ( vo ) ;
continue ;
} else if ( resultA . size ( ) > 0 ) {
StaffExportVo vo = new StaffExportVo ( ) ;
vo . setFailureMsg ( "重复的账号" ) ;
+ + ii ;
vo . setIndex ( ii ) . setUserName ( staff . getUserName ( ) ) . setAccount ( staff . getAccount ( ) ) . setRole ( staff . getRole ( ) ) . setWorkNumber ( staff . getWorkNumber ( ) ) . setStaffGradeName ( staff . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staff . getStaffProfessionalArchitectureName ( ) ) . setPhone ( staff . getPhone ( ) ) . setEmail ( staff . getEmail ( ) ) . setSchoolAppellationName ( staff . getSchoolAppellationName ( ) ) ;
vo . setIndex ( ii ) . setUserName ( staffVo . getUserName ( ) ) . setAccount ( staffVo . getAccount ( ) ) . setRole ( staffVo . getRole ( ) ) . setWorkNumber ( staffVo . getWorkNumber ( ) ) . setStaffGradeName ( staffVo . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staffVo . getStaffProfessionalArchitectureName ( ) ) . setStaffGradeNameTwo ( staffVo . getStaffGradeNameTwo ( ) ) . setStaffProfessionalArchitectureNameTwo ( staffVo . getStaffProfessionalArchitectureNameTwo ( ) ) . set Phone ( staffVo . getPhone ( ) ) . setEmail ( staffVo . getEmail ( ) ) . setSchoolAppellationName ( staffVo . getSchoolAppellationName ( ) ) ;
staffs . remove ( i ) ;
i - - ;
failVo1 . add ( vo ) ;
continue ;
} else if ( phone ! = null & & phone ! = "" ) {
List < Integer > resultP = userInfoDao . queryPhone ( phone ) ;
@ -266,24 +277,36 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
StaffExportVo vo = new StaffExportVo ( ) ;
vo . setFailureMsg ( "重复的手机号码" ) ;
+ + ii ;
vo . setIndex ( ii ) . setUserName ( staff . getUserName ( ) ) . setAccount ( staff . getAccount ( ) ) . setRole ( staff . getRole ( ) ) . setWorkNumber ( staff . getWorkNumber ( ) ) . setStaffGradeName ( staff . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staff . getStaffProfessionalArchitectureName ( ) ) . setPhone ( staff . getPhone ( ) ) . setEmail ( staff . getEmail ( ) ) . setSchoolAppellationName ( staff . getSchoolAppellationName ( ) ) ;
vo . setIndex ( ii ) . setUserName ( staffVo . getUserName ( ) ) . setAccount ( staffVo . getAccount ( ) ) . setRole ( staffVo . getRole ( ) ) . setWorkNumber ( staffVo . getWorkNumber ( ) ) . setStaffGradeName ( staffVo . getStaffGradeName ( ) ) . setStaffProfessionalArchitectureName ( staffVo . getStaffProfessionalArchitectureName ( ) ) . setStaffGradeNameTwo ( staffVo . getStaffGradeNameTwo ( ) ) . setStaffProfessionalArchitectureNameTwo ( staffVo . getStaffProfessionalArchitectureNameTwo ( ) ) . set Phone ( staffVo . getPhone ( ) ) . setEmail ( staffVo . getEmail ( ) ) . setSchoolAppellationName ( staffVo . getSchoolAppellationName ( ) ) ;
staffs . remove ( i ) ;
i - - ;
failVo1 . add ( vo ) ;
continue ;
}
}
+ + ii ;
if ( ! staffs . isEmpty ( ) & & staffs . size ( ) > 0 ) {
staffVo . setPassword ( ConstantUtils . INITIAL_PASSWORD ) ;
staffVo . setPassword ( ConstantUtils . INITIAL_PASSWORD ) . setUniqueIdentificationAccount ( String . valueOf ( System . currentTimeMillis ( ) ) ) ;
userInfoDao . addUserinfo ( staffVo ) ;
staff . setPlatformId ( ConstantUtils . PLATFORMID ) . setUserId ( staffVo . getUserId ( ) ) ;
boolean b = systemSetttingDao . addStaff ( staff ) ;
if ( ! b ) {
throw new RuntimeException ( ) ;
String [ ] split = staffVo . getRoleId ( ) . split ( "," ) ;
for ( String str : split ) {
if ( Integer . parseInt ( str ) = = 2 ) {
Integer gradeId = systemSetttingDao . queryDepartmentNameGrade ( staffVo . getStaffGradeName ( ) , ConstantUtils . Keda_schoolId ) ;
Integer organizationId = systemSetttingDao . queryDepartmentNameOrganization ( staffVo . getStaffProfessionalArchitectureName ( ) , ConstantUtils . Keda_schoolId ) ;
staffVo . setStaffGradeId ( gradeId ) . setStaffProfessionalArchitectureId ( organizationId ) ;
boolean b = systemSetttingDao . addStaffManager ( staffVo ) ;
if ( ! b ) { throw new RuntimeException ( ) ; }
} else if ( Integer . parseInt ( str ) = = 3 ) {
Integer organizationId = systemSetttingDao . queryDepartmentNameOrganization ( staffVo . getStaffProfessionalArchitectureNameTwo ( ) , ConstantUtils . Keda_schoolId ) ;
Integer gradeId = systemSetttingDao . queryDepartmentNameGrade ( staffVo . getStaffGradeNameTwo ( ) , organizationId ) ;
staffVo . setStaffGradeId ( gradeId ) . setStaffProfessionalArchitectureId ( organizationId ) ;
boolean b = systemSetttingDao . addStaffTeacher ( staffVo ) ;
if ( ! b ) { throw new RuntimeException ( ) ; }
}
}
}
}
} catch ( RuntimeException e ) {
e . printStackTrace ( ) ;
@ -326,7 +349,10 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
//2.加载模板流数据
org . springframework . core . io . Resource resource = new ClassPathResource ( "excel-template/员工信息导入失败模板.xlsx" ) ;
// org.springframework.core.io.Resource resource = new FileSystemResource("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
InputStream inputStream = resource . getInputStream ( ) ;
// InputStream inputStream = new FileInputStream("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
//3、通过工具类下载文件
new ExcelExportUtil ( StaffExportVo . class , Constant . ROW_INDEX , Constant . STYLE_INDEX ) .