Commit 2c54d235 authored by huyuchen's avatar huyuchen

huyc 项目档案代码提交

parent e185899f
......@@ -51,8 +51,7 @@ public class TElecEmployeeInfo extends BaseEntity {
* 员工姓名
*/
@Schema(description ="员工姓名")
@NotNull(message = "员工姓名不能为空")
@Size(max = 20, message = "员工姓名不可超过20位")
@TableField(exist = false)
private String empName;
/**
......
......@@ -31,6 +31,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
......@@ -132,4 +133,16 @@ public class TElecEmployeeInfoController {
}
return R.failed("未找到身份证号对应的档案信息");
}
/**
* 批量导入电子档案
* @param file
* @return R
*/
@PostMapping("/importZip")
@Operation(summary = "批量导入电子档案", description = "批量导入电子档案")
@SysLog("批量导入电子档案" )
public R<Boolean> importZip(@RequestParam("file") MultipartFile file) {
return this.tElecEmployeeInfoService.importZip(file);
}
}
......@@ -214,7 +214,7 @@ public class TEmployeeProjectController {
*/
@Operation(summary = "通过id批量删除项目档案", description = "通过id批量删除项目档案")
@SysLog("通过id批量删除项目档案" )
@PostMapping("/{ids}" )
@PostMapping("/deletebyIds" )
@PreAuthorize("@pms.hasPermission('archives_temployeeproject_batchdel')" )
public R<List<ErrorMessage>> removeByIds(@RequestParam String ids) {
return tEmployeeProjectService.batchRemoveByIds(ids);
......
......@@ -21,6 +21,8 @@ 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.TElecEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.web.multipart.MultipartFile;
/**
* 电子档案信息表
......@@ -31,4 +33,13 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo;
public interface TElecEmployeeInfoService extends IService<TElecEmployeeInfo> {
IPage<TElecEmployeeInfo> getTElecEmployeeInfoPage(Page page, TElecEmployeeInfo vo);
/**
* @description: 解析zip文件包中的多个附件,并生成结算记录
* @param file zip文件包
* @return: R
* @author: huyc
* @date: 2022/6/24
*/
R<Boolean> importZip(MultipartFile file);
}
......@@ -16,13 +16,30 @@
*/
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.TElecEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TElecEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
/**
* 电子档案信息表
......@@ -42,4 +59,56 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
public IPage<TElecEmployeeInfo> getTElecEmployeeInfoPage(Page page, TElecEmployeeInfo tElecEmployeeInfo) {
return baseMapper.getTElecEmployeeInfoPage(page,tElecEmployeeInfo);
}
/**
* @description: 解析zip文件包中的多个附件,并生成结算记录
* @param file zip文件包
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
* @author: wangweiguo
* @date: 2021/8/19
*/
@Override
public R<Boolean> importZip(MultipartFile file) {
File unzip = null;
File etractFile = null;
try {
String fileType = FileTypeUtil.getType(file.getInputStream());
// if (!StringUtils.equalsIgnoreCase(fileType, CommonConstants.ZIP_TYPE)) {
// return R.failed(ErrorCodes.IMPORT_FILE_TYPE_ERROR);
// }
List list = new ArrayList();
etractFile = new File(UUID.randomUUID().toString());
unzip = ZipUtil.unzip(file.getInputStream(), etractFile, CharsetUtil.CHARSET_GBK);
ZipFile zipFile=new ZipFile(unzip);
for (Enumeration<? extends ZipArchiveEntry> e = zipFile.getEntries(); e.hasMoreElements();) {
ZipArchiveEntry entry=e.nextElement();
if(!entry.isDirectory()){
BufferedReader br=new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry)));
String line = "";
while((line = br.readLine()) != null){
if(line.length() > 0){
list.add(line);
}
}
br.close();
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (etractFile != null) {
FileUtil.del(etractFile);
}
}
return R.ok();
}
}
......@@ -392,8 +392,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
insTEmployeeInfo.setFileStatus(CommonConstants.dingleDigitIntArray[0]);
insTEmployeeInfo.setDeleteFlag(CommonConstants.STATUS_NORMAL);
insTEmployeeInfo.setStatus(CommonConstants.dingleDigitIntArray[0]);
//TODO HUYC 员工编码生成规则
insTEmployeeInfo.setEmpCode("查询人员档案的编码");
insTEmployeeInfo.setEmpCode(this.getCode());
YifuUser user = SecurityUtils.getUser();
insTEmployeeInfo.setCreateBy(user.getId());
insTEmployeeInfo.setCreateName(user.getNickname());
......@@ -421,7 +420,10 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
}
insTEmployeePro.setEmpNo(str);
//员工编码生成规则
insTEmployeePro.setEmpCode("查询人员档案的编码");
TEmployeeInfo tEmployeeInfo = tEmployeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard, excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.STATUS_NORMAL));
insTEmployeePro.setEmpCode(tEmployeeInfo.getEmpCode());
YifuUser user = SecurityUtils.getUser();
insTEmployeePro.setCreateBy(user.getId());
insTEmployeePro.setCreateName(user.getNickname());
......@@ -471,7 +473,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
if (!Common.isEmpty(ids)) {
idsList = Common.initStrToList(ids, CommonConstants.COMMA_STRING);
} else {
return R.failed("传参不能为空");
return R.failed(ErrorCodes.PARAM_NOT_EMPTY);
}
List<TEmployeeProject> list = new ArrayList<>();
if (Common.isNotEmpty(idsList)) {
......
......@@ -44,7 +44,7 @@
<sql id="Base_Column_List">
a.ID,
a.EMP_NAME,
b.EMP_NAME,
a.EMP_IDCARD,
b.EMP_NO,
b.UNIT_NAME,
......@@ -67,7 +67,7 @@
AND a.ID = #{tElecEmployeeInfo.id}
</if>
<if test="tElecEmployeeInfo.empName != null and tElecEmployeeInfo.empName.trim() != ''">
AND a.EMP_NAME = #{tElecEmployeeInfo.empName}
AND b.EMP_NAME = #{tElecEmployeeInfo.empName}
</if>
<if test="tElecEmployeeInfo.empIdcard != null and tElecEmployeeInfo.empIdcard.trim() != ''">
AND a.EMP_IDCARD = #{tElecEmployeeInfo.empIdcard}
......
......@@ -202,6 +202,8 @@ public interface CommonConstants {
int FOUR_INT = 4;
String TEN_STRING = "10";
public static final String SPOT = ".";
/**
* 员工初始序列
* @Author pwang
......@@ -247,6 +249,8 @@ public interface CommonConstants {
String IS_TRUE = "是";
int SIX_INT = 6;
int EIGHT_INT = 8;
public static final String ZIP_TYPE = "zip";
int BATCH_COUNT = 100;
String IMPORT_DATA_ANALYSIS_ERROR = "数据导入解析异常,请检查表数据格式";
String CREATE_TIME = "create_time";
......
......@@ -271,4 +271,8 @@ public interface ErrorCodes {
* 待划转员工已在目标项目下不可划转
*/
String CHECKS_CHANGE_EMP_PROJECT = "checks.change.emp.project";
/**
* 导入的文件格式不正确
*/
String IMPORT_FILE_TYPE_ERROR = "import.file.type.error";
}
......@@ -82,6 +82,8 @@ archives.import.emp.not.exists=\u6839\u636E\u8EAB\u4EFD\u8BC1\u672A\u627E\u5230\
archives.import.emp.idCard.must=\u8EAB\u4EFD\u8BC1\u5FC5\u586B
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
......
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