package com.hcc.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.hcc.pojo.*;
import com.hcc.service.*;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author CC
* @since 2022-04-28
*/
@RestController
@RequestMapping("/employee/basid")
public class EmployeeController {
@Autowired
private IEmployeeService employeeService;
@Autowired
private IPoliticsStatusService politicsStatusService;
@Autowired
private IJoblevelService joblevelService;
@Autowired
private INationService nationService;
@Autowired
private IPositionService positionService;
@Autowired
private IDepartmentService departmentService;
@ApiOperation(value = "获取所有员工")
@GetMapping("/")
public RespPageBean getEmployee(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer size,
Employee employee,
LocalDate[] beginDateScope){
return employeeService.getEmployee(currentPage,size,employee,beginDateScope);
}
@ApiOperation(value = "获取所有政治面貌")
@GetMapping("/politicsstatus")
public List<PoliticsStatus> getAllPoliticeStatus(){
return politicsStatusService.list();
}
@ApiOperation(value = "获取所有职称")
@GetMapping("/joblevels")
public List<Joblevel> getJoblevels(){
return joblevelService.list();
}
@ApiOperation(value = "获取所有民族")
@GetMapping("/nations")
public List<Nation> getNation(){
return nationService.list();
}
@ApiOperation(value = "获取所有职位")
@GetMapping("/position")
public List<Position> getPosition(){
return positionService.list();
}
@ApiOperation(value = "获取所有部门")
@GetMapping("/department")
public List<Department> getAllDepartment(){
return departmentService.getAllDepartments();
}
@ApiOperation(value = "获取工号")
@GetMapping("/maxWorkID")
public RespBean maxWorkID(){
return employeeService.maxWorkID();
}
@ApiOperation(value = "添加员工")
@PostMapping("/")
public RespBean addEmp(@RequestBody Employee employee){
return employeeService.addEmp(employee);
}
@ApiOperation(value = "更新员工")
@PutMapping("/")
public RespBean updateEmployee(@RequestBody Employee employee){
if (employeeService.updateById(employee)){
return RespBean.success("更新成功");
}
return RespBean.success("更新失败");
}
@ApiOperation(value = "删除员工")
@DeleteMapping("/{id}")
public RespBean deleteEmployee(@PathVariable Integer id){
if (employeeService.removeById(id)){
return RespBean.success("删除成功");
}
return RespBean.success("删除失败");
}
@ApiOperation(value = "导出员工数据")
@GetMapping(value = "/export",produces = "application/octet-stream")
public void exportEmployee(HttpServletResponse response){
List<Employee> list = employeeService.getEmployee(null);
ExportParams Params = new ExportParams("员工表", "员工表", ExcelType.HSSF);
Workbook workbook = ExcelExportUtil.exportExcel(Params,Employee.class,list);
ServletOutputStream out = null;
try {
//以流的方式传出
response.setHeader("content-type","application/octet-stream");
//防止响应乱码
response.setHeader("content-disposition","attachment;filename="+URLEncoder.encode("员工表.xls","UTF-8"));
out=response.getOutputStream();
workbook.write(out);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if (out!=null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@ApiOperation(value = "导入员工数据")
@PostMapping(value = "/import")
public RespBean importEmployee(MultipartFile file){
ImportParams importParams = new ImportParams();
//去掉标题行
importParams.setTitleRows(1);
List<Nation> nationList = nationService.list();
List<PoliticsStatus> politicsStatusList = politicsStatusService.list();
List<Department> departmentList = departmentService.list();
List<Joblevel> joblevelList = joblevelService.list();
List<Position> positionList = positionService.list();
try {
//重写
List<Employee> list = ExcelImportUtil.importExcel(file.getInputStream(), Employee.class, importParams);
list.forEach(employee -> {
//民族id
employee.setNationId(nationList.get(nationList.indexOf(new Nation(employee.getNation().getName()))).getId());
//政治面貌id
employee.setPoliticId(politicsStatusList.get(politicsStatusList.indexOf(new PoliticsStatus(employee.getPoliticsStatus().getName()))).getId());
//部门id
employee.setDepartmentId(departmentList.get(departmentList.indexOf(new Department(employee.getDepartment().getName()))).getId());
//职称id
employee.setJobLevelId(joblevelList.get(joblevelList.indexOf(new Joblevel(employee.getJoblevel().getName()))).getId());
//职位id
employee.setPosId(positionList.get(positionList.indexOf(new Position(employee.getPosition().getName()))).getId());
});
if(employeeService.saveBatch(list)){
return RespBean.success("插入员工成功");
}
} catch (Exception e) {
e.printStackTrace();
}
return RespBean.error("插入员工失败");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Springboot+vue的OA办公系统OAoffer.zip
共544个文件
xml:175个
class:140个
java:137个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 162 浏览量
2024-05-15
13:46:30
上传
评论
收藏 1.64MB ZIP 举报
温馨提示
该项目利用了基于springboot + vue + mysql的开发模式框架实现的课设系统,包括了项目的源码资源、sql文件、相关指引文档等等。 【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【技术】 Java、Python、Node.js、Spring Boot、Django、Express、MySQL、PostgreSQL、MongoDB、React、Angular、Vue、Bootstrap、Material-UI、Redis、Docker、Kubernetes
资源推荐
资源详情
资源评论
收起资源包目录
Springboot+vue的OA办公系统OAoffer.zip (544个子文件)
.browserslistrc 30B
Employee.class 22KB
EmployeeController.class 11KB
SecurityConfig.class 9KB
Admin.class 9KB
Salary.class 9KB
Menu.class 8KB
AdminServiceImpl.class 8KB
EmployeeServiceImpl.class 7KB
CodeGenerator.class 7KB
MailLog.class 6KB
RabbitMqconfig.class 5KB
FastDFSUtils.class 5KB
Swagger2Config.class 5KB
EmployeeRemove.class 5KB
Department.class 5KB
SalaryAdjust.class 5KB
EmployeeEc.class 5KB
PermissController.class 5KB
JwtTokenuntil.class 5KB
Appraise.class 4KB
WebSocketConfig$1.class 4KB
EmployeeTrain.class 4KB
Joblevel.class 4KB
AdminInfoController.class 4KB
SysMsg.class 4KB
Position.class 4KB
CustomFilter.class 4KB
JwtAuthencationTokenFilter.class 4KB
MailTask.class 3KB
Oplog.class 3KB
WebSocketConfig.class 3KB
ChatMsg.class 3KB
CaptchaController.class 3KB
MailReceiver.class 3KB
PositionController.class 3KB
JoblevelController.class 3KB
CustomUrlDecisionManager.class 3KB
RespBean.class 3KB
PoliticsStatus.class 3KB
MenuServiceImpl.class 3KB
Role.class 3KB
AdminRole.class 3KB
Nation.class 3KB
AdminController.class 3KB
MenuRole.class 3KB
SalaryController.class 3KB
AdminLoginParam.class 3KB
LoginController.class 2KB
SalarySobCfgController.class 2KB
DepartmentServiceImpl.class 2KB
RespPageBean.class 2KB
CustomAuthorityDeserializer.class 2KB
SecurityConfig$1.class 2KB
MenuRoleServiceImpl.class 2KB
DepartmentController.class 2KB
RestfulAccessDeniedHandel.class 2KB
RestAuthorizationEntryPoint.class 2KB
RedisConfig.class 2KB
WsController.class 2KB
CaptchaConfig.class 2KB
IAdminService.class 1KB
EmployeeMapper.class 1KB
CodeGenerator$2.class 1KB
DateConverter.class 1KB
MailApplication.class 1KB
ChatController.class 1KB
MenuController.class 1006B
YebApplication.class 935B
AppTest.class 927B
IEmployeeService.class 916B
HelloController.class 902B
MailConstants.class 839B
AdminUtlis.class 799B
PoliticsStatusServiceImpl.class 706B
EmployeeRemoveServiceImpl.class 706B
EmployeeTrainServiceImpl.class 699B
MyBatisPlusConfig.class 697B
SalaryAdjustServiceImpl.class 692B
EmployeeEcServiceImpl.class 678B
AdminRoleServiceImpl.class 671B
AppraiseServiceImpl.class 664B
JoblevelServiceImpl.class 664B
PositionServiceImpl.class 664B
MailLogServiceImpl.class 657B
NationServiceImpl.class 650B
SysMsgServiceImpl.class 650B
SalaryServiceImpl.class 650B
OplogServiceImpl.class 643B
RoleServiceImpl.class 636B
IDepartmentService.class 615B
MenuMapper.class 581B
DepartmentMapper.class 580B
AdminRoleMapper.class 551B
CodeGenerator$1.class 550B
MenuRoleMapper.class 541B
EmployeeRemoveController.class 532B
PoliticsStatusController.class 532B
EmployeeTrainController.class 528B
SalaryAdjustController.class 524B
共 544 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
枫蜜柚子茶
- 粉丝: 6797
- 资源: 5108
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功