培训计划管理导入导出接口
parent
b10f5db41a
commit
20497ec5ec
|
|
@ -12,14 +12,20 @@ import com.gunshi.project.xyt.service.FileAssociationsService;
|
||||||
import com.gunshi.project.xyt.service.PersonnelPlanService;
|
import com.gunshi.project.xyt.service.PersonnelPlanService;
|
||||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
import com.gunshi.project.xyt.validate.markers.Update;
|
import com.gunshi.project.xyt.validate.markers.Update;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -151,4 +157,63 @@ public class PersonnelPlanController extends AbstractCommonFileController{
|
||||||
return R.ok(data);
|
return R.ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
@Operation(summary = "上传")
|
||||||
|
public R<List<PersonnelPlan>> uploading(@RequestPart("file") MultipartFile file) throws IOException {
|
||||||
|
|
||||||
|
//判断文件是否有数据
|
||||||
|
if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) {
|
||||||
|
throw new IllegalArgumentException("上传文件为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExcelUtil<PersonnelPlan> util = new ExcelUtil< >(PersonnelPlan.class);
|
||||||
|
|
||||||
|
List<PersonnelPlan> plans = util.importExcel(file.getInputStream());
|
||||||
|
|
||||||
|
return R.ok(plans);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/download")
|
||||||
|
@Operation(summary = "下载")
|
||||||
|
public void download(@RequestBody PersonnelPlanPage page, HttpServletResponse response) {
|
||||||
|
LambdaQueryChainWrapper<PersonnelPlan> query = service.lambdaQuery();
|
||||||
|
|
||||||
|
Date stm = page.getStm();
|
||||||
|
if (Objects.nonNull(stm)){
|
||||||
|
query.ge(PersonnelPlan::getStm, stm);
|
||||||
|
}
|
||||||
|
|
||||||
|
Date etm = page.getEtm();
|
||||||
|
if (Objects.nonNull(etm)){
|
||||||
|
query.le(PersonnelPlan::getEtm, etm);
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = page.getName();
|
||||||
|
if (StringUtils.isNotBlank(name)){
|
||||||
|
query.like(PersonnelPlan::getName, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
String applicant = page.getApplicant();
|
||||||
|
if (StringUtils.isNotBlank(applicant)){
|
||||||
|
query.like(PersonnelPlan::getApplicant, applicant);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PersonnelPlan> list = query.list();
|
||||||
|
ExcelUtil<PersonnelPlan> util = new ExcelUtil< >(PersonnelPlan.class);
|
||||||
|
|
||||||
|
util.exportExcel(response, list, "培训计划");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/template")
|
||||||
|
@Operation(summary = "下载模板")
|
||||||
|
public void download(HttpServletResponse response) {
|
||||||
|
ExcelUtil<PersonnelPlan> util = new ExcelUtil<>(PersonnelPlan.class);
|
||||||
|
|
||||||
|
util.importTemplateExcel(response, "培训计划");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import com.gunshi.core.dateformat.DateFormatString;
|
import com.gunshi.core.dateformat.DateFormatString;
|
||||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
import com.gunshi.project.xyt.validate.markers.Update;
|
import com.gunshi.project.xyt.validate.markers.Update;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
@ -49,6 +50,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 培训班名称
|
* 培训班名称
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "培训班名称",sort = 1)
|
||||||
@TableField(value="name")
|
@TableField(value="name")
|
||||||
@Schema(description="培训班名称")
|
@Schema(description="培训班名称")
|
||||||
@Size(max = 30,message = "培训班名称最大长度要小于 30")
|
@Size(max = 30,message = "培训班名称最大长度要小于 30")
|
||||||
|
|
@ -67,6 +69,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 主办单位
|
* 主办单位
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "主办单位",sort = 4)
|
||||||
@TableField(value="unit")
|
@TableField(value="unit")
|
||||||
@Schema(description="主办单位")
|
@Schema(description="主办单位")
|
||||||
@Size(max = 100,message = "主办单位最大长度要小于 100")
|
@Size(max = 100,message = "主办单位最大长度要小于 100")
|
||||||
|
|
@ -76,6 +79,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 开始培训时间
|
* 开始培训时间
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "开始培训时间",sort = 2)
|
||||||
@Schema(description="开始培训时间 格式:yyyy-MM-dd")
|
@Schema(description="开始培训时间 格式:yyyy-MM-dd")
|
||||||
@NotNull(message = "开始培训时间不能为空")
|
@NotNull(message = "开始培训时间不能为空")
|
||||||
@TableField(value="stm")
|
@TableField(value="stm")
|
||||||
|
|
@ -85,6 +89,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 结束培训时间
|
* 结束培训时间
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "结束培训时间",sort = 3)
|
||||||
@Schema(description="结束培训时间 格式:yyyy-MM-dd")
|
@Schema(description="结束培训时间 格式:yyyy-MM-dd")
|
||||||
@NotNull(message = "结束培训时间不能为空")
|
@NotNull(message = "结束培训时间不能为空")
|
||||||
@TableField(value="etm")
|
@TableField(value="etm")
|
||||||
|
|
@ -108,6 +113,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 培训地点
|
* 培训地点
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "培训地点",sort = 6)
|
||||||
@Schema(description="培训地点")
|
@Schema(description="培训地点")
|
||||||
@TableField(value="addr")
|
@TableField(value="addr")
|
||||||
@Size(max = 200,message = "主办单位最大长度要小于 200")
|
@Size(max = 200,message = "主办单位最大长度要小于 200")
|
||||||
|
|
@ -117,6 +123,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 培训内容
|
* 培训内容
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "培训内容",sort = 5)
|
||||||
@Schema(description="培训内容")
|
@Schema(description="培训内容")
|
||||||
@TableField(value="content")
|
@TableField(value="content")
|
||||||
@Size(max = 500,message = "培训内容最大长度要小于 500")
|
@Size(max = 500,message = "培训内容最大长度要小于 500")
|
||||||
|
|
@ -171,6 +178,7 @@ public class PersonnelPlan extends CommUpdate implements Serializable {
|
||||||
@Schema(description="填报人")
|
@Schema(description="填报人")
|
||||||
@TableField(value="applicant")
|
@TableField(value="applicant")
|
||||||
@Size(max = 50,message = "填报人最大长度要小于 50")
|
@Size(max = 50,message = "填报人最大长度要小于 50")
|
||||||
|
@Excel(name = "填报人",sort = 7)
|
||||||
private String applicant;
|
private String applicant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue