Commit c5f1ea14 authored by fangxinjiang's avatar fangxinjiang

HRO 收入证明 客户资料

parent 1239fd87
/*
* 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;
import java.time.LocalDateTime;
/**
* 收入证明 中的 单位信息维护表
*
* @author fxj
* @date 2023-08-23 17:31:05
*/
@Data
@TableName("t_company_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "收入证明 中的 单位信息维护表")
public class TCompanyInfo extends BaseEntity {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* 公司名称
*/
@ExcelAttribute(name = "公司名称", isNotEmpty = true, errorInfo = "公司名称不能为空", maxLength = 50)
@NotBlank(message = "公司名称不能为空")
@Length(max = 50, message = "公司名称不能超过50个字符")
@ExcelProperty("公司名称")
@Schema(description = "公司名称")
private String companyName;
/**
* 公司地址
*/
@ExcelAttribute(name = "公司地址", isNotEmpty = true, errorInfo = "公司地址不能为空", maxLength = 200)
@NotBlank(message = "公司地址不能为空")
@Length(max = 200, message = "公司地址不能超过200个字符")
@ExcelProperty("公司地址")
@Schema(description = "公司地址")
private String companyAddress;
/**
* 公司电话
*/
@ExcelAttribute(name = "公司电话", isNotEmpty = true, errorInfo = "公司电话不能为空", maxLength = 20)
@NotBlank(message = "公司电话不能为空")
@Length(max = 20, message = "公司电话不能超过20个字符")
@ExcelProperty("公司电话")
@Schema(description = "公司电话")
private String companyTel;
/**
* 创建人id
*/
@ExcelAttribute(name = "创建人id", isNotEmpty = true, errorInfo = "创建人id不能为空", maxLength = 32)
@NotBlank(message = "创建人id不能为空")
@Length(max = 32, message = "创建人id不能超过32个字符")
@ExcelProperty("创建人id")
@Schema(description = "创建人id")
private String createBy;
/**
* 创建人姓名
*/
@ExcelAttribute(name = "创建人姓名", maxLength = 32)
@Length(max = 32, message = "创建人姓名不能超过32个字符")
@ExcelProperty("创建人姓名")
@Schema(description = "创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isNotEmpty = true, errorInfo = "创建时间不能为空", isDate = true)
@NotBlank(message = "创建时间不能为空")
@ExcelProperty("创建时间")
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 更新人id
*/
@ExcelAttribute(name = "更新人id", maxLength = 32)
@Length(max = 32, message = "更新人id不能超过32个字符")
@ExcelProperty("更新人id")
@Schema(description = "更新人id")
private String updateBy;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@ExcelProperty("更新时间")
@Schema(description = "更新时间")
private LocalDateTime updateTime;
/**
* 0 未删除 1 已删除
*/
@ExcelAttribute(name = "0 未删除 1 已删除", maxLength = 1)
@Length(max = 1, message = "0 未删除 1 已删除不能超过1个字符")
@ExcelProperty("0 未删除 1 已删除")
@Schema(description = "0 未删除 1 已删除")
private String deleteFlag;
}
/*
* 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.TCompanyInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 收入证明 中的 单位信息维护表
*
* @author fxj
* @date 2023-08-23 17:31:05
*/
@Data
public class TCompanyInfoSearchVo extends TCompanyInfo {
/**
* 多选导出或删除等操作
*/
@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.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
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 com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 收入证明 中的 单位信息维护表
*
* @author fxj
* @date 2023-08-23 17:31:05
*/
@Data
public class TCompanyInfoVo 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;
/**
* 公司名称
*/
@NotBlank(message = "公司名称 不能为空")
@Length(max = 50, message = "公司名称 不能超过50 个字符")
@ExcelAttribute(name = "公司名称", isNotEmpty = true, errorInfo = "公司名称 不能为空", maxLength = 50)
@Schema(description = "公司名称")
@ExcelProperty("公司名称")
private String 公司名称;
/**
* 公司地址
*/
@NotBlank(message = "公司地址 不能为空")
@Length(max = 200, message = "公司地址 不能超过200 个字符")
@ExcelAttribute(name = "公司地址", isNotEmpty = true, errorInfo = "公司地址 不能为空", maxLength = 200)
@Schema(description = "公司地址")
@ExcelProperty("公司地址")
private String companyAddress;
/**
* 公司电话
*/
@NotBlank(message = "公司电话 不能为空")
@Length(max = 20, message = "公司电话 不能超过20 个字符")
@ExcelAttribute(name = "公司电话", isNotEmpty = true, errorInfo = "公司电话 不能为空", maxLength = 20)
@Schema(description = "公司电话")
@ExcelProperty("公司电话")
private String companyTel;
/**
* 创建人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 createBy;
/**
* 创建人姓名
*/
@Length(max = 32, message = "创建人姓名 不能超过32 个字符")
@ExcelAttribute(name = "创建人姓名", maxLength = 32)
@Schema(description = "创建人姓名")
@ExcelProperty("创建人姓名")
private String createName;
/**
* 创建时间
*/
@NotBlank(message = "创建时间 不能为空")
@ExcelAttribute(name = "创建时间", isNotEmpty = true, errorInfo = "创建时间 不能为空", isDate = true)
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private Date createTime;
/**
* 更新人id
*/
@Length(max = 32, message = "更新人id 不能超过32 个字符")
@ExcelAttribute(name = "更新人id", maxLength = 32)
@Schema(description = "更新人id")
@ExcelProperty("更新人id")
private String updateBy;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间", isDate = true)
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private Date updateTime;
/**
* 0 未删除 1 已删除
*/
@Length(max = 1, message = "0 未删除 1 已删除 不能超过1 个字符")
@ExcelAttribute(name = "0 未删除 1 已删除", maxLength = 1)
@Schema(description = "0 未删除 1 已删除")
@ExcelProperty("0 未删除 1 已删除")
private String deleteFlag;
}
/*
* 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.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCompanyInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCompanyInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCompanyInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
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 2023-08-23 17:31:05
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tcompanyinfo")
@Tag(name = "收入证明 中的 单位信息维护表管理")
public class TCompanyInfoController {
private final TCompanyInfoService tCompanyInfoService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TCompanyInfo>> getTCompanyInfoPage(Page<TCompanyInfo> page, TCompanyInfoSearchVo tCompanyInfo) {
return new R<>(tCompanyInfoService.getTCompanyInfoPage(page, tCompanyInfo));
}
/**
* 不分页查询
*
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage")
//@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo_get')" )
public R<List<TCompanyInfo>> getTCompanyInfoNoPage(@RequestBody TCompanyInfoSearchVo tCompanyInfo) {
return R.ok(tCompanyInfoService.noPageDiy(tCompanyInfo));
}
/**
* 通过id查询收入证明 中的 单位信息维护表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tcompanyinfo_get')")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo_get')")
public R<TCompanyInfo> getById(@PathVariable("id") String id) {
return R.ok(tCompanyInfoService.getById(id));
}
/**
* 新增收入证明 中的 单位信息维护表
*
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return R
*/
@Operation(summary = "新增收入证明 中的 单位信息维护表", description = "新增收入证明 中的 单位信息维护表:hasPermission('demo_tcompanyinfo_add')")
@SysLog("新增收入证明 中的 单位信息维护表")
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo_add')")
public R<Boolean> save(@RequestBody TCompanyInfo tCompanyInfo) {
TCompanyInfo exits = tCompanyInfoService.getOne(Wrappers.<TCompanyInfo>query().lambda()
.eq(TCompanyInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.eq(TCompanyInfo::getCompanyName,tCompanyInfo.getCompanyName()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exits)){
return R.failed("已存在相同公司名称的有效数据!");
}
return R.ok(tCompanyInfoService.save(tCompanyInfo));
}
/**
* 修改收入证明 中的 单位信息维护表
*
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return R
*/
@Operation(summary = "修改收入证明 中的 单位信息维护表", description = "修改收入证明 中的 单位信息维护表:hasPermission('demo_tcompanyinfo_edit')")
@SysLog("修改收入证明 中的 单位信息维护表")
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo_edit')")
public R<Boolean> updateById(@RequestBody TCompanyInfo tCompanyInfo) {
TCompanyInfo exits = tCompanyInfoService.getOne(Wrappers.<TCompanyInfo>query().lambda()
.eq(TCompanyInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.ne(TCompanyInfo::getId,tCompanyInfo.getId())
.eq(TCompanyInfo::getCompanyName,tCompanyInfo.getCompanyName()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exits)){
return R.failed("已存在相同公司名称的有效数据!");
}
return R.ok(tCompanyInfoService.updateById(tCompanyInfo));
}
/**
* 通过id删除收入证明 中的 单位信息维护表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id删除收入证明 中的 单位信息维护表", description = "通过id删除收入证明 中的 单位信息维护表:hasPermission('demo_tcompanyinfo_del')")
@SysLog("通过id删除收入证明 中的 单位信息维护表")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo_del')")
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tCompanyInfoService.removeById(id));
}
/**
* 收入证明 中的 单位信息维护表 批量导入
*
* @author fxj
* @date 2023-08-23 17:31:05
**/
@SneakyThrows
@Operation(description = "批量新增收入证明 中的 单位信息维护表 hasPermission('demo_tcompanyinfo-batch-import')")
@SysLog("批量新增收入证明 中的 单位信息维护表")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tCompanyInfoService.importDiy(file.getInputStream());
}
/**
* 收入证明 中的 单位信息维护表 批量导出
*
* @author fxj
* @date 2023-08-23 17:31:05
**/
@Operation(description = "导出收入证明 中的 单位信息维护表 hasPermission('demo_tcompanyinfo-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('demo_tcompanyinfo-export')")
public void export(HttpServletResponse response, @RequestBody TCompanyInfoSearchVo searchVo) {
tCompanyInfoService.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.TCompanyInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 收入证明 中的 单位信息维护表
*
* @author fxj
* @date 2023-08-23 17:31:05
*/
@Mapper
public interface TCompanyInfoMapper extends BaseMapper<TCompanyInfo> {
/**
* 收入证明 中的 单位信息维护表简单分页查询
*
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return
*/
IPage<TCompanyInfo> getTCompanyInfoPage(Page<TCompanyInfo> page, @Param("tCompanyInfo") TCompanyInfo tCompanyInfo);
}
/*
* 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCompanyInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCompanyInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
* 收入证明 中的 单位信息维护表
*
* @author fxj
* @date 2023-08-23 17:31:05
*/
public interface TCompanyInfoService extends IService<TCompanyInfo> {
/**
* 收入证明 中的 单位信息维护表简单分页查询
*
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return
*/
IPage<TCompanyInfo> getTCompanyInfoPage(Page<TCompanyInfo> page, TCompanyInfoSearchVo tCompanyInfo);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TCompanyInfoSearchVo searchVo);
List<TCompanyInfo> noPageDiy(TCompanyInfoSearchVo 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.TCompanyInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TCompanyInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCompanyInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCompanyInfoSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCompanyInfoVo;
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 2023-08-23 17:31:05
*/
@Log4j2
@Service
public class TCompanyInfoServiceImpl extends ServiceImpl<TCompanyInfoMapper, TCompanyInfo> implements TCompanyInfoService {
/**
* 收入证明 中的 单位信息维护表简单分页查询
* @param tCompanyInfo 收入证明 中的 单位信息维护表
* @return
*/
@Override
public IPage<TCompanyInfo> getTCompanyInfoPage(Page<TCompanyInfo> page, TCompanyInfoSearchVo tCompanyInfo){
return baseMapper.getTCompanyInfoPage(page,tCompanyInfo);
}
/**
* 收入证明 中的 单位信息维护表批量导出
* @param searchVo 收入证明 中的 单位信息维护表
* @return
*/
@Override
public void listExport(HttpServletResponse response, TCompanyInfoSearchVo searchVo){
String fileName = "收入证明 中的 单位信息维护表批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TCompanyInfo> 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, TCompanyInfo.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<TCompanyInfo> util = new ExcelUtil<>(TCompanyInfo.class);
for (TCompanyInfo 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<TCompanyInfo> noPageDiy(TCompanyInfoSearchVo searchVo) {
LambdaQueryWrapper<TCompanyInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TCompanyInfo::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(TCompanyInfoSearchVo searchVo) {
LambdaQueryWrapper<TCompanyInfo> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TCompanyInfo::getId,idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TCompanyInfoSearchVo entity){
LambdaQueryWrapper<TCompanyInfo> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TCompanyInfo::getCreateTime, entity.getCreateTimes()[0])
.le(TCompanyInfo::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())){
wrapper.eq(TCompanyInfo::getCreateName,entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TCompanyInfoVo> util1 = new ExcelUtil<>(TCompanyInfoVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TCompanyInfoVo.class, new ReadListener<TCompanyInfoVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TCompanyInfoVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TCompanyInfoVo 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());
importTCompanyInfo(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 importTCompanyInfo(List<TCompanyInfoVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TCompanyInfoVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TCompanyInfoVo excel) {
TCompanyInfo insert = new TCompanyInfo();
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.TCompanyInfoMapper">
<resultMap id="tCompanyInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TCompanyInfo">
<id property="id" column="id"/>
<result property="companyName" column="COMPANY_NAME"/>
<result property="companyAddress" column="COMPANY_ADDRESS"/>
<result property="companyTel" column="COMPANY_TEL"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
</resultMap>
<sql id="Base_Column_List">
a.id,
a.COMPANY_NAME,
a.COMPANY_ADDRESS,
a.COMPANY_TEL,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME,
a.DELETE_FLAG
</sql>
<sql id="tCompanyInfo_where">
<if test="tCompanyInfo != null">
<if test="tCompanyInfo.id != null and tCompanyInfo.id.trim() != ''">
AND a.id = #{tCompanyInfo.id}
</if>
<if test="tCompanyInfo.companyName != null and tCompanyInfo.companyName.trim() != ''">
AND a.COMPANY_NAME = #{tCompanyInfo.companyName}
</if>
<if test="tCompanyInfo.companyAddress != null and tCompanyInfo.companyAddress.trim() != ''">
AND a.COMPANY_ADDRESS = #{tCompanyInfo.companyAddress}
</if>
<if test="tCompanyInfo.companyTel != null and tCompanyInfo.companyTel.trim() != ''">
AND a.COMPANY_TEL = #{tCompanyInfo.companyTel}
</if>
<if test="tCompanyInfo.createBy != null and tCompanyInfo.createBy.trim() != ''">
AND a.CREATE_BY = #{tCompanyInfo.createBy}
</if>
<if test="tCompanyInfo.createName != null and tCompanyInfo.createName.trim() != ''">
AND a.CREATE_NAME = #{tCompanyInfo.createName}
</if>
<if test="tCompanyInfo.createTime != null">
AND a.CREATE_TIME = #{tCompanyInfo.createTime}
</if>
<if test="tCompanyInfo.updateBy != null and tCompanyInfo.updateBy.trim() != ''">
AND a.UPDATE_BY = #{tCompanyInfo.updateBy}
</if>
<if test="tCompanyInfo.updateTime != null">
AND a.UPDATE_TIME = #{tCompanyInfo.updateTime}
</if>
<if test="tCompanyInfo.deleteFlag != null and tCompanyInfo.deleteFlag.trim() != ''">
AND a.DELETE_FLAG = #{tCompanyInfo.deleteFlag}
</if>
</if>
</sql>
<!--tCompanyInfo简单分页查询-->
<select id="getTCompanyInfoPage" resultMap="tCompanyInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_company_info a
<where>
1=1
<include refid="tCompanyInfo_where"/>
order by a.UPDATE_TIME desc
</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