人员管理添加岗位

This commit is contained in:
cwchen 2024-08-12 10:56:20 +08:00
parent 1f1d6f0258
commit 15505541dc
9 changed files with 131 additions and 62 deletions

View File

@ -26,7 +26,7 @@ public class BusinessConstants {
public final static String XLS = ".xls";
/** 人员导入*/
public final static String PERSON_IMPORT_VO = "PersonExportVo";
public final static String PERSON_IMPORT_VO = "PersonImportVo";
public final static String MAN = "";
public final static String FEMALE = "";
public final static String OTHER = "其他";

View File

@ -86,9 +86,9 @@ public class ImportExcelUtils {
}
private static boolean checkModal(Sheet sheet, String className) {
int colNum = sheet.getRow(0).getLastCellNum();
int colNum = sheet.getRow(1).getLastCellNum();
if (Objects.equals(className, BusinessConstants.PERSON_IMPORT_VO)) {
return colNum == 6;
return colNum == 7;
}
return false;
}
@ -166,6 +166,10 @@ public class ImportExcelUtils {
obj.put("phone", row.getCell(BusinessConstants.CELL_4).getStringCellValue());
}
obj = setFileObj(row, obj, files);
if (row.getCell(BusinessConstants.CELL_6) != null) {
// 人员岗位
obj.put("post", row.getCell(BusinessConstants.CELL_6).getStringCellValue());
}
return obj;
}

View File

@ -33,4 +33,7 @@ public class PersonExportVo {
@Excel(name = "马甲编号", width = 20.0,height = 15.0,orderNum = "6")
private String mjCode;
@Excel(name = "人员岗位", width = 20.0,height = 15.0,orderNum = "7")
private String post;
}

View File

@ -45,4 +45,9 @@ public class PersonImportVo implements Serializable {
* 人脸照片
*/
private MultipartFile file;
/**
* 岗位
*/
private String post;
}

View File

@ -67,12 +67,12 @@ public class PersonVo implements Serializable {
/**
* 安全帽编号
*/
@Length(max = 10, message = "安全帽编号字符长度不能超过20", groups = {Query.class})
@Length(max = 10, message = "安全帽编号字符长度不能超过10", groups = {Query.class})
private String aqmCode;
/**
* 马甲编号
*/
@Length(max = 10, message = "马甲编号字符长度不能超过20", groups = {Query.class})
@Length(max = 10, message = "马甲编号字符长度不能超过10", groups = {Query.class})
private String mjCode;
/**
* 创建时间
@ -168,6 +168,18 @@ public class PersonVo implements Serializable {
*/
private List<String> delElseFileIdList;
/**
* 岗位
*/
@NotBlank(message = "人员岗位不能为空", groups = {Query.class})
@Length(max = 32, message = "人员岗位字符长度不能超过32", groups = {Query.class})
private String post;
/**
* 是否推送至人脸库 0.未推送 1.已推送
*/
private Integer isPush;
/**
* 查询条件限制
*/

View File

@ -202,4 +202,13 @@ public interface PersonMgeMapper {
* @param vo
*/
public void insertCertificate(CertificateVo vo);
/**
* 获取人员岗位
* @return List<Map<String,String>>
* @author cwchen
* @date 2024/8/12 10:02
*/
@MapKey("name")
List<Map<String, String>> getPostType();
}

View File

@ -94,7 +94,8 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
try {
list = mapper.getExportPersonLists(dto);
for (PersonVo vo : list) {
vo = handleData(vo);
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
}
} catch (Exception e) {
log.error(e.toString(), e);
@ -122,15 +123,15 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
return AjaxResult.error("电话已存在");
}
// 验证安全帽编号是否重复马甲编号是否重复
if(StringUtils.isNotBlank(vo.getAqmCode())){
int result = mapper.codeIsExist(vo,1);
if(result > 0){
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){
if (StringUtils.isNotBlank(vo.getMjCode())) {
int result = mapper.codeIsExist(vo, 2);
if (result > 0) {
return AjaxResult.error("马甲编号已存在");
}
}
@ -176,15 +177,15 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
return AjaxResult.error("电话已存在");
}
// 验证安全帽编号是否重复马甲编号是否重复
if(StringUtils.isNotBlank(vo.getAqmCode())){
int result = mapper.codeIsExist(vo,1);
if(result > 0){
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){
if (StringUtils.isNotBlank(vo.getMjCode())) {
int result = mapper.codeIsExist(vo, 2);
if (result > 0) {
return AjaxResult.error("马甲编号已存在");
}
}
@ -242,10 +243,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
// 删除人员资源文件人脸照片
mapper.delPerson(dto);
list = mapper.getCertificate(dto);
if(list!=null){
list = mapper.getCertificate(dto);
if (list != null) {
for (int i = 0; i < list.size(); i++) {
list.get(i).setCertificateType(list.get(i).getCertificateType()+1);
list.get(i).setCertificateType(list.get(i).getCertificateType() + 1);
mapper.delCertificateResourceFile(list.get(i));
}
}
@ -263,18 +264,24 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult excelUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
String result = UploadCheckUtils.uploadExcelVerify(file);
if(StringUtils.isNotBlank(result)){
return AjaxResult.error(result);
}
List<String> errorFileLists = new ArrayList<>();
try {
List<JSONObject> lstObj = (List<JSONObject>) ImportExcelUtils.readExcel(file, PersonExportVo.class, tempFilePath);
List<JSONObject> lstObj = (List<JSONObject>) ImportExcelUtils.readExcel(file, PersonImportVo.class, tempFilePath);
List<PersonVo> list = new ArrayList<>();
if (CollectionUtils.isEmpty(lstObj)) {
return AjaxResult.error("请勿导入空数据");
}
// 获取人员岗位
List<Map<String, String>> postTypeList = mapper.getPostType();
// 校验数据是否合法包含照片验证
for (JSONObject obj : lstObj) {
PersonImportVo vo = new PersonImportVo();
PersonVo personVo = new PersonVo();
vo = setPersonData(vo, obj);
vo = setPersonData(vo, obj, postTypeList);
String isVerify = UploadCheckUtils.uploadImgVerify(vo.getFile());
if (StringUtils.isNotBlank(isVerify)) {
return AjaxResult.error("" + obj.getString("rowNo") + "行人脸照片" + isVerify);
@ -301,10 +308,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
List<Map<String, String>> personIsExist = mapper.personIsExist(new PersonVo());
for (PersonVo vo : list) {
if (idCardIsExist(personIsExist, vo, 1)) {
return AjaxResult.error(""+vo.getSerialNumber()+"行身份证号码已存在");
return AjaxResult.error("" + vo.getSerialNumber() + "行身份证号码已存在");
}
if (idCardIsExist(personIsExist, vo, 2)) {
return AjaxResult.error(""+vo.getSerialNumber()+"行电话已存在");
return AjaxResult.error("" + vo.getSerialNumber() + "行电话已存在");
}
}
for (PersonVo vo : list) {
@ -316,7 +323,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
errorFileLists.add(delFileId);
}
} catch (RuntimeException runtimeException) {
if(runtimeException.getMessage() == null){
if (runtimeException.getMessage() == null) {
return AjaxResult.error("模板中含有单元格数据格式不正确");
}
return AjaxResult.error(runtimeException.getMessage());
@ -418,15 +425,16 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
/**
* 证书资源文件赋值
*
* @param item
* @param vo
* @return
*/
public ResourceFileVo setCertificateResourceFileData(JSONObject item, CertificateVo vo) {
ResourceFileVo fileVo = new ResourceFileVo();
String fileType = String.valueOf(vo.getCertificateType()+1);
String fileType = String.valueOf(vo.getCertificateType() + 1);
String resourceId = IdUtils.simpleUUID();
fileVo.setFileType(vo.getCertificateType()+1);
fileVo.setFileType(vo.getCertificateType() + 1);
fileVo.setFilePath(item.getString("fileId"));
fileVo.setFileSuffix(item.getString("suffix"));
fileVo.setFileName(item.getString("fileName"));
@ -444,16 +452,37 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
* @author cwchen
* @date 2024/7/17 10:38
*/
public PersonImportVo setPersonData(PersonImportVo vo, JSONObject obj) {
public PersonImportVo setPersonData(PersonImportVo vo, JSONObject obj, List<Map<String, String>> postList) {
vo.setSerialNumber(obj.getString("rowNum"));
vo.setName(handleData(obj.getString("name")));
vo.setSex(setSexData(handleData(obj.getString("sex"))));
vo.setIdCard(handleData(obj.getString("idCard")));
vo.setPhone(handleData(obj.getString("phone")));
vo.setFile(obj.get("file") != null ? (MultipartFile) obj.get("file") : null);
vo.setPost(setPost(postList,handleData(obj.getString("post"))));
return vo;
}
/**
* 设置人员岗位
* @param postList
* @param value
* @return String
* @author cwchen
* @date 2024/8/12 10:07
*/
public String setPost(List<Map<String, String>> postList, String value) {
if (CollectionUtils.isEmpty(postList)) {
return null;
}
for (Map<String, String> map : postList) {
if (Objects.equals(map.get("name"), value)) {
return map.get("value");
}
}
return null;
}
/**
* 处理性别
*
@ -521,8 +550,8 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
return null;
}
public String handleData(String value){
if(StringUtils.isNotBlank(value)){
public String handleData(String value) {
if (StringUtils.isNotBlank(value)) {
return value.trim();
}
return null;
@ -534,13 +563,13 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
List<ResourceFileVo> electricianImgList = new ArrayList<>();
List<ResourceFileVo> elseImgList = new ArrayList<>();
try {
PersonVo vo = mapper.selectCertificateById(memberId);
if(ObjectUtil.isNotEmpty(vo)){
List<ResourceFileVo> list = mapper.selectCertificateFile(memberId);
PersonVo vo = mapper.selectCertificateById(memberId);
if (ObjectUtil.isNotEmpty(vo)) {
List<ResourceFileVo> list = mapper.selectCertificateFile(memberId);
getImageFile(list);
highImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType()==2)).collect(Collectors.toList());
electricianImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType()==3)).collect(Collectors.toList());
elseImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType()==4)).collect(Collectors.toList());
highImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType() == 2)).collect(Collectors.toList());
electricianImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType() == 3)).collect(Collectors.toList());
elseImgList = list.stream().filter(bracelet -> (bracelet.getSourceImagType() == 4)).collect(Collectors.toList());
vo.setHighImgList(highImgList);
vo.setElectricianImgList(electricianImgList);
vo.setElseImgList(elseImgList);
@ -554,12 +583,13 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
/**
* 图片查询
*
* @param list
* @return
*/
public void getImageFile(List<ResourceFileVo> list) {
if(com.bonus.common.core.utils.StringUtils.isNotEmpty(list)){
list.forEach(file->{
public void getImageFile(List<ResourceFileVo> list) {
if (com.bonus.common.core.utils.StringUtils.isNotEmpty(list)) {
list.forEach(file -> {
R<SysFile> result = remoteFileService.getImgBase64(file.getFilePath(), SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
String jsonString = JSON.toJSONString(result.getData());
@ -572,11 +602,11 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
public AjaxResult updateCertificate( MultipartFile[] highfile, MultipartFile[] electfile,MultipartFile[] elsefile, Long id){
public AjaxResult updateCertificate(MultipartFile[] highfile, MultipartFile[] electfile, MultipartFile[] elsefile, Long id) {
String delFileId = null;
CertificateVo vo = new CertificateVo();
try{
if(highfile!=null) {
try {
if (highfile != null) {
R result = remoteFileService.mostUploadFile(highfile, SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.ERROR) {
log.error("高处作业证上传失败");
@ -597,7 +627,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
}
}
if(electfile!=null) {
if (electfile != null) {
R result2 = remoteFileService.mostUploadFile(electfile, SecurityConstants.INNER);
if (result2 != null && result2.getCode() == HttpStatus.ERROR) {
log.error("电工作业证上传失败");
@ -618,7 +648,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
}
}
if(elsefile!=null) {
if (elsefile != null) {
R result3 = remoteFileService.mostUploadFile(elsefile, SecurityConstants.INNER);
if (result3 != null && result3.getCode() == HttpStatus.ERROR) {
log.error("其他作业证上传失败");
@ -639,7 +669,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
}
}
}catch (Exception e) {
} catch (Exception e) {
log.error("新增证书", e);
// 添加失败-删除文件
if (org.apache.commons.lang3.StringUtils.isNotEmpty(delFileId)) {
@ -650,5 +680,5 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
}
return AjaxResult.success();
}
}
}

View File

@ -18,7 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_time,
update_user,
del_flag,
id
id,
post,
is_push
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
@ -32,12 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{updateTime},
#{updateUser},
0,
null
null,
#{post},
#{isPush}
</trim>
</insert>
<!--修改人员-->
<update id="editPerson">
UPDATE tb_people SET name = #{name},sex = #{sex},id_card = #{idCard},phone = #{phone},aqm_code = #{aqmCode},mj_code = #{mjCode},update_time = #{updateTime},update_user = #{updateUser} WHERE id = #{id}
UPDATE tb_people SET name = #{name},sex = #{sex},id_card = #{idCard},phone = #{phone},aqm_code = #{aqmCode},mj_code = #{mjCode},update_time = #{updateTime},update_user = #{updateUser},post = #{post},is_push = #{isPush} WHERE id = #{id}
</update>
<!--删除人员-->
<update id="delPerson">
@ -63,7 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tp.aqm_code AS aqmCode,
tp.mj_code AS mjCode,
sfs.file_path AS filePath,
sfs.id AS fileId
sfs.id AS fileId,
tp.post
FROM tb_people tp
LEFT JOIN sys_file_source sfs ON tp.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
WHERE tp.id = #{id} AND tp.del_flag = 0
@ -79,8 +84,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tp.mj_code AS mjCode,
sfs.file_path AS filePath,
sfs.id AS fileId,
sdd.dict_label AS post,
IFNULL(tp.is_push,0) AS isPush,
count(tpc.id) as certificateNum
FROM tb_people tp
LEFT JOIN sys_dict_data sdd ON tp.post = sdd.dict_value AND sdd.dict_type = 'post_type' AND sdd.status = '0'
LEFT JOIN sys_file_source sfs ON tp.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
LEFT JOIN tb_people_certificate tpc on tp.id = tpc.people_id
WHERE tp.del_flag = 0
@ -89,18 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="sex != null">
AND tp.sex = #{sex}
</if>
<if test="roleCode == 'administrators'">
</if>
<if test="roleCode == 'depart'">
</if>
<if test="roleCode == 'team'">
</if>
GROUP BY tp.id,sfs.id,sfs.file_path
ORDER BY tp.update_time DESC
ORDER BY tp.create_time DESC
</select>
<!--验证安全帽编号是否重复、马甲编号是否重复-->
<select id="codeIsExist" resultType="java.lang.Integer">
@ -229,8 +228,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tp.id_card AS idCard,
tp.phone,
tp.aqm_code AS aqmCode,
tp.mj_code AS mjCode
tp.mj_code AS mjCode,
sdd.dict_label AS post
FROM tb_people tp
LEFT JOIN sys_dict_data sdd ON tp.post = sdd.dict_value AND sdd.dict_type = 'post_type' AND sdd.status = '0'
WHERE tp.del_flag = 0
<if test="name != null and name!=''">
AND INSTR(tp.name,#{name}) > 0
@ -240,6 +241,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
ORDER BY tp.update_time DESC
</select>
<!--获取人员岗位-->
<select id="getPostType" resultType="java.util.Map">
SELECT dict_label AS name, dict_value AS value FROM sys_dict_data sdd
WHERE sdd.dict_type = 'post_type' AND sdd.status = '0'
</select>
<!--删除资源文件-->
<update id="delCertificateResourceFile">