Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5baec6f1b6
|
|
@ -132,6 +132,25 @@
|
|||
<version>6.0.18.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.30</version>
|
||||
</dependency>
|
||||
<!-- easypoi相关的jar包 -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,197 @@
|
|||
package com.bonus.common.core.utils;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
|
||||
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
||||
/**
|
||||
* @author 10488
|
||||
* @Auther: ccw
|
||||
* @Date: 2022/05/12/16:22
|
||||
* @description: easypoi 导出表格样式
|
||||
*/
|
||||
public class ExcelStyleUtil implements IExcelExportStyler {
|
||||
private static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT");
|
||||
private static final short FONT_SIZE_TEN = 10;
|
||||
private static final short FONT_SIZE_ELEVEN = 11;
|
||||
private static final short FONT_SIZE_TWELVE = 12;
|
||||
|
||||
/**
|
||||
* 大标题样式
|
||||
*/
|
||||
private CellStyle headerStyle;
|
||||
|
||||
/**
|
||||
* 每列标题样式
|
||||
*/
|
||||
private CellStyle titleStyle;
|
||||
|
||||
/**
|
||||
* 数据行样式
|
||||
*/
|
||||
private CellStyle styles;
|
||||
|
||||
public ExcelStyleUtil(Workbook workbook) {
|
||||
this.init(workbook);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化样式
|
||||
*
|
||||
* @param workbook
|
||||
*/
|
||||
private void init(Workbook workbook) {
|
||||
this.headerStyle = initHeaderStyle(workbook);
|
||||
this.titleStyle = initTitleStyle(workbook);
|
||||
this.styles = initStyles(workbook);
|
||||
}
|
||||
|
||||
/**
|
||||
* 大标题样式
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public CellStyle getHeaderStyle(short color) {
|
||||
return headerStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每列标题样式
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public CellStyle getTitleStyle(short color) {
|
||||
return titleStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据行样式
|
||||
*
|
||||
* @param parity 可以用来表示奇偶行
|
||||
* @param entity 数据内容
|
||||
* @return 样式
|
||||
*/
|
||||
|
||||
@Override
|
||||
public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取样式方法
|
||||
*
|
||||
* @param dataRow 数据行
|
||||
* @param obj 对象
|
||||
* @param data 数据
|
||||
*/
|
||||
|
||||
@Override
|
||||
|
||||
public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
|
||||
return getStyles(true, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板使用的样式设置
|
||||
*/
|
||||
|
||||
@Override
|
||||
public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化--大标题样式
|
||||
*
|
||||
* @param workbook
|
||||
* @return
|
||||
*/
|
||||
|
||||
private CellStyle initHeaderStyle(Workbook workbook) {
|
||||
CellStyle style = getBaseCellStyle(workbook);
|
||||
style.setFont(getFont(workbook, FONT_SIZE_TWELVE, true));
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化--每列标题样式
|
||||
*
|
||||
* @param workbook
|
||||
* @return
|
||||
*/
|
||||
|
||||
private CellStyle initTitleStyle(Workbook workbook) {
|
||||
CellStyle style = getBaseCellStyle(workbook);
|
||||
style.setFont(getFont(workbook, FONT_SIZE_ELEVEN, false));
|
||||
//背景色
|
||||
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化--数据行样式
|
||||
*
|
||||
* @param workbook
|
||||
* @return
|
||||
*/
|
||||
private CellStyle initStyles(Workbook workbook) {
|
||||
CellStyle style = getBaseCellStyle(workbook);
|
||||
style.setFont(getFont(workbook, FONT_SIZE_TEN, false));
|
||||
style.setDataFormat(STRING_FORMAT);
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础样式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private CellStyle getBaseCellStyle(Workbook workbook) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//下边框
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//左边框
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//上边框
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//右边框
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//水平居中
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
//上下居中
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
//设置自动换行
|
||||
style.setWrapText(true);
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字体样式
|
||||
*
|
||||
* @param size 字体大小
|
||||
* @param isBold 是否加粗
|
||||
* @return
|
||||
*/
|
||||
|
||||
private Font getFont(Workbook workbook, short size, boolean isBold) {
|
||||
Font font = workbook.createFont();
|
||||
//字体样式
|
||||
font.setFontName("宋体");
|
||||
//是否加粗
|
||||
font.setBold(isBold);
|
||||
//字体大小
|
||||
font.setFontHeightInPoints(size);
|
||||
return font;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,4 +54,14 @@ public class BraceletParamsDto {
|
|||
* 资源类型
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 资源文件ID
|
||||
*/
|
||||
private Long fileId;
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
private String filePath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.bonus.common.entity.bracelet.exportVo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:PersonExportVo
|
||||
* @author:cwchen
|
||||
* @date:2024-07-16-21:04
|
||||
* @version:1.0
|
||||
* @description:人员导出-vo
|
||||
*/
|
||||
@Data
|
||||
public class PersonExportVo {
|
||||
|
||||
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
|
||||
private String id;
|
||||
|
||||
@Excel(name = "姓名", width = 20.0,height = 15.0,orderNum = "1")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "性别", width = 20.0,height = 15.0,orderNum = "2")
|
||||
private String sex;
|
||||
|
||||
@Excel(name = "身份证号", width = 20.0,height = 15.0,orderNum = "3")
|
||||
private String idCard;
|
||||
|
||||
@Excel(name = "电话", width = 20.0,height = 15.0,orderNum = "4")
|
||||
private String phone;
|
||||
|
||||
@Excel(name = "安全帽编号", width = 20.0,height = 15.0,orderNum = "5")
|
||||
private String aqmCode;
|
||||
|
||||
@Excel(name = "马甲编号", width = 20.0,height = 15.0,orderNum = "6")
|
||||
private String mjCode;
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
package com.bonus.common.entity.bracelet.vo;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
|
@ -8,6 +13,7 @@ import org.hibernate.validator.constraints.Range;
|
|||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -18,7 +24,7 @@ import java.util.Date;
|
|||
* @description:人员-vo
|
||||
*/
|
||||
@Data
|
||||
public class PersonVo {
|
||||
public class PersonVo implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
|
|
@ -64,20 +70,24 @@ public class PersonVo {
|
|||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Date createTime = new Date();
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Date updateTime = new Date();
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createUser;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Long createUser = SecurityUtils.getUserId();
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updateUser;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Long updateUser = SecurityUtils.getUserId();
|
||||
/**
|
||||
* 所属班组ID
|
||||
*/
|
||||
|
|
@ -86,6 +96,7 @@ public class PersonVo {
|
|||
/**
|
||||
* 删除的文件ID
|
||||
*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String delFiles;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.common.entity.file;
|
||||
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -36,13 +37,13 @@ public class ResourceFileVo {
|
|||
private Date createTime = new Date();
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private Long createUser;
|
||||
private Long createUser = SecurityUtils.getUserId();
|
||||
|
||||
@ApiModelProperty(value = "修改日期")
|
||||
private Date updateTime = new Date();
|
||||
|
||||
@ApiModelProperty(value = "修改人")
|
||||
private Long updateUser;
|
||||
private Long updateUser = SecurityUtils.getUserId();
|
||||
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private Integer delFlag = 0;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import com.bonus.common.security.interceptor.HeaderInterceptor;
|
|||
public class WebMvcConfig implements WebMvcConfigurer
|
||||
{
|
||||
/** 不需要拦截地址 "/logout",*/
|
||||
public static final String[] excludeUrls = { "/login", "/refresh" };
|
||||
public static final String[] excludeUrls = { "/login", "/refresh","/mongoFile/**" };
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package com.bonus.bracelet.controller;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-03-11-14:54
|
||||
* @version:1.0
|
||||
* @description:文件模板下载
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/download/")
|
||||
@Slf4j
|
||||
public class DownLoadFileController {
|
||||
|
||||
/**
|
||||
* 人员模板-下载模板
|
||||
* @param request
|
||||
* @param response
|
||||
* @return void
|
||||
* @author cwchen
|
||||
* @date 2024/7/16 20:40
|
||||
*/
|
||||
@GetMapping("personFile")
|
||||
public void personFile(HttpServletRequest request, HttpServletResponse response) {
|
||||
InputStream inputStream = null;
|
||||
ServletOutputStream servletOutputStream = null;
|
||||
try {
|
||||
String path = "download/" + "person_model.xlsx";
|
||||
inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.addHeader("charset", "utf-8");
|
||||
response.addHeader("Pragma", "no-cache");
|
||||
String encodeName = URLEncoder.encode("person_model.xlsx", StandardCharsets.UTF_8.toString());
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
|
||||
servletOutputStream = response.getOutputStream();
|
||||
IOUtils.copy(inputStream, servletOutputStream);
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
log.error("人员模板-下载失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.bonus.bracelet.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import com.bonus.bracelet.service.IPersonMgeService;
|
||||
import com.bonus.common.core.constant.BusinessConstants;
|
||||
import com.bonus.common.core.utils.ExcelStyleUtil;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.exportVo.PersonExportVo;
|
||||
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-03-11-14:55
|
||||
* @version:1.0
|
||||
* @description:导出文件-web层
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/export/")
|
||||
@Slf4j
|
||||
public class ExportFileController {
|
||||
|
||||
|
||||
@Resource(name = "IPersonMgeService")
|
||||
private IPersonMgeService iPersonMgeService;
|
||||
|
||||
/**
|
||||
* 导出人员
|
||||
* @param request
|
||||
* @param response
|
||||
* @param dto
|
||||
* @return void
|
||||
* @author cwchen
|
||||
* @date 2024/7/16 21:13
|
||||
*/
|
||||
@GetMapping("exportPerson")
|
||||
public void exportPerson(HttpServletRequest request, HttpServletResponse response, BraceletParamsDto dto) {
|
||||
try {
|
||||
List<PersonExportVo> personExportVoList = new ArrayList<>();
|
||||
List<PersonVo> personLists = iPersonMgeService.getPersonLists(dto);
|
||||
for (int i = 0; i < personLists.size(); i++) {
|
||||
PersonExportVo exportVo = new PersonExportVo();
|
||||
PersonVo vo = personLists.get(i);
|
||||
BeanUtils.copyProperties(vo, exportVo);
|
||||
exportVo.setId((i + 1) + "");
|
||||
exportVo.setSex(vo.getSex() == BusinessConstants.TYPE ? "男" : vo.getSex() == BusinessConstants.TYPE2 ? "其他" : "女");
|
||||
personExportVoList.add(exportVo);
|
||||
}
|
||||
ExportParams exportParams = new ExportParams("人员", "人员", ExcelType.XSSF);
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PersonExportVo.class, personExportVoList);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("人员" + ".xlsx", "UTF-8"));
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error("导出人员", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ public class PersonMgeController extends BaseController {
|
|||
@Resource(name = "IPersonMgeService")
|
||||
private IPersonMgeService service;
|
||||
|
||||
@RequiresPermissions("basic:person:list")
|
||||
// @RequiresPermissions("basic:person:list")
|
||||
@GetMapping("list")
|
||||
@SysLog(title = "人员管理", businessType = OperaType.QUERY,logType = 0,module = "基础管理->人员管理",details ="查询人员列表")
|
||||
public TableDataInfo list(BraceletParamsDto dto) {
|
||||
|
|
@ -41,14 +41,14 @@ public class PersonMgeController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@RequiresPermissions("basic:person:add")
|
||||
// @RequiresPermissions("basic:person:add")
|
||||
@PostMapping("addPerson")
|
||||
@SysLog(title = "人员管理", businessType = OperaType.INSERT,logType = 0,module = "基础管理->人员管理",details ="新增人员" )
|
||||
public AjaxResult add(HttpServletRequest request, @RequestParam(value = "file", required = false) MultipartFile file, String params) {
|
||||
return service.addPerson(file, params);
|
||||
}
|
||||
|
||||
@RequiresPermissions("basic:person:edit")
|
||||
// @RequiresPermissions("basic:person:edit")
|
||||
@PostMapping("editPerson")
|
||||
@SysLog(title = "人员管理", businessType = OperaType.INSERT,logType = 0,module = "基础管理->人员管理",details ="修改人员" )
|
||||
public AjaxResult editPerson(HttpServletRequest request, @RequestParam(value = "file", required = false) MultipartFile file, String params) {
|
||||
|
|
@ -60,7 +60,7 @@ public class PersonMgeController extends BaseController {
|
|||
return service.getPersonInfo(dto);
|
||||
}
|
||||
|
||||
@RequiresPermissions("basic:person:del")
|
||||
// @RequiresPermissions("basic:person:del")
|
||||
@PostMapping("delPerson")
|
||||
@SysLog(title = "人员管理", businessType = OperaType.INSERT,logType = 0,module = "基础管理->人员管理",details ="删除人员" )
|
||||
public AjaxResult delPerson(@RequestBody BraceletParamsDto dto) {
|
||||
|
|
|
|||
|
|
@ -30,5 +30,5 @@ public interface ResourceFileMapper {
|
|||
* @author cwchen
|
||||
* @date 2024/7/16 15:07
|
||||
*/
|
||||
void delResourceFile(PersonVo vo);
|
||||
void delResourceFile(Long fileId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.PersonVo;
|
||||
import com.bonus.common.entity.file.ResourceFileVo;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.common.security.utils.ValidatorsUtils;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
|
|
@ -85,10 +86,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
// 验证身份证是否重复、手机号
|
||||
List<Map<String, String>> list = mapper.personIsExist(vo);
|
||||
if (idCardIsExist(list, vo, 1)) {
|
||||
return AjaxResult.error("身份证号码" + vo.getIdCard() + "已存在");
|
||||
return AjaxResult.error("身份证号码已存在");
|
||||
}
|
||||
if (idCardIsExist(list, vo, 2)) {
|
||||
return AjaxResult.error("电话" + vo.getPhone() + "已存在");
|
||||
return AjaxResult.error("电话已存在");
|
||||
}
|
||||
// 校验文件、上传文件
|
||||
if (file == null) {
|
||||
|
|
@ -102,6 +103,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
// 对身份证号、手机号 进行 sm4加密 保存人员数据、保存文件资源
|
||||
vo.setIdCard(Sm4Utils.encode(vo.getIdCard()));
|
||||
vo.setPhone(Sm4Utils.encode(vo.getPhone()));
|
||||
// SecurityUtils.getLoginUser()
|
||||
mapper.addPerson(vo);
|
||||
delFileId = uploadFile(file, vo);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -130,10 +132,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
// 验证身份证是否重复、手机号
|
||||
List<Map<String, String>> list = mapper.personIsExist(vo);
|
||||
if (idCardIsExist(list, vo, 1)) {
|
||||
return AjaxResult.error("身份证号码" + vo.getIdCard() + "已存在");
|
||||
return AjaxResult.error("身份证号码已存在");
|
||||
}
|
||||
if (idCardIsExist(list, vo, 2)) {
|
||||
return AjaxResult.error("电话" + vo.getPhone() + "已存在");
|
||||
return AjaxResult.error("电话已存在");
|
||||
}
|
||||
// 校验文件、上传文件
|
||||
if (file == null && StringUtils.isNotBlank(vo.getDelFiles())) {
|
||||
|
|
@ -152,7 +154,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
if (StringUtils.isNotEmpty(vo.getDelFiles())) {
|
||||
String[] delFiles = vo.getDelFiles().split(",");
|
||||
for (String fileId : delFiles) {
|
||||
resourceFileMapper.delResourceFile(vo);
|
||||
resourceFileMapper.delResourceFile(vo.getFileId());
|
||||
remoteFileService.delFile(fileId, SecurityConstants.INNER);
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +190,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
if (dto.getTeamId() != null) {
|
||||
return AjaxResult.error("该人员已分配班组,请先从班组中移除该人员");
|
||||
}
|
||||
// 删除人员、资源文件、人脸照片
|
||||
mapper.delPerson(dto);
|
||||
resourceFileMapper.delResourceFile(dto.getFileId());
|
||||
remoteFileService.delFile(dto.getFilePath(), SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("删除人员", e);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -71,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<!--查询人员列表-->
|
||||
<select id="getPersonLists" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
|
||||
SELECT tp.id,
|
||||
tp.name,
|
||||
tp.sex,
|
||||
tp.id_card AS idCard,
|
||||
tp.phone,
|
||||
tp.aqm_code AS aqmCode,
|
||||
|
|
@ -95,6 +97,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="roleCode == 'team'">
|
||||
|
||||
</if>
|
||||
ORDER BY create_time
|
||||
ORDER BY tp.create_time
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="fileName != null and fileName!=''">file_name,</if>
|
||||
<if test="fileSuffix != null and fileSuffix!=''">file_suffix,</if>
|
||||
<if test="filePath != null and filePath!=''">file_path,</if>
|
||||
<if test="fileType != null and fileType!=''">file_type,</if>
|
||||
<if test="fileType != null">file_type,</if>
|
||||
<if test="sourceId != null and sourceId!=''">source_id,</if>
|
||||
<if test="sourceType != null and sourceType!=''">source_type,</if>
|
||||
create_time,
|
||||
|
|
@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="fileName != null and fileName!=''">#{fileName},</if>
|
||||
<if test="fileSuffix != null and fileSuffix!=''">#{fileSuffix},</if>
|
||||
<if test="filePath != null and filePath!=''">#{filePath},</if>
|
||||
<if test="fileType != null and fileType!=''">#{filePath},</if>
|
||||
<if test="fileType != null">#{fileType},</if>
|
||||
<if test="sourceId != null and sourceId!=''">#{sourceId},</if>
|
||||
<if test="sourceType != null and sourceType!=''">#{sourceType},</if>
|
||||
#{createTime},
|
||||
|
|
@ -36,6 +36,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</insert>
|
||||
<!--删除资源文件-->
|
||||
<update id="delResourceFile">
|
||||
UPDATE sys_file_source SET del_flag = 1 WHERE id = #{id}
|
||||
UPDATE sys_file_source SET del_flag = 1 WHERE id = #{fileId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -33,6 +33,7 @@ public class MongoFileUploadController {
|
|||
|
||||
@ApiOperation(value = "获取图片base64地址")
|
||||
@PostMapping("getImgBase64")
|
||||
@InnerAuth
|
||||
public R<SysFile> getImgBase64(@RequestBody String fileId){
|
||||
try {
|
||||
SysFile sysFile = new SysFile();
|
||||
|
|
@ -49,6 +50,7 @@ public class MongoFileUploadController {
|
|||
|
||||
@ApiOperation(value = "获取图片base64地址")
|
||||
@PostMapping("getFileBast64")
|
||||
@InnerAuth
|
||||
public R<SysFile> getFileBast64(@RequestBody String fileId){
|
||||
try {
|
||||
SysFile sysFile = new SysFile();
|
||||
|
|
@ -65,6 +67,7 @@ public class MongoFileUploadController {
|
|||
|
||||
@ApiOperation(value = "获取图片base64地址")
|
||||
@PostMapping("getFileByte")
|
||||
@InnerAuth
|
||||
public R<byte[]> getFileByte(@RequestBody String fileId){
|
||||
try {
|
||||
SysFile sysFile = new SysFile();
|
||||
|
|
@ -106,6 +109,7 @@ public class MongoFileUploadController {
|
|||
|
||||
@ApiOperation(value = "文件删除")
|
||||
@PostMapping("delFile")
|
||||
@InnerAuth
|
||||
public R delFile(@RequestBody String fileId){
|
||||
try {
|
||||
mongoService.removeFile(fileId);
|
||||
|
|
@ -118,6 +122,7 @@ public class MongoFileUploadController {
|
|||
|
||||
@ApiOperation(value = "base64上传")
|
||||
@PostMapping("uploadFileByBase64")
|
||||
@InnerAuth
|
||||
public R uploadFileByBase64(@RequestParam(value = "base64", required = false) String base64){
|
||||
try {
|
||||
MultipartFile multipartFile = BASE64DecodedMultipartFile.base64ToMultipart(base64);
|
||||
|
|
|
|||
Loading…
Reference in New Issue