feat(smartfactory): 优化员工导出功能
- 为 CameraDeviceMapper 添加按 sort 字段升序排序 - 在 StaffController 中增加工种字典值和工厂信息的获取,并完善员工信息导出内容 - 更新 StaffRespVO,增加 factoryName 和 workTypeName 字段,修改 sex 字段为 sexStr
This commit is contained in:
parent
77d7620898
commit
b7cb164837
@ -18,7 +18,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -141,9 +140,27 @@ public class StaffController {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<StaffDO> list = staffService.getStaffPage(pageReqVO).getList();
|
||||
|
||||
// 获取工种字典值
|
||||
List<DictDataRespDTO> dictDataRespDTOS = dictDataApi.getDictDataList("user_work_type").getCheckedData();
|
||||
Map<String, String> workTypeMap = dictDataRespDTOS.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
|
||||
|
||||
// 获取工厂信息Map
|
||||
Map<Long, FactoryInfoDO> factoryInfoDOMap = convertMap(factoryInfoService.getFactoryList(), FactoryInfoDO::getId);
|
||||
|
||||
List<StaffRespVO> respVOS = BeanUtils.toBean(list, StaffRespVO.class);
|
||||
respVOS.forEach(item -> {
|
||||
if (item.getWorkTypeId() != null) {
|
||||
item.setWorkTypeName(workTypeMap.getOrDefault(item.getWorkTypeId().toString(), ""));
|
||||
}
|
||||
// 设置性别
|
||||
item.setSexStr(item.getSex() == null ? null : item.getSex() == 1 ? "男" : "女");
|
||||
// 设置工厂名称
|
||||
item.setFactoryName(factoryInfoDOMap.get(item.getFactoryId()) != null ? factoryInfoDOMap.get(item.getFactoryId()).getShortName() : null);
|
||||
});
|
||||
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "员工.xls", "数据", StaffRespVO.class,
|
||||
BeanUtils.toBean(list, StaffRespVO.class));
|
||||
ExcelUtils.write(response, "员工.xls", "数据", StaffRespVO.class, respVOS);
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
|
@ -20,27 +20,34 @@ public class StaffRespVO {
|
||||
@ExcelProperty("姓名")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "工厂名称", example = "6971")
|
||||
@ExcelProperty("工厂名称")
|
||||
private String factoryName;
|
||||
|
||||
@Schema(description = "年龄")
|
||||
@ExcelProperty("年龄")
|
||||
private Integer age;
|
||||
|
||||
@Schema(description = "用户性别(0男 1女 2未知)")
|
||||
@ExcelProperty("性别")
|
||||
@Schema(description = "用户性别(1男 2女)")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "用户性别(1男 2女)")
|
||||
@ExcelProperty("性别")
|
||||
private String sexStr;
|
||||
|
||||
@Schema(description = "工种id", example = "6971")
|
||||
private Integer workTypeId;
|
||||
|
||||
@Schema(description = "工种名称", example = "6971")
|
||||
@ExcelProperty("工种")
|
||||
private String workTypeName;
|
||||
|
||||
@Schema(description = "所属业务类型")
|
||||
private Integer businessType;
|
||||
|
||||
@Schema(description = "工厂id", example = "6971")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "工厂名称", example = "6971")
|
||||
@ExcelProperty("工厂名称")
|
||||
private String factoryName;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
@ExcelProperty("手机号")
|
||||
private String mobile;
|
||||
|
@ -39,6 +39,7 @@ public interface CameraDeviceMapper extends BaseMapperX<CameraDeviceDO> {
|
||||
return selectList(new LambdaQueryWrapperX<CameraDeviceDO>()
|
||||
.eq(factoryId != null, CameraDeviceDO::getFactoryId, factoryId)
|
||||
.eq(CameraDeviceDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.eq(CameraDeviceDO::getIsShow, 1));
|
||||
.eq(CameraDeviceDO::getIsShow, 1)
|
||||
.orderByAsc(CameraDeviceDO::getSort));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user