临时人员
This commit is contained in:
parent
d6a1f0fe56
commit
5bcd9950ac
|
|
@ -180,6 +180,9 @@ public class PersonVo implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Integer isPush = 0;
|
private Integer isPush = 0;
|
||||||
|
|
||||||
|
/**班组名称*/
|
||||||
|
private String teamName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询条件限制
|
* 查询条件限制
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.bonus.bracelet.controller;
|
||||||
|
|
||||||
|
import com.bonus.bracelet.service.TemporarilyPersonService;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||||
|
import com.bonus.common.log.annotation.SysLog;
|
||||||
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:TemporarilyPersonController
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2024-09-30-9:23
|
||||||
|
* @version:1.0
|
||||||
|
* @description:临时人员-controller
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/temporarilyPerson/")
|
||||||
|
@Slf4j
|
||||||
|
public class TemporarilyPersonController extends BaseController {
|
||||||
|
|
||||||
|
@Resource(name = "TemporarilyPersonService")
|
||||||
|
private TemporarilyPersonService service;
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
@SysLog(title = "临时人员管理", businessType = OperaType.QUERY, logType = 0, module = "基础管理->临时人员管理", details = "查询临时人员列表")
|
||||||
|
public TableDataInfo list(BraceletParamsDto dto) {
|
||||||
|
startPage();
|
||||||
|
TableDataInfo tableDataInfo = service.getTemporarilyPersons(dto);
|
||||||
|
return tableDataInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delTemporarilyPerson")
|
||||||
|
@SysLog(title = "临时人员管理", businessType = OperaType.DELETE, logType = 0, module = "基础管理->临时人员管理", details = "删除临时人员")
|
||||||
|
public AjaxResult delTemporarilyPerson(@RequestBody BraceletParamsDto dto) {
|
||||||
|
return service.delTemporarilyPerson(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.bonus.bracelet.mapper;
|
||||||
|
|
||||||
|
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||||
|
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:TemporarilyPersonMapper
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2024-09-30-9:27
|
||||||
|
* @version:1.0
|
||||||
|
* @description:临时人员-mapper
|
||||||
|
*/
|
||||||
|
@Repository(value = "TemporarilyPersonMapper")
|
||||||
|
public interface TemporarilyPersonMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时人员列表
|
||||||
|
* @param dto
|
||||||
|
* @return List<PersonVo>
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/9/30 9:39
|
||||||
|
*/
|
||||||
|
List<PersonVo> getTemporarilyPersons(BraceletParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除临时人员
|
||||||
|
* @param dto
|
||||||
|
* @return void
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/9/30 10:26
|
||||||
|
*/
|
||||||
|
void delTemporarilyPerson(BraceletParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新手环绑定的临时人员
|
||||||
|
* @param dto
|
||||||
|
* @return void
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/9/30 10:30
|
||||||
|
*/
|
||||||
|
void updateBracelet(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询临时人员绑定的手环设备
|
||||||
|
* @param dto
|
||||||
|
* @return Long
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/9/30 10:36
|
||||||
|
*/
|
||||||
|
Long getBraceletByTemporarilyPerson(BraceletParamsDto dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.bonus.bracelet.service;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:TemporarilyPersonService
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2024-09-30-9:25
|
||||||
|
* @version:1.0
|
||||||
|
* @description:临时人员-service
|
||||||
|
*/
|
||||||
|
public interface TemporarilyPersonService {
|
||||||
|
TableDataInfo getTemporarilyPersons(BraceletParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除临时人员
|
||||||
|
* @param dto
|
||||||
|
* @return AjaxResult
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/9/30 10:25
|
||||||
|
*/
|
||||||
|
AjaxResult delTemporarilyPerson(BraceletParamsDto dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,182 @@
|
||||||
|
package com.bonus.bracelet.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.bonus.bracelet.mapper.ResourceFileMapper;
|
||||||
|
import com.bonus.bracelet.mapper.TemporarilyPersonMapper;
|
||||||
|
import com.bonus.bracelet.service.TemporarilyPersonService;
|
||||||
|
import com.bonus.common.core.constant.BusinessConstants;
|
||||||
|
import com.bonus.common.core.constant.HttpStatus;
|
||||||
|
import com.bonus.common.core.constant.SecurityConstants;
|
||||||
|
import com.bonus.common.core.domain.R;
|
||||||
|
import com.bonus.common.core.utils.FaceCodeUtil;
|
||||||
|
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||||
|
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
||||||
|
import com.bonus.system.api.RemoteFileService;
|
||||||
|
import com.bonus.system.api.domain.SysFile;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @className:TemporarilyPersonServiceImpl
|
||||||
|
* @author:cwchen
|
||||||
|
* @date:2024-09-30-9:26
|
||||||
|
* @version:1.0
|
||||||
|
* @description:临时人员-业务逻辑层
|
||||||
|
*/
|
||||||
|
@Service(value = "TemporarilyPersonService")
|
||||||
|
@Slf4j
|
||||||
|
public class TemporarilyPersonServiceImpl implements TemporarilyPersonService {
|
||||||
|
|
||||||
|
@Resource(name = "TemporarilyPersonMapper")
|
||||||
|
private TemporarilyPersonMapper mapper;
|
||||||
|
|
||||||
|
@Resource(name = "testTaskExecutor")
|
||||||
|
private ThreadPoolTaskExecutor testTaskExecutor;
|
||||||
|
|
||||||
|
@Resource(name = "ResourceFileMapper")
|
||||||
|
private ResourceFileMapper resourceFileMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemoteFileService remoteFileService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FaceInterUtilService faceInterService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataInfo getTemporarilyPersons(BraceletParamsDto dto) {
|
||||||
|
dto.setSourceType(BusinessConstants.RESOURCE_TYPE_USERTEMP);
|
||||||
|
List<PersonVo> list = new ArrayList<>();
|
||||||
|
List<Future> futureList = new ArrayList<>();
|
||||||
|
List<PersonVo> newList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
list = mapper.getTemporarilyPersons(dto);
|
||||||
|
for (PersonVo vo : list) {
|
||||||
|
Future<PersonVo> future = testTaskExecutor.submit(new Callable<PersonVo>() {
|
||||||
|
@Override
|
||||||
|
public PersonVo call() throws Exception {
|
||||||
|
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
|
||||||
|
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
|
||||||
|
String imageBase64 = getImageBase64(vo.getFilePath());
|
||||||
|
vo.setBase64Url(imageBase64);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
futureList.add(future);
|
||||||
|
}
|
||||||
|
for (Future<PersonVo> future : futureList) {
|
||||||
|
PersonVo vo = future.get();
|
||||||
|
newList.add(vo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询人员列表", e);
|
||||||
|
}
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setRows(newList);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setTotal(new PageInfo(list).getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult delTemporarilyPerson(BraceletParamsDto dto) {
|
||||||
|
try {
|
||||||
|
if (dto.getId() == null) {
|
||||||
|
return AjaxResult.error("参数不能为空");
|
||||||
|
}
|
||||||
|
// 删除临时人员、更新手环绑定的临时人员
|
||||||
|
mapper.delTemporarilyPerson(dto);
|
||||||
|
Long id = mapper.getBraceletByTemporarilyPerson(dto);
|
||||||
|
mapper.updateBracelet(id);
|
||||||
|
if (StringUtils.isNotBlank(dto.getFilePath())) {
|
||||||
|
String personImgBase64 = getPersonImgBase64(dto.getFilePath());
|
||||||
|
// 删除人脸库
|
||||||
|
AjaxResult delAjax = delFaceToLibrary(personImgBase64, FaceCodeUtil.DEL, "ls-" + dto.getId());
|
||||||
|
if (dto.getFileId() != null) {
|
||||||
|
resourceFileMapper.delResourceFile(dto.getFileId());
|
||||||
|
remoteFileService.delFile(String.valueOf(dto.getFileId()), SecurityConstants.INNER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图片的base64
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @return String
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/8/20 9:18
|
||||||
|
*/
|
||||||
|
public String getImageBase64(String filePath) {
|
||||||
|
R<SysFile> result = remoteFileService.getImgBase64(filePath, SecurityConstants.INNER);
|
||||||
|
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
||||||
|
String jsonString = JSON.toJSONString(result.getData());
|
||||||
|
JSONObject item = JSON.parseObject(jsonString);
|
||||||
|
String base64 = item.getString("url");
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件ID获取图片base64
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @return String
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/8/12 14:35
|
||||||
|
*/
|
||||||
|
public String getPersonImgBase64(String filePath) {
|
||||||
|
R<SysFile> result = remoteFileService.getImgBase64(filePath, SecurityConstants.INNER);
|
||||||
|
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
||||||
|
String jsonString = JSON.toJSONString(result.getData());
|
||||||
|
JSONObject item = JSON.parseObject(jsonString);
|
||||||
|
String base64 = item.getString("url");
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人脸库
|
||||||
|
*
|
||||||
|
* @param base64
|
||||||
|
* @param type
|
||||||
|
* @param id
|
||||||
|
* @return Integer
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/8/12 13:27
|
||||||
|
*/
|
||||||
|
public AjaxResult delFaceToLibrary(String base64, String type, String id) {
|
||||||
|
if (StringUtils.isEmpty(base64)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
|
||||||
|
log.info("删除人脸库返回结果:{}", ajaxResult);
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.bracelet.mapper.TemporarilyPersonMapper">
|
||||||
|
<update id="updateBracelet">
|
||||||
|
UPDATE tb_bracelet SET peopel_type = null,bid_id = null,bid_time = null,face_status = null WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
<!--删除临时人员-->
|
||||||
|
<delete id="delTemporarilyPerson">
|
||||||
|
DELETE FROM tb_ls_user WHERE id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!--临时人员列表-->
|
||||||
|
<select id="getTemporarilyPersons" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
|
||||||
|
SELECT tls.id,
|
||||||
|
tls.name,
|
||||||
|
tls.sex,
|
||||||
|
tls.id_card AS idCard,
|
||||||
|
tls.phone,
|
||||||
|
sfs.file_path AS filePath,
|
||||||
|
sfs.id AS fileId,
|
||||||
|
twt.team_name AS teamName
|
||||||
|
FROM tb_ls_user tls
|
||||||
|
LEFT JOIN t_work_team twt ON tls.team_id = twt.team_id AND twt.del_flag = 0
|
||||||
|
LEFT JOIN sys_file_source sfs ON tls.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
|
||||||
|
<where>
|
||||||
|
<if test="keyWord != null and keyWord!=''">
|
||||||
|
(
|
||||||
|
INSTR(tls.name,#{keyWord}) > 0 OR
|
||||||
|
INSTR(twt.team_name,#{keyWord}) > 0
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<!--查询临时人员绑定的手环设备-->
|
||||||
|
<select id="getBraceletByTemporarilyPerson" resultType="java.lang.Long">
|
||||||
|
SELECT id FROM tb_bracelet WHERE bid_id = #{id} AND peopel_type = 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue