diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/HumanManageVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/HumanManageVo.java index a2c29df..87deffa 100644 --- a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/HumanManageVo.java +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/HumanManageVo.java @@ -3,6 +3,10 @@ package com.securitycontrol.entity.background.vo; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.util.List; /** * @author 10488 @@ -14,18 +18,28 @@ public class HumanManageVo { private String userId; @ApiModelProperty(value = "班组ID") + @NotBlank(message = "班组不能为空", groups = {Query.class}) + @Length(max = 100, message = "班组字符长度不能超过100", groups = {Query.class}) private String teamId; @ApiModelProperty(value = "人员姓名") + @NotBlank(message = "人员姓名不能为空", groups = {Query.class}) + @Length(max = 30, message = "人员姓名字符长度不能超过30", groups = {Query.class}) private String userName; @ApiModelProperty(value = "身份证号码") + @NotBlank(message = "身份证号码不能为空", groups = {Query.class}) + @Length(max = 100, message = "身份证号码字符长度不能超过100", groups = {Query.class}) private String idNumber; @ApiModelProperty(value = "手机号码") + @NotBlank(message = "手机号码不能为空", groups = {Query.class}) + @Length(max = 20, message = "手机号码字符长度不能超过100", groups = {Query.class}) private String phone; @ApiModelProperty(value = "工种") + @NotBlank(message = "工种不能为空", groups = {Query.class}) + @Length(max = 30, message = "工种字符长度不能超过30", groups = {Query.class}) private String userType; @ApiModelProperty(value = "人员状态") @@ -51,11 +65,21 @@ public class HumanManageVo { private String proName; @JsonInclude(JsonInclude.Include.NON_EMPTY) + @ApiModelProperty(value = "删除的文件ID") private String delFiles; @ApiModelProperty(value = "创建时间") private String createTime; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List fileData; + + @Data + public static class FileData{ + private String fileId; + private String base64Url; + } /** * 查询条件限制 */ diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/HumanManageController.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/HumanManageController.java index 054cf33..7c6942a 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/HumanManageController.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/HumanManageController.java @@ -53,11 +53,17 @@ public class HumanManageController extends BaseController { return service.addOrUpdatePersonnel(file, params); } + @ApiOperation(value = "人员详情") + @GetMapping("getPersonnelById") + public AjaxResult getPersonnelById(ParamDto dto) { + return service.getPersonnelById(dto); + } + @ApiOperation(value = "删除人员") - @PostMapping("delHuman") + @PostMapping("delPersonnel") @Log(title = "人员管理", menu = "人车管理->人员管理", grade = OperationType.DELETE_BUSINESS, details = "删除人员", type = "业务日志") - public AjaxResult delPro(@RequestBody HumanManageVo dto) { - return service.delHuman(dto); + public AjaxResult delPersonnelById(@RequestBody ParamDto dto) { + return service.delPersonnelById(dto); } } diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/HumanManageMapper.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/HumanManageMapper.java index a4db4b3..e8665ef 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/HumanManageMapper.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/HumanManageMapper.java @@ -3,6 +3,7 @@ package com.securitycontrol.background.mapper; import com.securitycontrol.entity.background.dto.ParamDto; import com.securitycontrol.entity.background.vo.HumanManageVo; import com.securitycontrol.entity.system.vo.ResourceFileVo; +import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -74,11 +75,44 @@ public interface HumanManageMapper { /** * 人员是否存在 + * * @param vo * @return List> * @description * @author cwchen * @date 2024/3/21 17:53 */ + @MapKey("id") List> userIsExist(HumanManageVo vo); + + /** + * 删除人员 + * + * @param dto + * @description + * @author cwchen + * @date 2024/3/21 20:37 + */ + void delPersonnelById(ParamDto dto); + + /** + * 人员详情 + * + * @param dto + * @return HumanManageVo + * @description + * @author cwchen + * @date 2024/3/21 20:40 + */ + HumanManageVo getPersonnelById(ParamDto dto); + + /** + * 获取人员照片 + * @param userId + * @return List + * @description + * @author cwchen + * @date 2024/3/21 20:42 + */ + List getFiles(String userId); } diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/HumanService.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/HumanService.java index 9d7e4f1..802c0fd 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/HumanService.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/HumanService.java @@ -27,6 +27,7 @@ public interface HumanService { /** * 新增/修改 用户 + * * @param file * @param params * @return AjaxResult @@ -36,13 +37,25 @@ public interface HumanService { */ AjaxResult addOrUpdatePersonnel(MultipartFile file, String params); + /** - * ssss + * 人员详情 * - * @param vo - * @return + * @param dto + * @return AjaxResult + * @description + * @author cwchen + * @date 2024/3/21 20:34 */ - AjaxResult delHuman(HumanManageVo vo); - + AjaxResult getPersonnelById(ParamDto dto); + /** + * 删除人员 + * @param dto + * @return AjaxResult + * @description + * @author cwchen + * @date 2024/3/21 20:35 + */ + AjaxResult delPersonnelById(ParamDto dto); } diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java index b3add03..ea09a48 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java @@ -16,6 +16,7 @@ import com.securitycontrol.entity.background.dto.ParamDto; import com.securitycontrol.entity.background.vo.HumanManageVo; import com.securitycontrol.entity.system.vo.ResourceFileVo; import com.securitycontrol.system.api.RemoteFileService; +import com.securitycontrol.system.api.domain.SysFile; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -152,16 +153,58 @@ public class HumanServiceImpl implements HumanService { } @Override - public AjaxResult delHuman(HumanManageVo vo) { - try{ - HumanManageVo delvo=new HumanManageVo(); - delvo.setUserId(vo.getUserId()); -// delvo.setDelFalge("0"); - mapper.updateHuman(delvo); - }catch (Exception e){ + public AjaxResult getPersonnelById(ParamDto dto) { + HumanManageVo vo = new HumanManageVo(); + vo = mapper.getPersonnelById(dto); + String decryptIdNumber = AesCbcUtils.decrypt(vo.getIdNumber()); + if(decryptIdNumber != null){ + vo.setIdNumber(decryptIdNumber); + } + List resourceFileVos = mapper.getFiles(vo.getUserId()); + if (CollectionUtils.isNotEmpty(resourceFileVos)) { + List list = new ArrayList<>(); + for (ResourceFileVo fileVo : resourceFileVos) { + String base64 = null; + Result result = remoteFileService.getImgBase64(fileVo.getFileId(), SecurityConstants.INNER); + if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) { + String jsonString = JSON.toJSONString(result.getData()); + JSONObject item = JSON.parseObject(jsonString); + base64 = item.getString("url"); + } + HumanManageVo.FileData fileData = new HumanManageVo.FileData(); + fileData.setFileId(fileVo.getFileId()); + fileData.setBase64Url(base64); + list.add(fileData); + } + vo.setFileData(list); + } + return AjaxResult.success(vo); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult delPersonnelById(ParamDto dto) { + try { + if (StringUtils.isEmpty(dto.getId())) { + return AjaxResult.error("参数不完整"); + } + mapper.delPersonnelById(dto); + // 查询人员照片 + List files = mapper.getFiles(dto.getId()); + if (CollectionUtils.isNotEmpty(files)) { + files.forEach(item -> { + mapper.delFile(item.getFileId()); + remoteFileService.delFile(item.getFileId(), SecurityConstants.INNER); + }); + } + + } catch (Exception e) { + log.error("删除人员", e); + //手动回滚异常 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return AjaxResult.error(); } return AjaxResult.success(); } - } diff --git a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/HumanManageMapper.xml b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/HumanManageMapper.xml index f45781c..bfcce56 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/HumanManageMapper.xml +++ b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/HumanManageMapper.xml @@ -71,11 +71,15 @@ DELETE FROM tb_resource_file WHERE file_id = #{fileId} + + + DELETE FROM t_team_people WHERE user_id = #{id} + + + + + \ No newline at end of file