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