Commit 2191704e authored by fangxinjiang's avatar fangxinjiang

代码优化

parent 55132bbf
......@@ -117,41 +117,6 @@ public class TCertRecord extends BaseEntity {
@Schema(description ="印章名称")
private String seal;
/**
* 创建者
*/
@ExcelAttribute(name = "创建者" )
@Schema(description ="创建者")
private String createBy;
/**
* 更新人
*/
@ExcelAttribute(name = "更新人" )
@Schema(description ="更新人")
private String updateBy;
/**
* 创建人姓名
*/
@ExcelAttribute(name = "创建人姓名" )
@Schema(description ="创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间" )
@Schema(description ="创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间" )
@Schema(description ="更新时间")
private LocalDateTime updateTime;
/**
* 证明类型:0 在职 1 离职2劳动合同解除 3调档函4.代缴证明
*/
......@@ -174,10 +139,10 @@ public class TCertRecord extends BaseEntity {
private String leaveReason;
/**
* 性别:0男 1
* 性别:1男 2
*/
@ExcelAttribute(name = "性别:0男 1女" )
@Schema(description ="性别:0男 1女")
@ExcelAttribute(name = "性别" )
@Schema(description ="性别:1男 2女,和档案一致")
private String sex;
/**
......
/*
* 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.ExcelIgnore;
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 java.math.BigDecimal;
import java.util.Date;
/**
* 员工不良记录
*
* @author fxj
* @date 2022-06-29 15:50:45
*/
@Data
@TableName("t_emp_bad_record")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "员工不良记录")
public class TEmpBadRecord extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelAttribute(name = "主键" )
@Schema(description ="主键")
@ExcelIgnore
private String id;
/**
* 员工姓名
*/
@ExcelAttribute(name = "员工姓名" ,maxLength = 20)
@Schema(description ="员工姓名")
@ExcelProperty("员工姓名")
private String empName;
/**
* 员工ID
*/
@ExcelAttribute(name = "员工ID")
@Schema(description ="员工ID")
@ExcelIgnore
private String empId;
/**
* 身份证号
*/
@ExcelAttribute(name = "身份证号" ,maxLength = 20)
@Schema(description ="身份证号")
@ExcelProperty("身份证号")
private String empIdcard;
/**
* 产生项目
*/
@ExcelAttribute(name = "产生项目" ,maxLength = 50)
@Schema(description ="产生项目")
@ExcelProperty("产生项目")
private String project;
/**
* 项目编码
*/
@ExcelAttribute(name = "项目编码" ,maxLength = 50)
@Schema(description ="项目编码")
@ExcelProperty("项目编码")
private String projectCode;
/**
* 发生时间
*/
@ExcelAttribute(name = "发生时间" )
@Schema(description ="发生时间")
@ExcelProperty("发生时间")
private Date happenTime;
/**
* 备注
*/
@ExcelAttribute(name = "备注", maxLength = 200)
@Schema(description ="备注")
@ExcelProperty("备注")
private String remark;
/**
* 费用损失 (费用损失与其他费用损失其一必填)
*/
@ExcelAttribute(name = "费用损失 " )
@Schema(description ="费用损失 (费用损失与其他费用损失其一必填)")
@ExcelProperty("费用损失")
private BigDecimal loseFee;
/**
* 其他损失 (费用损失与其他费用损失其一必填)
*/
@ExcelAttribute(name = "其他损失" )
@Schema(description ="其他损失 (费用损失与其他费用损失其一必填)")
@ExcelProperty("其他损失")
private BigDecimal loseFeeOther;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpBadRecord;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @Author fxj
* @Date 2022/6/29
* @Description
* @Version 1.0
*/
@Data
public class EmpBadRecordSearchVo extends TEmpBadRecord {
private String ids;
/**
* 创建时间区间 [开始时间,结束时间]
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTimes;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author fxj
* @Date 2022/6/29
* @Description
* @Version 1.0
*/
@Data
public class EmpBadRecordVo extends RowIndex implements Serializable {
/**
* 员工姓名
*/
@ExcelAttribute(name = "员工姓名" ,maxLength = 20, isNotEmpty = true)
@Schema(description ="员工姓名")
private String empName;
/**
* 员工ID
*/
@ExcelAttribute(name = "员工ID")
@Schema(description ="员工ID")
private String empId;
/**
* 身份证号
*/
@ExcelAttribute(name = "身份证号" ,maxLength = 20, isNotEmpty = true)
@Schema(description ="身份证号")
private String empIdcard;
/**
* 产生项目
*/
@ExcelAttribute(name = "产生项目" ,maxLength = 50, isNotEmpty = true)
@Schema(description ="产生项目")
private String project;
/**
* 项目编码
*/
@ExcelAttribute(name = "项目编码" ,maxLength = 50, isNotEmpty = true)
@Schema(description ="项目编码")
private String projectCode;
/**
* 发生时间
*/
@ExcelAttribute(name = "发生时间" , isNotEmpty = true)
@Schema(description ="发生时间")
private Date happenTime;
/**
* 备注
*/
@ExcelAttribute(name = "备注", maxLength = 200, isNotEmpty = true)
@Schema(description ="备注")
private String remark;
/**
* 费用损失 (费用损失与其他费用损失其一必填)
*/
@ExcelAttribute(name = "费用损失 " )
@Schema(description ="费用损失 (费用损失与其他费用损失其一必填)")
private BigDecimal loseFee;
/**
* 其他损失 (费用损失与其他费用损失其一必填)
*/
@ExcelAttribute(name = "其他损失" )
@Schema(description ="其他损失 (费用损失与其他费用损失其一必填)")
private BigDecimal loseFeeOther;
}
/*
* 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.TEmpBadRecord;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpBadRecordService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpBadRecordSearchVo;
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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.http.HttpHeaders;
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 2022-06-29 15:50:45
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/tempbadrecord" )
@Tag(name = "员工不良记录管理")
public class TEmpBadRecordController {
private final TEmpBadRecordService tEmpBadRecordService;
/**
* 分页查询
* @param page 分页对象
* @param tEmpBadRecord 员工不良记录
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page" )
//@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_get')" )
public R<IPage<TEmpBadRecord>> getTEmpBadRecordPage(Page page, EmpBadRecordSearchVo tEmpBadRecord) {
return R.ok(tEmpBadRecordService.pageDiy(page, tEmpBadRecord));
}
/**
* 不分页查询
* @param tEmpBadRecord 员工不良记录
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage" )
//@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_get')" )
public R<List<TEmpBadRecord>> getTEmpBadRecordNoPage(@RequestBody EmpBadRecordSearchVo tEmpBadRecord) {
return R.ok(tEmpBadRecordService.noPageDiy(tEmpBadRecord));
}
/**
* 通过id查询员工不良记录
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tempbadrecord_get')")
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_get')" )
public R<TEmpBadRecord> getById(@PathVariable("id" ) String id) {
return R.ok(tEmpBadRecordService.getById(id));
}
/**
* 新增员工不良记录
* @param tEmpBadRecord 员工不良记录
* @return R
*/
@Operation(summary = "新增员工不良记录", description = "新增员工不良记录:hasPermission('demo_tempbadrecord_add')")
@SysLog("新增员工不良记录" )
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_add')" )
public R<Boolean> save(@RequestBody TEmpBadRecord tEmpBadRecord) {
return tEmpBadRecordService.saveDiy(tEmpBadRecord);
}
/**
* 修改员工不良记录
* @param tEmpBadRecord 员工不良记录
* @return R
*/
@Operation(summary = "修改员工不良记录", description = "修改员工不良记录:hasPermission('demo_tempbadrecord_edit')")
@SysLog("修改员工不良记录" )
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_edit')" )
public R<Boolean> updateById(@RequestBody TEmpBadRecord tEmpBadRecord) {
return R.ok(tEmpBadRecordService.updateById(tEmpBadRecord));
}
/**
* 通过id删除员工不良记录
* @param id id
* @return R
*/
@Operation(summary = "通过id删除员工不良记录", description = "通过id删除员工不良记录:hasPermission('demo_tempbadrecord_del')")
@SysLog("通过id删除员工不良记录" )
@DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_del')" )
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tEmpBadRecordService.removeById(id));
}
/**
* 通过ids删除员工不良记录
* @param ids
* @return R
*/
@Operation(summary = "通过ids删除员工不良记录", description = "通过id删除员工不良记录:hasPermission('demo_tempbadrecord_del_batch')")
@SysLog("通过ids删除员工不良记录" )
@DeleteMapping("/removeByIds" )
@PreAuthorize("@pms.hasPermission('demo_tempbadrecord_del_batch')" )
public R<Boolean> removeByIds(@RequestParam String ids) {
List<String> idList = Common.getList(ids);
return R.ok(tEmpBadRecordService.removeByIds(idList));
}
/**
* 批量新增不良记录信息
*
* @param file
* @return
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation(description = "批量新增不良记录信息 hasPermission('archives_tempbadrecord_importListAdd')")
@SysLog("批量新增不良记录信息")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_tempbadrecord_importListAdd')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tEmpBadRecordService.importEmpBadRecordDiy(file.getInputStream());
}
/**
* 批量导出项目档案信息
* @param searchVo
* @return R<List>
* @Author FXJ
* @Date 2022-06-21
**/
@Operation(description = "导出")
@PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody EmpBadRecordSearchVo searchVo) {
tEmpBadRecordService.listExport(response,searchVo);
}
}
......@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
......@@ -245,4 +246,17 @@ public class TEmployeeProjectController {
public R getItemByEmpNo(@RequestParam String empIdcard,@RequestParam String empNo) {
return tEmployeeProjectService.getItemByEmpNo(empIdcard,empNo);
}
/**
* 通过身份证获取对应所有项目信息
* @author fxj
* @param empIdCard
* @date 2022-06-29 17:45
* @return R
*/
@Operation(summary = "通过身份证获取对应所有项目信息", description = "通过身份证获取对应所有项目信息")
@GetMapping("/getProjectByIdCard" )
public R<Map<String,String>> getProjectByIdCard(@RequestParam String empIdCard) {
return tEmployeeProjectService.getProjectByIdCard(empIdCard);
}
}
/*
* 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.yifu.cloud.plus.v1.yifu.archives.entity.TEmpBadRecord;
import org.apache.ibatis.annotations.Mapper;
/**
* 员工不良记录
*
* @author fxj
* @date 2022-06-29 15:50:45
*/
@Mapper
public interface TEmpBadRecordMapper extends BaseMapper<TEmpBadRecord> {
}
/*
* 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.TEmpBadRecord;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpBadRecordSearchVo;
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 2022-06-29 15:50:45
*/
public interface TEmpBadRecordService extends IService<TEmpBadRecord> {
R<List<ErrorMessage>> importEmpBadRecordDiy(InputStream inputStream);
R<Boolean> saveDiy(TEmpBadRecord tEmpBadRecord);
void listExport(HttpServletResponse response, EmpBadRecordSearchVo searchVo);
IPage<TEmpBadRecord> pageDiy(Page page, EmpBadRecordSearchVo tEmpBadRecord);
List<TEmpBadRecord> noPageDiy(EmpBadRecordSearchVo tEmpBadRecord);
}
......@@ -31,6 +31,7 @@ import org.springframework.validation.BindingResult;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 项目档案表
......@@ -118,4 +119,6 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
void saveEmployeeProjectInfo(TEmployeeInfo employeeInfo);
R getItemByEmpNo(String empIdcard, String empNo);
R<Map<String, String>> getProjectByIdCard(String empIdCard);
}
......@@ -92,7 +92,7 @@ public class TCertRecordServiceImpl extends ServiceImpl<TCertRecordMapper, TCert
@Override
public IPage<TCertRecord> pageDiy(Page page, CertRecordSearchVo searchVo) {
LambdaQueryWrapper<TCertRecord> wrapper = buildQueryWrapper(searchVo);
wrapper.orderByDesc(BaseEntity::getCreateTime);
wrapper.orderByDesc(TCertRecord::getOpenTime);
return baseMapper.selectPage(page,wrapper);
}
......
/*
* 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.TEmpBadRecord;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpBadRecordMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpBadRecordService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor;
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.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 员工不良记录
*
* @author fxj
* @date 2022-06-29 15:50:45
*/
@Log4j2
@RequiredArgsConstructor
@Service
public class TEmpBadRecordServiceImpl extends ServiceImpl<TEmpBadRecordMapper, TEmpBadRecord> implements TEmpBadRecordService {
private final TEmployeeInfoMapper employeeInfoMapper;
private final TEmployeeProjectMapper projectMapper;
@Override
public R<List<ErrorMessage>> importEmpBadRecordDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpBadRecordVo> util1 = new ExcelUtil<>(EmpBadRecordVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpBadRecordVo.class, new ReadListener<EmpBadRecordVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpBadRecordVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpBadRecordVo 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());
importEmpBadRecord(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);
}
@Override
public R<Boolean> saveDiy(TEmpBadRecord tEmpBadRecord) {
return R.ok(baseMapper.insert(tEmpBadRecord) > 0);
}
private void importEmpBadRecord(List<EmpBadRecordVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
List<TEmpBadRecord> list = this.list();
TEmployeeInfo emp;
TEmployeeProject exist;
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
EmpBadRecordVo excel = excelVOList.get(i);
emp = employeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
errorMsg = checkRes(list, emp, excel);
if (Common.isNotNull(errorMsg)){
errorMessageList.add(errorMsg);
continue;
}
excel.setEmpName(emp.getEmpName());
exist = projectMapper.selectOne(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getDeptNo,excel.getProjectCode())
.eq(TEmployeeProject::getProjectStatus,CommonConstants.ZERO_STRING)
.eq(TEmployeeProject::getEmpIdcard,excel.getEmpIdcard())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(exist)){
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),MsgUtils.getMessage(ErrorCodes.ARCHIVES_PROJECT_EMP_NOT_EXIST)));
continue;
}
// 数据合法情况
insertExcel(excel,emp);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
}
}
private ErrorMessage checkRes(List<TEmpBadRecord> list, TEmployeeInfo emp, EmpBadRecordVo excel) {
if (Common.isEmpty(emp)){
return new ErrorMessage(excel.getRowIndex(),MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
return new ErrorMessage(excel.getRowIndex(),MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED));
}
return null;
}
/**
* 插入excel bad record
*/
private void insertExcel(EmpBadRecordVo excel, TEmployeeInfo emp) {
TEmpBadRecord insert = new TEmpBadRecord();
BeanUtil.copyProperties(excel, insert);
insert.setEmpIdcard(emp.getEmpIdcard());
insert.setEmpId(emp.getId());
insert.setEmpId(emp.getId());
this.save(insert);
}
@Override
public void listExport(HttpServletResponse response, EmpBadRecordSearchVo searchVo) {
String fileName = "不良记录批量导出" + LocalDateTime.now() + ".xlsx";
//获取要导出的列表
List<TEmpBadRecord> list = new ArrayList<>();
//获取记录
list = noPageDiy(searchVo);
if (Common.isNotNull(list)){
ExcelUtil<TEmpBadRecord> util = new ExcelUtil<>(TEmpBadRecord.class);
for (TEmpBadRecord vo:list){
util.convertEntity(vo,null,null,null);
}
}
ServletOutputStream out = null;
try {
if (list.size()>0) {
out = response.getOutputStream();
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(fileName , "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
out.flush();
}
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public IPage<TEmpBadRecord> pageDiy(Page page, EmpBadRecordSearchVo tEmpBadRecord) {
LambdaQueryWrapper<TEmpBadRecord> wrapper = buildQueryWrapper(tEmpBadRecord);
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectPage(page,wrapper);
}
@Override
public List<TEmpBadRecord> noPageDiy(EmpBadRecordSearchVo tEmpBadRecord) {
LambdaQueryWrapper<TEmpBadRecord> wrapper = buildQueryWrapper(tEmpBadRecord);
List<String> idList = Common.getList(tEmpBadRecord.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TEmpBadRecord::getId,idList);
}
return baseMapper.selectList(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(EmpBadRecordSearchVo entity){
LambdaQueryWrapper<TEmpBadRecord> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TEmpBadRecord::getCreateTime, entity.getCreateTimes()[0])
.le(TEmpBadRecord::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getEmpName())){
wrapper.likeRight(TEmpBadRecord::getEmpName,entity.getEmpName());
}
if (Common.isNotNull(entity.getEmpIdcard())){
wrapper.likeRight(TEmpBadRecord::getEmpIdcard,entity.getEmpIdcard());
}
if (Common.isNotNull(entity.getCreateName())){
wrapper.eq(TEmpBadRecord::getCreateName,entity.getCreateName());
}
return wrapper;
}
}
......@@ -96,7 +96,7 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
continue;
}
// 数据合法情况
insertExcelPost(excel,emp);
insertExcel(excel,emp);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
}
}
......@@ -166,7 +166,7 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
/**
* 插入excel work record
*/
private void insertExcelPost(EmpWorkRecordExcelVO excel,TEmployeeInfo emp) {
private void insertExcel(EmpWorkRecordExcelVO excel, TEmployeeInfo emp) {
TEmpWorkRecording insert = new TEmpWorkRecording();
BeanUtil.copyProperties(excel, insert);
insert.setDeleteFlag(CommonConstants.ZERO_STRING);
......@@ -194,7 +194,7 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
@Override
public R<List<ErrorMessage>> importEmpWorkRecordDiy(InputStream inputStream) {
List<com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage> errorMessageList = new ArrayList<>();
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpWorkRecordExcelVO> util1 = new ExcelUtil<>(EmpWorkRecordExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
......
......@@ -727,4 +727,19 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
return R.ok(map);
}
@Override
public R<Map<String, String>> getProjectByIdCard(String empIdCard) {
List<TEmployeeProject> projects = baseMapper.selectList(Wrappers.<TEmployeeProject>query().lambda()
.eq(TEmployeeProject::getDeleteFlag,CommonConstants.ZERO_STRING)
.eq(TEmployeeProject::getProjectStatus,CommonConstants.ZERO_STRING)
.eq(TEmployeeProject::getEmpIdcard,empIdCard));
Map<String,String> projectMap = new HashMap<>();
if (Common.isEmpty(projects)){
for (TEmployeeProject project:projects){
projectMap.put(project.getDeptName(),project.getDeptNo());
}
}
return R.ok(projectMap);
}
}
<?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.TEmpBadRecordMapper">
<resultMap id="tEmpBadRecordMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpBadRecord">
<id property="id" column="ID"/>
<result property="empName" column="EMP_NAME"/>
<result property="empId" column="EMP_ID"/>
<result property="empIdcard" column="EMP_IDCARD"/>
<result property="project" column="PROJECT"/>
<result property="projectCode" column="PROJECT_CODE"/>
<result property="happenTime" column="HAPPEN_TIME"/>
<result property="remark" column="REMARK"/>
<result property="loseFee" column="LOSE_FEE"/>
<result property="loseFeeOther" column="LOSE_FEE_OTHER"/>
<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>
</mapper>
......@@ -172,7 +172,7 @@ public interface ErrorCodes {
String ARCHIVES_EMP_FAMILY_NAME_EXISTING = "archives.emp.family.name.existing";
/**
* 已存在对应身份证的家庭成员信息
* 无对应身份证的员工信息
*/
String ARCHIVES_EMP_NOT_EXIST = "archives.emp.not.exist";
......@@ -279,4 +279,8 @@ public interface ErrorCodes {
* 申请年份不可为未来年份
*/
String ARCHIVES_EMP_CERTIFICATE_DECLARE_YEAR_ERROR = "archives.emp.certificate.declare.year.error";
/**
* 对应项目编码无项目档案信息,请核实后导入
*/
String ARCHIVES_PROJECT_EMP_NOT_EXIST = "archives.project.emp.not.exist";
}
......@@ -85,6 +85,8 @@ archives.import.emp.leaveReason.must=\u51CF\u6863\u539F\u56E0\u5FC5\u586B
import.file.type.error=\u5BFC\u5165\u7684\u6587\u4EF6\u683C\u5F0F\u4E0D\u6B63\u786E
archives.project.emp.not.exist=\u5BF9\u5E94\u9879\u76EE\u7F16\u7801\u65E0\u9879\u76EE\u6863\u6848\u4FE1\u606F\uFF0C\u8BF7\u6838\u5B9E\u540E\u5BFC\u5165
......
......@@ -77,5 +77,11 @@
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
package com.yifu.cloud.plus.v1.yifu.common.mybatis.base;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -33,6 +34,7 @@ public class BaseEntity implements Serializable {
*/
@Schema(description = "创建人")
@TableField(fill = FieldFill.INSERT)
@ExcelIgnore
private String createBy;
/**
......@@ -48,6 +50,7 @@ public class BaseEntity implements Serializable {
*/
@Schema(description = "更新人")
@TableField(fill = FieldFill.INSERT_UPDATE)
@ExcelIgnore
private String updateBy;
/**
......
......@@ -66,9 +66,9 @@ public class ${className}Controller {
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@GetMapping("/noPage" )
@PostMapping("/noPage" )
//@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" )
public R<List<${className}>> get${className}NoPage(${className} ${classname}) {
public R<List<${className}>> get${className}NoPage(@RequestBody ${className} ${classname}) {
return R.ok(${classname}Service.list(Wrappers.query(${classname})));
}
......@@ -80,7 +80,7 @@ public class ${className}Controller {
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('${moduleName}_${pathName}_get')")
@GetMapping("/{${pk.lowerAttrName}}" )
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_get')" )
public R<${classname}> getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
public R<${className}> getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
}
......
......@@ -17,6 +17,7 @@
#set($excludeColumns = ["create_time","update_time","create_by","update_by"])
package ${package}.${moduleName}.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;
......@@ -51,6 +52,7 @@ public class ${className} extends BaseEntity {
#end
@ExcelAttribute(name = "$column.comments"#if($column.isNullable =='NO' && $column.attrType !='LocalDate' && $column.attrType !='LocalDateTime'), isNotEmpty = true,errorInfo = "$column.comments不能为空"#end #if($column.maxLength), maxLength = $column.maxLength #end)
@Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
@ExcelProperty("$column.comments")
private $column.attrType $column.lowerAttrName;
#end
......
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