Commit 775ea278 authored by fangxinjiang's avatar fangxinjiang

基础档案新增字段及必填调整

parent 47e2760a
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@Data
@TableName("t_emp_contact_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "")
public class TEmpContactInfo extends BaseEntity {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* empId
*/
@ExcelAttribute(name = "empId", maxLength = 32)
@Length(max = 32, message = "empId不能超过32个字符")
@ExcelProperty("empId")
@Schema(description = "empId")
private String empId;
/**
* 姓名
*/
@ExcelAttribute(name = "姓名", isNotEmpty = true, errorInfo = "姓名不能为空", maxLength = 20)
@NotBlank(message = "姓名不能为空")
@Length(max = 20, message = "姓名不能超过20个字符")
@ExcelProperty("姓名")
@Schema(description = "姓名")
private String empName;
/**
* 与本人关系
*/
@ExcelAttribute(name = "与本人关系", isNotEmpty = true, errorInfo = "与本人关系不能为空", maxLength = 50)
@NotBlank(message = "与本人关系不能为空")
@Length(max = 50, message = "与本人关系不能超过50个字符")
@ExcelProperty("与本人关系")
@Schema(description = "与本人关系")
private String relationType;
/**
* 联系地址-街道、详情
*/
@ExcelAttribute(name = "联系地址-街道、详情", isNotEmpty = true, errorInfo = "联系地址-街道、详情不能为空", maxLength = 100)
@NotBlank(message = "联系地址-街道、详情不能为空")
@Length(max = 100, message = "联系地址-街道、详情不能超过100个字符")
@ExcelProperty("联系地址-街道、详情")
@Schema(description = "联系地址-街道、详情")
private String address;
/**
* 联系电话
*/
@ExcelAttribute(name = "联系电话", isNotEmpty = true, errorInfo = "联系电话不能为空", maxLength = 20)
@NotBlank(message = "联系电话不能为空")
@Length(max = 20, message = "联系电话不能超过20个字符")
@ExcelProperty("联系电话")
@Schema(description = "联系电话")
private String tel;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@Data
public class TEmpContactInfoSearchVo extends TEmpContactInfo {
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,多个逗号分割")
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
/**
* @Author fxj
* 查询数据起
**/
@Schema(description = "查询limit 开始")
private int limitStart;
/**
* @Author fxj
* 查询数据止
**/
@Schema(description = "查询limit 数据条数")
private int limitEnd;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@Data
public class TEmpContactInfoVo extends RowIndex implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@NotBlank(message = "id 不能为空")
@Length(max = 32, message = "id 不能超过32 个字符")
@ExcelAttribute(name = "id", isNotEmpty = true, errorInfo = "id 不能为空", maxLength = 32)
@Schema(description = "id")
@ExcelProperty("id")
private String id;
/**
* empId
*/
@Length(max = 32, message = "empId 不能超过32 个字符")
@ExcelAttribute(name = "empId", maxLength = 32)
@Schema(description = "empId")
@ExcelProperty("empId")
private String empId;
/**
* 姓名
*/
@NotBlank(message = "姓名 不能为空")
@Length(max = 20, message = "姓名 不能超过20 个字符")
@ExcelAttribute(name = "姓名", isNotEmpty = true, errorInfo = "姓名 不能为空", maxLength = 20)
@Schema(description = "姓名")
@ExcelProperty("姓名")
private String empName;
/**
* 与本人关系
*/
@NotBlank(message = "与本人关系 不能为空")
@Length(max = 50, message = "与本人关系 不能超过50 个字符")
@ExcelAttribute(name = "与本人关系", isNotEmpty = true, errorInfo = "与本人关系 不能为空", maxLength = 50)
@Schema(description = "与本人关系")
@ExcelProperty("与本人关系")
private String relationType;
/**
* 联系地址-街道、详情
*/
@NotBlank(message = "联系地址-街道、详情 不能为空")
@Length(max = 100, message = "联系地址-街道、详情 不能超过100 个字符")
@ExcelAttribute(name = "联系地址-街道、详情", isNotEmpty = true, errorInfo = "联系地址-街道、详情 不能为空", maxLength = 100)
@Schema(description = "联系地址-街道、详情")
@ExcelProperty("联系地址-街道、详情")
private String address;
/**
* 联系电话
*/
@NotBlank(message = "联系电话 不能为空")
@Length(max = 20, message = "联系电话 不能超过20 个字符")
@ExcelAttribute(name = "联系电话", isNotEmpty = true, errorInfo = "联系电话 不能为空", maxLength = 20)
@Schema(description = "联系电话")
@ExcelProperty("联系电话")
private String tel;
/**
* 创建者
*/
@Length(max = 64, message = "创建者 不能超过64 个字符")
@ExcelAttribute(name = "创建者", maxLength = 64)
@Schema(description = "创建者")
@ExcelProperty("创建者")
private String createBy;
/**
* 更新人
*/
@Length(max = 64, message = "更新人 不能超过64 个字符")
@ExcelAttribute(name = "更新人", maxLength = 64)
@Schema(description = "更新人")
@ExcelProperty("更新人")
private String updateBy;
/**
* 创建人姓名
*/
@Length(max = 32, message = "创建人姓名 不能超过32 个字符")
@ExcelAttribute(name = "创建人姓名", maxLength = 32)
@Schema(description = "创建人姓名")
@ExcelProperty("创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isDate = true)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private Date createTime;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private Date updateTime;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpContactInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpContactInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tempcontactinfo")
@Tag(name = "紧急联系人")
public class TEmpContactInfoController {
private final TEmpContactInfoService tEmpContactInfoService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tEmpContactInfo
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TEmpContactInfo>> getTEmpContactInfoPage(Page<TEmpContactInfo> page, TEmpContactInfoSearchVo tEmpContactInfo) {
return new R<>(tEmpContactInfoService.getTEmpContactInfoPage(page, tEmpContactInfo));
}
/**
* 不分页查询
*
* @param tEmpContactInfo
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
//@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo_get')" )
public R<List<TEmpContactInfo>> getTEmpContactInfoNoPage(@RequestBody TEmpContactInfoSearchVo tEmpContactInfo) {
return R.ok(tEmpContactInfoService.noPageDiy(tEmpContactInfo));
}
/**
* 通过id查询
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('archives_tempcontactinfo_get')")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo_get')")
public R<TEmpContactInfo> getById(@PathVariable("id") String id) {
return R.ok(tEmpContactInfoService.getById(id));
}
/**
* 新增
*
* @param tEmpContactInfo
* @return R
*/
@Operation(summary = "新增", description = "新增:hasPermission('archives_tempcontactinfo_add')")
@SysLog("新增")
@PostMapping
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo_add')")
public R<Boolean> save(@RequestBody TEmpContactInfo tEmpContactInfo) {
return R.ok(tEmpContactInfoService.save(tEmpContactInfo));
}
/**
* 修改
*
* @param tEmpContactInfo
* @return R
*/
@Operation(summary = "修改", description = "修改:hasPermission('archives_tempcontactinfo_edit')")
@SysLog("修改")
@PutMapping
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo_edit')")
public R<Boolean> updateById(@RequestBody TEmpContactInfo tEmpContactInfo) {
return R.ok(tEmpContactInfoService.updateById(tEmpContactInfo));
}
/**
* 通过id删除
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除", description = "通过id删除:hasPermission('archives_tempcontactinfo_del')")
@SysLog("通过id删除")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo_del')")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tEmpContactInfoService.removeById(id));
}
/**
* 批量导入
*
* @author fxj
* @date 2024-06-17 14:29:11
**/
@SneakyThrows
@Operation(description = "批量新增 hasPermission('archives_tempcontactinfo-batch-import')")
@SysLog("批量新增")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tEmpContactInfoService.importDiy(file.getInputStream());
}
/**
* 批量导出
*
* @author fxj
* @date 2024-06-17 14:29:11
**/
@Operation(description = "导出 hasPermission('archives_tempcontactinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('archives_tempcontactinfo-export')")
public void export(HttpServletResponse response, @RequestBody TEmpContactInfoSearchVo searchVo) {
tEmpContactInfoService.listExport(response, searchVo);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@Mapper
public interface TEmpContactInfoMapper extends BaseMapper<TEmpContactInfo> {
/**
* 简单分页查询
*
* @param tEmpContactInfo
* @return
*/
IPage<TEmpContactInfo> getTEmpContactInfoPage(Page<TEmpContactInfo> page, @Param("tEmpContactInfo") TEmpContactInfo tEmpContactInfo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpContactInfoSearchVo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
*
*
* @author fxj
* @date 2024-06-17 14:29:11
*/
public interface TEmpContactInfoService extends IService<TEmpContactInfo> {
/**
* 简单分页查询
* @param tEmpContactInfo
* @return
*/
IPage<TEmpContactInfo> getTEmpContactInfoPage(Page<TEmpContactInfo> page, TEmpContactInfoSearchVo tEmpContactInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TEmpContactInfoSearchVo searchVo);
List<TEmpContactInfo> noPageDiy(TEmpContactInfoSearchVo searchVo);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpContactInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpContactInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpContactInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpContactInfoVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* @author fxj
* @date 2024-06-17 14:29:11
*/
@Log4j2
@Service
public class TEmpContactInfoServiceImpl extends ServiceImpl<TEmpContactInfoMapper, TEmpContactInfo> implements TEmpContactInfoService {
/**
* 简单分页查询
*
* @param tEmpContactInfo
* @return
*/
@Override
public IPage<TEmpContactInfo> getTEmpContactInfoPage(Page<TEmpContactInfo> page, TEmpContactInfoSearchVo tEmpContactInfo) {
return baseMapper.getTEmpContactInfoPage(page, tEmpContactInfo);
}
/**
* 批量导出
*
* @param searchVo
* @return
*/
@Override
public void listExport(HttpServletResponse response, TEmpContactInfoSearchVo searchVo) {
String fileName = "批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TEmpContactInfo> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, TEmpContactInfo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; ) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = noPageDiy(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<TEmpContactInfo> util = new ExcelUtil<>(TEmpContactInfo.class);
for (TEmpContactInfo vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("" + index).build();
excelWriter.write(list, writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)) {
list.clear();
}
}
} else {
WriteSheet writeSheet = EasyExcel.writerSheet("" + index).build();
excelWriter.write(list, writeSheet);
}
if (Common.isNotNull(list)) {
list.clear();
}
out.flush();
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<TEmpContactInfo> noPageDiy(TEmpContactInfoSearchVo searchVo) {
LambdaQueryWrapper<TEmpContactInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TEmpContactInfo::getId, idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0) {
wrapper.last(" limit " + searchVo.getLimitStart() + "," + searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(TEmpContactInfoSearchVo searchVo) {
LambdaQueryWrapper<TEmpContactInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)) {
wrapper.in(TEmpContactInfo::getId, idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TEmpContactInfoSearchVo entity) {
LambdaQueryWrapper<TEmpContactInfo> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TEmpContactInfo::getCreateTime, entity.getCreateTimes()[0])
.le(TEmpContactInfo::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())) {
wrapper.eq(TEmpContactInfo::getCreateName, entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TEmpContactInfoVo> util1 = new ExcelUtil<>(TEmpContactInfoVo.class);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TEmpContactInfoVo.class, new ReadListener<TEmpContactInfoVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TEmpContactInfoVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TEmpContactInfoVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTEmpContactInfo(cachedDataList, errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTEmpContactInfo(List<TEmpContactInfoVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TEmpContactInfoVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TEmpContactInfoVo excel) {
TEmpContactInfo insert = new TEmpContactInfo();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpContactInfoMapper">
<resultMap id="tEmpContactInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo">
<id property="id" column="ID"/>
<result property="empId" column="EMP_ID"/>
<result property="empName" column="EMP_NAME"/>
<result property="relationType" column="RELATION_TYPE"/>
<result property="address" column="ADDRESS"/>
<result property="tel" column="TEL"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.EMP_ID,
a.EMP_NAME,
a.RELATION_TYPE,
a.ADDRESS,
a.TEL,
a.CREATE_BY,
a.UPDATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_TIME
</sql>
<sql id="tEmpContactInfo_where">
<if test="tEmpContactInfo != null">
<if test="tEmpContactInfo.id != null and tEmpContactInfo.id.trim() != ''">
AND a.ID = #{tEmpContactInfo.id}
</if>
<if test="tEmpContactInfo.empId != null and tEmpContactInfo.empId.trim() != ''">
AND a.EMP_ID = #{tEmpContactInfo.empId}
</if>
<if test="tEmpContactInfo.empName != null and tEmpContactInfo.empName.trim() != ''">
AND a.EMP_NAME = #{tEmpContactInfo.empName}
</if>
<if test="tEmpContactInfo.relationType != null and tEmpContactInfo.relationType.trim() != ''">
AND a.RELATION_TYPE = #{tEmpContactInfo.relationType}
</if>
<if test="tEmpContactInfo.address != null and tEmpContactInfo.address.trim() != ''">
AND a.ADDRESS = #{tEmpContactInfo.address}
</if>
<if test="tEmpContactInfo.tel != null and tEmpContactInfo.tel.trim() != ''">
AND a.TEL = #{tEmpContactInfo.tel}
</if>
<if test="tEmpContactInfo.createBy != null and tEmpContactInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{tEmpContactInfo.createBy}
</if>
<if test="tEmpContactInfo.updateBy != null and tEmpContactInfo.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tEmpContactInfo.updateBy}
</if>
<if test="tEmpContactInfo.createName != null and tEmpContactInfo.createName.trim() != ''">
AND a.CREATE_NAME = #{tEmpContactInfo.createName}
</if>
<if test="tEmpContactInfo.createTime != null">
AND a.CREATE_TIME = #{tEmpContactInfo.createTime}
</if>
<if test="tEmpContactInfo.updateTime != null">
AND a.UPDATE_TIME = #{tEmpContactInfo.updateTime}
</if>
</if>
</sql>
<!--tEmpContactInfo简单分页查询-->
<select id="getTEmpContactInfoPage" resultMap="tEmpContactInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_emp_contact_info a
<where>
1=1
<include refid="tEmpContactInfo_where"/>
</where>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment