add file upload method

This commit is contained in:
fumeiai 2020-05-20 23:57:07 +08:00
parent 521cecc989
commit a5024f2dd2
17 changed files with 1750 additions and 52 deletions

View File

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: commons-io:commons-io:2.5">
<library name="Maven: commons-io:commons-io:1.3.2">
<CLASSES>
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/2.5/commons-io-2.5.jar!/" />
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/2.5/commons-io-2.5-javadoc.jar!/" />
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/2.5/commons-io-2.5-sources.jar!/" />
<root url="jar://$USER_HOME$/java/myrepo/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar!/" />
</SOURCES>
</library>
</component>

38
.idea/workspace.xml generated
View File

@ -2,17 +2,23 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/ExcelUtil.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/excel/ExcelCell.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/excel/ExcelLog.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/excel/ExcelLogs.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/excel/ExcelSheet.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/excel/FieldForSortting.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Maven__commons_io_commons_io_2_5.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lz_management.iml" beforeDir="false" afterPath="$PROJECT_DIR$/lz_management.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/DateUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/common/utils/DateUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffDao.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/controller/StaffController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/controller/StaffController.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffDao.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffDao.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffService.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffService.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/mapper/generator/StaffDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/mapper/generator/StaffDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/task/GetFeishuDepartmentsJob.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/task/SyncnizeFlybookDataJob.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/lz/FumeiaiTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/lz/FumeiaiTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/oauth2/OAuth2Filter.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/oauth2/OAuth2Filter.class" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -52,16 +58,19 @@
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/com/lz/common/utils" />
<property name="settings.editor.selected.configurable" value="MavenSettings" />
</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="com.lz.common.utils" />
<recent name="com.lz.modules.app.Dto" />
<recent name="com.lz.modules.app.enums" />
<recent name="com.lz.modules.app.entity.excel" />
<recent name="com.lz.modules.job.model.responseBo" />
<recent name="com.lz" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/main/java/com/lz/common/utils" />
</key>
</component>
<component name="RunDashboard">
@ -160,7 +169,7 @@
<workItem from="1588159936850" duration="1226000" />
<workItem from="1588161274115" duration="1691000" />
<workItem from="1588163384182" duration="74761000" />
<workItem from="1588936950753" duration="88892000" />
<workItem from="1588936950753" duration="95089000" />
</task>
<servers />
</component>
@ -190,7 +199,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/test/java/com/lz/FumeiaiTest.java</url>
<line>190</line>
<line>191</line>
<option name="timeStamp" value="43" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
@ -215,7 +224,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
<line>83</line>
<line>93</line>
<option name="timeStamp" value="62" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
@ -228,11 +237,6 @@
<line>80</line>
<option name="timeStamp" value="67" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java</url>
<line>191</line>
<option name="timeStamp" value="75" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>

View File

@ -124,7 +124,7 @@
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:1.3.2" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />

View File

@ -26,6 +26,7 @@
<commons.io.version>2.5</commons.io.version>
<commons.codec.version>1.10</commons.codec.version>
<commons.configuration.version>1.10</commons.configuration.version>
<commons.io.version>1.3.2</commons.io.version>
<shiro.version>1.4.0</shiro.version>
<jwt.version>0.7.0</jwt.version>
<kaptcha.version>0.0.9</kaptcha.version>
@ -146,6 +147,11 @@
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>

View File

@ -27,6 +27,10 @@ public class DateUtils {
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**
* yyyyMMdd
*/
public static final String DEFAULT_PATTERN = "yyyyMMdd";
/**
* 日期格式化 日期格式为yyyy-MM-dd

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
package com.lz.common.utils.excel;
import com.lz.common.utils.StringUtil;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @BelongsProject: ltapi
* @BelongsPackage: com.lz.lt.api.common.util.excel
* @Author: gui.quanwang
* @CreateTime: 2018-11-27 16:53
* @Description: 数值型的栏位只能使用Double(自定义注解)
* @注意本内容仅限于杭州霖梓网络科技有限公司内部传阅禁止外泄以及用于其他的商业目的
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ExcelCell {
/**
* 顺序 default 100
*
* @return index
*/
int index();
/**
* 当值为null时要显示的值 default StringUtils.EMPTY
*
* @return defaultValue
*/
String defaultValue() default StringUtil.EMPTY;
/**
* 用于验证
*
* @return valid
*/
Valid valid() default @Valid();
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Valid {
/**
* 必须与in中String相符,目前仅支持String类型
*
* @return e.g. {"key","value"}
*/
String[] in() default {};
/**
* 是否允许为空,用于验证数据 default true
*
* @return allowNull
*/
boolean allowNull() default true;
/**
* Apply a "greater than" constraint to the named property
*
* @return gt
*/
double gt() default Double.NaN;
/**
* Apply a "less than" constraint to the named property
*
* @return lt
*/
double lt() default Double.NaN;
/**
* Apply a "greater than or equal" constraint to the named property
*
* @return ge
*/
double ge() default Double.NaN;
/**
* Apply a "less than or equal" constraint to the named property
*
* @return le
*/
double le() default Double.NaN;
}
}

View File

@ -0,0 +1,100 @@
package com.lz.common.utils.excel;
/**
* @BelongsProject: ltapi
* @BelongsPackage: com.lz.lt.api.common.util.excel
* @Author: gui.quanwang
* @CreateTime: 2018-11-27 16:43
* @Description: excel输出
* @注意本内容仅限于杭州霖梓网络科技有限公司内部传阅禁止外泄以及用于其他的商业目的
*/
public class ExcelLog {
/**
* 行数
*/
private Integer rowNum;
/**
* 数据
*/
private Object object;
/**
* 记录
*/
private String log;
/**
* @param object
* @param log
*/
public ExcelLog(Object object, String log) {
super();
this.object = object;
this.log = log;
}
/**
* @param rowNum
* @param object
* @param log
*/
public ExcelLog(Object object, String log, Integer rowNum) {
super();
this.rowNum = rowNum;
this.object = object;
this.log = log;
}
/**
* @return the rowNum
*/
public Integer getRowNum() {
return rowNum;
}
/**
* @param rowNum the rowNum to set
*/
public void setRowNum(Integer rowNum) {
this.rowNum = rowNum;
}
/**
* @return the object
*/
public Object getObject() {
return object;
}
/**
* @param object the object to set
*/
public void setObject(Object object) {
this.object = object;
}
/**
* @return the log
*/
public String getLog() {
return log;
}
/**
* @param log the log to set
*/
public void setLog(String log) {
this.log = log;
}
@Override
public String toString() {
return "ExcelLog{" +
"rowNum=" + rowNum +
", object=" + object +
", log='" + log + '\'' +
'}';
}
}

View File

@ -0,0 +1,82 @@
package com.lz.common.utils.excel;
import com.lz.common.utils.StringUtil;
import java.util.ArrayList;
import java.util.List;
/**
* @BelongsProject: ltapi
* @BelongsPackage: com.lz.lt.api.common.util.excel
* @Author: gui.quanwang
* @CreateTime: 2018-11-27 16:45
* @Description: excel错误日志记录
* @注意本内容仅限于杭州霖梓网络科技有限公司内部传阅禁止外泄以及用于其他的商业目的
*/
public class ExcelLogs {
/**
* 是否出错
*/
private Boolean hasError;
/**
* excel集合
*/
private List<ExcelLog> logList;
public ExcelLogs() {
super();
hasError = false;
}
/**
* @return the hasError
*/
public Boolean getHasError() {
return hasError;
}
/**
* @param hasError the hasError to set
*/
public void setHasError(Boolean hasError) {
this.hasError = hasError;
}
/**
* @return the logList
*/
public List<ExcelLog> getLogList() {
return logList;
}
/**
* @param logList the logList to set
*/
public void setLogList(List<ExcelLog> logList) {
this.logList = logList;
}
/**
* 获取错误excel集合
* @return
*/
public List<ExcelLog> getErrorLogList() {
List<ExcelLog> errList = new ArrayList<>();
for (ExcelLog log : this.logList) {
if (log != null && StringUtil.isNotBlank(log.getLog())) {
errList.add(log);
}
}
return errList;
}
@Override
public String toString() {
return "ExcelLogs{" +
"hasError=" + hasError +
", logList=" + logList +
'}';
}
}

View File

@ -0,0 +1,87 @@
package com.lz.common.utils.excel;
import java.util.Collection;
import java.util.Map;
/**
* @BelongsProject: ltapi
* @BelongsPackage: com.lz.lt.api.common.util.excel
* @Author: gui.quanwang
* @CreateTime: 2018-11-27 16:49
* @Description: 用于汇出多个sheet的Vo
* @注意本内容仅限于杭州霖梓网络科技有限公司内部传阅禁止外泄以及用于其他的商业目的
*/
public class ExcelSheet<T> {
/**
* sheet名
*/
private String sheetName;
/**
* 头部集合(字段属性)
*/
private Map<String, String> headers;
/**
* 数据源
*/
private Collection<T> dataset;
/**
* @return the sheetName
*/
public String getSheetName() {
return sheetName;
}
/**
* Excel页签名称
*
* @param sheetName the sheetName to set
*/
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
/**
* Excel表头
*
* @return the headers
*/
public Map<String, String> getHeaders() {
return headers;
}
/**
* @param headers the headers to set
*/
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
/**
* Excel数据集合
*
* @return the dataset
*/
public Collection<T> getDataset() {
return dataset;
}
/**
* @param dataset the dataset to set
*/
public void setDataset(Collection<T> dataset) {
this.dataset = dataset;
}
@Override
public String toString() {
return "ExcelSheet{" +
"sheetName='" + sheetName + '\'' +
", headers=" + headers +
", dataset=" + dataset +
'}';
}
}

View File

@ -0,0 +1,80 @@
package com.lz.common.utils.excel;
import java.lang.reflect.Field;
/**
* @BelongsProject: ltapi
* @BelongsPackage: com.lz.lt.api.common.util.excel
* @Author: gui.quanwang
* @CreateTime: 2018-11-27 16:52
* @Description: 泛型类反射后的字段封装类
* @注意本内容仅限于杭州霖梓网络科技有限公司内部传阅禁止外泄以及用于其他的商业目的
*/
public class FieldForSortting {
/**
* 泛型反射
*/
private Field field;
/**
* 索引
*/
private int index;
/**
* @param field
*/
public FieldForSortting(Field field) {
super();
this.field = field;
}
/**
* @param field
* @param index
*/
public FieldForSortting(Field field, int index) {
super();
this.field = field;
this.index = index;
}
/**
* @return the field
*/
public Field getField() {
return field;
}
/**
* @param field
* the field to set
*/
public void setField(Field field) {
this.field = field;
}
/**
* @return the index
*/
public int getIndex() {
return index;
}
/**
* @param index
* the index to set
*/
public void setIndex(int index) {
this.index = index;
}
@Override
public String toString() {
return "FieldForSortting{" +
"field=" + field +
", index=" + index +
'}';
}
}

View File

@ -1,29 +1,28 @@
package com.lz.modules.app.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.lz.common.utils.*;
import com.lz.modules.app.Dto.*;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.*;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.common.utils.DateUtils;
import com.lz.modules.app.Dto.*;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.service.*;
import com.lz.modules.sys.entity.SysCaptchaEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
/**
* 员工基本信息表
*
@ -188,12 +187,59 @@ public class StaffController {
educationDistribution.setRows(educationRows);
data.put("educationDistribution", educationDistribution);
R ret = R.ok();
ret.put("data", data);
return ret;
}
/**
* 上传Excel,读取Excel中内容
*
* @param file 文件
* @return
* @throws IOException
*/
@RequestMapping(value = "/batchImport")
// @RequiresPermissions("user:ltuserrewardlog:upload")
public R batchImport(@RequestParam(value = "file") MultipartFile file) {
InputStream inputStream;
try {
//判断文件是否为空
if (file == null) {
return R.error("文件不能为空");
}
//获取文件名
String name = file.getOriginalFilename();
//进一步判断文件是否为空即判断其大小是否为0或其名称是否为null验证文件名是否合格
long size = file.getSize();
if (StringUtil.isBlank(name) || size == 0 || !ExcelUtil.validateExcel(name)) {
return R.error("文件格式不正确!请使用.xls或.xlsx后缀文档。");
}
if (name.lastIndexOf(".csv") != -1 || name.lastIndexOf(".CSV") != -1) {
inputStream = new ByteArrayInputStream(file.getBytes());
} else {
inputStream = file.getInputStream();
}
List<Map<String, String>> sheet12List = Lists.newArrayList();
List<Map<String, String>> sheet3List = Lists.newArrayList();
List<Map<String, String>> sheet4List = Lists.newArrayList();
ExcelUtil.getExcelData(inputStream, sheet12List, sheet3List, sheet4List);
staffService.enterDatabase(sheet12List, sheet3List, sheet4List);
return R.ok();
} catch (IOException e) {
return R.error();
}
}
/**
* 保存
*/

View File

@ -47,5 +47,6 @@ public interface StaffService extends IService<StaffEntity> {
List<GraphicsStatisticalDto> getEducationData(String departmentId, String beginDate, String endDate);
void enterDatabase(List<Map<String, String>> sheet12List, List<Map<String, String>> sheet3List, List<Map<String, String>> sheet4List);
}

View File

@ -1,7 +1,9 @@
package com.lz.modules.app.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
@ -12,8 +14,8 @@ import com.lz.modules.app.Dto.StaffBaseInfoDto;
import com.lz.modules.app.Dto.StaffDto;
import com.lz.modules.app.Dto.StaffStatisticalDto;
import com.lz.modules.app.dao.StaffDao;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.app.entity.*;
import com.lz.modules.app.service.*;
import com.lz.modules.job.model.responseBo.DepartmentStaffBo;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -31,6 +33,14 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
@Resource
StaffDao staffDao;
@Resource
StaffOccupationService staffOccupationService;
@Resource
StaffEducationService staffEducationService;
@Resource
StaffProjectExperienceService staffProjectExperienceService;
@Resource
StaffWorkTransferRecordService staffWorkTransferRecordService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
@ -161,6 +171,75 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return graphicsStatisticals;
}
@Override
public void enterDatabase(List<Map<String, String>> sheet12List, List<Map<String, String>> sheet3List, List<Map<String, String>> sheet4List) {
for (Map<String, String> map : sheet12List) {
StaffEntity staffEntity = JSON.parseObject(JSON.toJSONString(map), StaffEntity.class);
StaffOccupationEntity occupationEntity = JSON.parseObject(JSON.toJSONString(map), StaffOccupationEntity.class);
StaffEducationEntity educationEntity = JSON.parseObject(JSON.toJSONString(map), StaffEducationEntity.class);
StaffEntity Staff = this.getByName(staffEntity.getName());
if (Staff == null) {
this.save(staffEntity);
} else {
staffEntity.setId(Staff.getId());
this.updateById(staffEntity);
}
StaffOccupationEntity occupation = staffOccupationService.getOne(new QueryWrapper<StaffOccupationEntity>().eq("staff_id", staffEntity.getId()));
if (occupation == null) {
occupationEntity.setStaffId(staffEntity.getId());
staffOccupationService.save(occupationEntity);
} else {
occupationEntity.setId(occupation.getId());
staffOccupationService.updateById(occupationEntity);
}
StaffEducationEntity education = staffEducationService.getOne(new QueryWrapper<StaffEducationEntity>().eq("staff_id", staffEntity.getId()));
if (education == null) {
educationEntity.setStaffId(staffEntity.getId());
staffEducationService.save(educationEntity);
} else {
educationEntity.setId(education.getId());
staffEducationService.updateById(educationEntity);
}
}
for (Map<String, String> map : sheet3List) {
StaffProjectExperienceEntity staffProjectExperienceEntity = JSON.parseObject(JSON.toJSONString(map), StaffProjectExperienceEntity.class);
StaffEntity Staff = this.getByName(map.get("name"));
if (Staff == null) {
continue;
} else {
staffProjectExperienceService.update(new UpdateWrapper<StaffProjectExperienceEntity>().set("is_delete", 1).eq("staff_id", Staff.getId()));
StaffProjectExperienceEntity projectExperienceEntity = staffProjectExperienceService.getOne(new QueryWrapper<StaffProjectExperienceEntity>().eq("staff_id", Staff.getId()).eq("project_name", staffProjectExperienceEntity.getProjectName()));
if (projectExperienceEntity == null) {
staffProjectExperienceEntity.setStaffId(Staff.getId());
staffProjectExperienceService.save(staffProjectExperienceEntity);
} else {
staffProjectExperienceEntity.setId(projectExperienceEntity.getId());
staffProjectExperienceEntity.setIsDelete(0);
staffProjectExperienceService.updateById(staffProjectExperienceEntity);
}
}
}
for (Map<String, String> map : sheet4List) {
StaffWorkTransferRecordEntity staffWorkTransferRecordEntity = JSON.parseObject(JSON.toJSONString(map), StaffWorkTransferRecordEntity.class);
StaffEntity Staff = this.getByName(map.get("name"));
if (Staff == null) {
continue;
} else {
staffWorkTransferRecordService.update(new UpdateWrapper<StaffWorkTransferRecordEntity>().set("is_delete", 1).eq("staff_id", Staff.getId()));
StaffWorkTransferRecordEntity workTransferRecordEntity = staffWorkTransferRecordService.getOne(new QueryWrapper<StaffWorkTransferRecordEntity>().eq("staff_id", Staff.getId()).eq("transfer_time", staffWorkTransferRecordEntity.getTransferTime()));
if (workTransferRecordEntity == null) {
staffWorkTransferRecordEntity.setStaffId(Staff.getId());
staffWorkTransferRecordService.save(staffWorkTransferRecordEntity);
} else {
staffWorkTransferRecordEntity.setId(workTransferRecordEntity.getId());
staffWorkTransferRecordEntity.setIsDelete(0);
staffWorkTransferRecordService.updateById(staffWorkTransferRecordEntity);
}
}
}
}
private StaffEntity convertStaffEntity(DepartmentStaffBo staffBo) {
StaffEntity staffEntity = new StaffEntity();
staffEntity.setName(staffBo.getName());//员工姓名

View File

@ -22,8 +22,8 @@ import org.springframework.stereotype.Component;
*
* @author fumeiai 20200429
*/
@Component("getFeishuDepartmentsJob")
public class GetFeishuDepartmentsJob {
@Component("syncnizeFlybookDataJob")
public class SyncnizeFlybookDataJob {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
@ -31,9 +31,9 @@ public class GetFeishuDepartmentsJob {
public void run() {
logger.info("borrowAndRepayMonitorJob start date == {}", DateUtils.getCurrentDate());
logger.info("syncnizeFlybookDataJob start date == {}", DateUtils.getCurrentDate());
feishuBusiness.getFeishuDepartmentsIntoData();
logger.info("borrowAndRepayMonitorJob end date == {}", DateUtils.getCurrentDate());
logger.info("syncnizeFlybookDataJob end date == {}", DateUtils.getCurrentDate());
}

View File

@ -41,15 +41,16 @@ public class FumeiaiTest {
feishuBusiness.getFeishuDepartmentsIntoData();
File xlsFile = new File("/Users/fumeiai/tmp/员工档案字段表-0427.xlsx");
// 获得工作簿
Workbook workbook = WorkbookFactory.create(xlsFile);
// 获得工作表个数
int sheetCount = workbook.getNumberOfSheets();
List<Map<String, String>> sheet12List = Lists.newArrayList();
List<Map<String, String>> sheet3List = Lists.newArrayList();
List<Map<String, String>> sheet4List = Lists.newArrayList();
// 获得工作簿
Workbook workbook = WorkbookFactory.create(xlsFile);
// 获得工作表个数
int sheetCount = workbook.getNumberOfSheets();
// 遍历工作表
for (int i = 0; i < sheetCount; i++) {
Sheet sheet = workbook.getSheetAt(i);