人员管理
This commit is contained in:
parent
4bc14339a4
commit
072e1f3a20
|
|
@ -25,7 +25,6 @@ public class BusinessConstants {
|
||||||
public final static String FEMALE = "女";
|
public final static String FEMALE = "女";
|
||||||
public final static String OTHER = "其他";
|
public final static String OTHER = "其他";
|
||||||
|
|
||||||
|
|
||||||
public final static Integer CELL_1 = 1;
|
public final static Integer CELL_1 = 1;
|
||||||
public final static Integer CELL_2 = 2;
|
public final static Integer CELL_2 = 2;
|
||||||
public final static Integer CELL_3 = 3;
|
public final static Integer CELL_3 = 3;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.common.core.utils;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import sun.net.www.content.image.jpeg;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -20,12 +21,18 @@ public class UploadCheckUtils {
|
||||||
* 文件大小 10MB(可用于图片和视频区分)
|
* 文件大小 10MB(可用于图片和视频区分)
|
||||||
*/
|
*/
|
||||||
public static final long IMG_FILE_SIZE = 10 * 1024 * 1024;
|
public static final long IMG_FILE_SIZE = 10 * 1024 * 1024;
|
||||||
|
/**
|
||||||
|
* EXCEL文件大小 100MB
|
||||||
|
*/
|
||||||
|
public static final long EXCEL_FILE_SIZE = 100 * 1024 * 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 只支持图片格式
|
* 只支持图片格式
|
||||||
*/
|
*/
|
||||||
public static final String[] YES_IMAGE_SUPPORT = {".jpg", ".jpeg", ".png"};
|
public static final String[] YES_IMAGE_SUPPORT = {".jpg", ".jpeg", ".png"};
|
||||||
|
|
||||||
|
public static final String[] YES_EXCEL_SUPPORT = {".xlsx", ".xls"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 只支持视频格式
|
* 只支持视频格式
|
||||||
*/
|
*/
|
||||||
|
|
@ -97,4 +104,35 @@ public class UploadCheckUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String uploadExcelVerify(MultipartFile multipartFile) {
|
||||||
|
// 校验文件是否为空
|
||||||
|
if (multipartFile == null) {
|
||||||
|
return "上传文件不能为空";
|
||||||
|
}
|
||||||
|
// 校验文件名字
|
||||||
|
String originalFilename = multipartFile.getOriginalFilename();
|
||||||
|
if (originalFilename == null) {
|
||||||
|
return "上传文件名字不能为空";
|
||||||
|
}
|
||||||
|
for (String realKey : FILE_NAME_EXCLUDE) {
|
||||||
|
if (originalFilename.contains(realKey)) {
|
||||||
|
return "上传文件名称不允许出现"+realKey+"关键字";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 校验文件后缀
|
||||||
|
if (!originalFilename.contains(SUFFIX)) {
|
||||||
|
return "上传文件不能没有后缀";
|
||||||
|
}
|
||||||
|
String suffix = originalFilename.substring(originalFilename.lastIndexOf('.'));
|
||||||
|
/*校验: 文件格式是否符合要求*/
|
||||||
|
if (!Arrays.asList(YES_EXCEL_SUPPORT).contains(suffix.toLowerCase(Locale.ROOT))) {
|
||||||
|
return "上传文件格式仅支持" + Arrays.asList(YES_EXCEL_SUPPORT).toString();
|
||||||
|
}
|
||||||
|
Long fileSize = multipartFile.getSize();
|
||||||
|
if (fileSize > EXCEL_FILE_SIZE) {
|
||||||
|
return "上传文件大小仅支持100MB以内";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bonus.bracelet.controller;
|
package com.bonus.bracelet.controller;
|
||||||
|
|
||||||
import com.bonus.bracelet.service.IPersonMgeService;
|
import com.bonus.bracelet.service.IPersonMgeService;
|
||||||
|
import com.bonus.common.core.constant.BusinessConstants;
|
||||||
|
import com.bonus.common.core.utils.UploadCheckUtils;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.web.page.TableDataInfo;
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
|
@ -10,6 +12,7 @@ import com.bonus.common.log.annotation.SysLog;
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
@ -72,6 +75,10 @@ public class PersonMgeController extends BaseController {
|
||||||
// @RequiresPermissions("basic:person:excelUpload")
|
// @RequiresPermissions("basic:person:excelUpload")
|
||||||
@SysLog(title = "人员管理", businessType = OperaType.IMPORT,logType = 0,module = "基础管理->人员管理",details ="人员导入" )
|
@SysLog(title = "人员管理", businessType = OperaType.IMPORT,logType = 0,module = "基础管理->人员管理",details ="人员导入" )
|
||||||
public AjaxResult excelUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response){
|
public AjaxResult excelUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response){
|
||||||
|
String result = UploadCheckUtils.uploadExcelVerify(file);
|
||||||
|
if(StringUtils.isNotBlank(result)){
|
||||||
|
return AjaxResult.error(result);
|
||||||
|
}
|
||||||
return service.excelUpload(file, request, response);
|
return service.excelUpload(file, request, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.bracelet.mapper;
|
||||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||||
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
||||||
import org.apache.ibatis.annotations.MapKey;
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -70,10 +71,22 @@ public interface PersonMgeMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询人员列表
|
* 查询人员列表
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return List<PersonVo>
|
* @return List<PersonVo>
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
* @date 2024/7/16 15:45
|
* @date 2024/7/16 15:45
|
||||||
*/
|
*/
|
||||||
List<PersonVo> getPersonLists(BraceletParamsDto dto);
|
List<PersonVo> getPersonLists(BraceletParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证安全帽编号、马甲编码是否存在
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @param type
|
||||||
|
* @return int
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/7/17 13:27
|
||||||
|
*/
|
||||||
|
int codeIsExist(@Param("params") PersonVo vo, @Param("type") int type);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,19 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
if (idCardIsExist(list, vo, 2)) {
|
if (idCardIsExist(list, vo, 2)) {
|
||||||
return AjaxResult.error("电话已存在");
|
return AjaxResult.error("电话已存在");
|
||||||
}
|
}
|
||||||
|
// 验证安全帽编号是否重复、马甲编号是否重复
|
||||||
|
if(StringUtils.isNotBlank(vo.getAqmCode())){
|
||||||
|
int result = mapper.codeIsExist(vo,1);
|
||||||
|
if(result > 0){
|
||||||
|
return AjaxResult.error("安全帽编号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(vo.getMjCode())){
|
||||||
|
int result = mapper.codeIsExist(vo,2);
|
||||||
|
if(result > 0){
|
||||||
|
return AjaxResult.error("马甲编号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
// 校验文件、上传文件
|
// 校验文件、上传文件
|
||||||
String isVerify = UploadCheckUtils.uploadImgVerify(file);
|
String isVerify = UploadCheckUtils.uploadImgVerify(file);
|
||||||
if (StringUtils.isNotBlank(isVerify)) {
|
if (StringUtils.isNotBlank(isVerify)) {
|
||||||
|
|
@ -140,6 +153,19 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
if (idCardIsExist(list, vo, 2)) {
|
if (idCardIsExist(list, vo, 2)) {
|
||||||
return AjaxResult.error("电话已存在");
|
return AjaxResult.error("电话已存在");
|
||||||
}
|
}
|
||||||
|
// 验证安全帽编号是否重复、马甲编号是否重复
|
||||||
|
if(StringUtils.isNotBlank(vo.getAqmCode())){
|
||||||
|
int result = mapper.codeIsExist(vo,1);
|
||||||
|
if(result > 0){
|
||||||
|
return AjaxResult.error("安全帽编号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(vo.getMjCode())){
|
||||||
|
int result = mapper.codeIsExist(vo,2);
|
||||||
|
if(result > 0){
|
||||||
|
return AjaxResult.error("马甲编号已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
// 校验文件、上传文件
|
// 校验文件、上传文件
|
||||||
if (StringUtils.isNotBlank(vo.getDelFiles())) {
|
if (StringUtils.isNotBlank(vo.getDelFiles())) {
|
||||||
String isVerify = UploadCheckUtils.uploadImgVerify(file);
|
String isVerify = UploadCheckUtils.uploadImgVerify(file);
|
||||||
|
|
@ -421,7 +447,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
String value = map.get(key);
|
String value = map.get(key);
|
||||||
if (value.indexOf(",") != -1) {
|
if (value.indexOf(",") != -1) {
|
||||||
System.out.println(key + " 重复,行: " + value);
|
System.out.println(key + " 重复,行: " + value);
|
||||||
errList.add(name + ":" + key + " 重复,重复行: " + value);
|
errList.add(name + " 重复,重复行: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errList;
|
return errList;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@ server:
|
||||||
port: 18086
|
port: 18086
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: -1
|
||||||
|
max-request-size: -1
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: bonus-bracelet
|
name: bonus-bracelet
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
ORDER BY tp.create_time
|
ORDER BY tp.create_time
|
||||||
</select>
|
</select>
|
||||||
|
<!--验证安全帽编号是否重复、马甲编号是否重复-->
|
||||||
|
<select id="codeIsExist" resultType="java.lang.Integer">
|
||||||
|
<if test="type == 1">
|
||||||
|
<if test="id == null">
|
||||||
|
SELECT COUNT(*) FROM tb_people WHERE aqm_code = #{params.aqmCode} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
<if test="id != null">
|
||||||
|
SELECT COUNT(*) FROM tb_people WHERE id != #{params.id} AND aqm_code = #{params.aqmCode} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
<if test="type == 2">
|
||||||
|
<if test="id == null">
|
||||||
|
SELECT COUNT(*) FROM tb_people WHERE mj_code = #{params.mjCode} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
<if test="id != null">
|
||||||
|
SELECT COUNT(*) FROM tb_people WHERE mj_code = #{params.mjCode} AND id != #{params.id} AND del_flag = 0
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue