|
|
@@ -0,0 +1,324 @@
|
|
|
+package org.jeecg.modules.oa.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.oa.entity.Enrollment;
|
|
|
+import org.jeecg.modules.oa.entity.EnrollmentContact;
|
|
|
+import org.jeecg.modules.oa.entity.EnrollmentEdu;
|
|
|
+import org.jeecg.modules.oa.entity.EnrollmentJob;
|
|
|
+import org.jeecg.modules.oa.service.IEnrollmentContactService;
|
|
|
+import org.jeecg.modules.oa.service.IEnrollmentEduService;
|
|
|
+import org.jeecg.modules.oa.service.IEnrollmentJobService;
|
|
|
+import org.jeecg.modules.oa.service.IEnrollmentService;
|
|
|
+import org.jeecg.modules.oa.vo.EnrollmentPage;
|
|
|
+import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 入职登记
|
|
|
+ * @Author: jeecg-boot
|
|
|
+ * @Date: 2023-05-26
|
|
|
+ * @Version: V1.0
|
|
|
+ */
|
|
|
+@Api(tags="入职登记")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/oa/enrollment")
|
|
|
+@Slf4j
|
|
|
+public class EnrollmentController {
|
|
|
+ @Autowired
|
|
|
+ private IEnrollmentService enrollmentService;
|
|
|
+ @Autowired
|
|
|
+ private IEnrollmentJobService enrollmentJobService;
|
|
|
+ @Autowired
|
|
|
+ private IEnrollmentContactService enrollmentContactService;
|
|
|
+ @Autowired
|
|
|
+ private IEnrollmentEduService enrollmentEduService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param enrollment
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-分页列表查询")
|
|
|
+ @ApiOperation(value="入职登记-分页列表查询", notes="入职登记-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(Enrollment enrollment,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ String username = enrollment.getUsername();
|
|
|
+ String realname = enrollment.getRealname();
|
|
|
+ String operator = enrollment.getOperator();
|
|
|
+ enrollment.setUsername(null);
|
|
|
+ enrollment.setRealname(null);
|
|
|
+ enrollment.setOperator(null);
|
|
|
+ QueryWrapper<Enrollment> queryWrapper = QueryGenerator.initQueryWrapper(enrollment, req.getParameterMap());
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(username),"username",username);
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(realname),"realname",realname);
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(operator),"operator",operator);
|
|
|
+ Page<Enrollment> page = new Page<Enrollment>(pageNo, pageSize);
|
|
|
+ IPage<Enrollment> pageList = enrollmentService.page(page, queryWrapper);
|
|
|
+ return Result.ok(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param enrollmentPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-添加")
|
|
|
+ @ApiOperation(value="入职登记-添加", notes="入职登记-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<?> add(@RequestBody EnrollmentPage enrollmentPage) {
|
|
|
+ Enrollment enrollment = new Enrollment();
|
|
|
+ BeanUtils.copyProperties(enrollmentPage, enrollment);
|
|
|
+ enrollmentService.saveMain(enrollment, enrollmentPage.getEnrollmentJobList(),enrollmentPage.getEnrollmentContactList(),enrollmentPage.getEnrollmentEduList());
|
|
|
+ return Result.ok("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param enrollmentPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-编辑")
|
|
|
+ @ApiOperation(value="入职登记-编辑", notes="入职登记-编辑")
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
+ public Result<?> edit(@RequestBody EnrollmentPage enrollmentPage) {
|
|
|
+ Enrollment enrollment = new Enrollment();
|
|
|
+ BeanUtils.copyProperties(enrollmentPage, enrollment);
|
|
|
+ Enrollment enrollmentEntity = enrollmentService.getById(enrollment.getId());
|
|
|
+ if(enrollmentEntity==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ enrollmentService.updateMain(enrollment, enrollmentPage.getEnrollmentJobList(),enrollmentPage.getEnrollmentContactList(),enrollmentPage.getEnrollmentEduList());
|
|
|
+ return Result.ok("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-通过id删除")
|
|
|
+ @ApiOperation(value="入职登记-通过id删除", notes="入职登记-通过id删除")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ enrollmentService.delMain(id);
|
|
|
+ return Result.ok("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-批量删除")
|
|
|
+ @ApiOperation(value="入职登记-批量删除", notes="入职登记-批量删除")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ this.enrollmentService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.ok("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-通过id查询")
|
|
|
+ @ApiOperation(value="入职登记-通过id查询", notes="入职登记-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Enrollment enrollment = enrollmentService.getById(id);
|
|
|
+ if(enrollment==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ return Result.ok(enrollment);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "工作经历集合-通过id查询")
|
|
|
+ @ApiOperation(value="工作经历集合-通过id查询", notes="工作经历-通过id查询")
|
|
|
+ @GetMapping(value = "/queryEnrollmentJobByMainId")
|
|
|
+ public Result<?> queryEnrollmentJobListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<EnrollmentJob> enrollmentJobList = enrollmentJobService.selectByMainId(id);
|
|
|
+ return Result.ok(enrollmentJobList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "联系人集合-通过id查询")
|
|
|
+ @ApiOperation(value="联系人集合-通过id查询", notes="联系人-通过id查询")
|
|
|
+ @GetMapping(value = "/queryEnrollmentContactByMainId")
|
|
|
+ public Result<?> queryEnrollmentContactListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<EnrollmentContact> enrollmentContactList = enrollmentContactService.selectByMainId(id);
|
|
|
+ return Result.ok(enrollmentContactList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "学习经历集合-通过id查询")
|
|
|
+ @ApiOperation(value="学习经历集合-通过id查询", notes="学习经历-通过id查询")
|
|
|
+ @GetMapping(value = "/queryEnrollmentEduByMainId")
|
|
|
+ public Result<?> queryEnrollmentEduListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<EnrollmentEdu> enrollmentEduList = enrollmentEduService.selectByMainId(id);
|
|
|
+ return Result.ok(enrollmentEduList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param enrollment
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, Enrollment enrollment) {
|
|
|
+ // Step.1 组装查询条件查询数据
|
|
|
+ QueryWrapper<Enrollment> queryWrapper = QueryGenerator.initQueryWrapper(enrollment, request.getParameterMap());
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ //Step.2 获取导出数据
|
|
|
+ List<Enrollment> queryList = enrollmentService.list(queryWrapper);
|
|
|
+ // 过滤选中数据
|
|
|
+ String selections = request.getParameter("selections");
|
|
|
+ List<Enrollment> enrollmentList = new ArrayList<Enrollment>();
|
|
|
+ if(oConvertUtils.isEmpty(selections)) {
|
|
|
+ enrollmentList = queryList;
|
|
|
+ }else {
|
|
|
+ List<String> selectionList = Arrays.asList(selections.split(","));
|
|
|
+ enrollmentList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step.3 组装pageList
|
|
|
+ List<EnrollmentPage> pageList = new ArrayList<EnrollmentPage>();
|
|
|
+ for (Enrollment main : enrollmentList) {
|
|
|
+ EnrollmentPage vo = new EnrollmentPage();
|
|
|
+ BeanUtils.copyProperties(main, vo);
|
|
|
+ List<EnrollmentJob> enrollmentJobList = enrollmentJobService.selectByMainId(main.getId());
|
|
|
+ vo.setEnrollmentJobList(enrollmentJobList);
|
|
|
+ List<EnrollmentContact> enrollmentContactList = enrollmentContactService.selectByMainId(main.getId());
|
|
|
+ vo.setEnrollmentContactList(enrollmentContactList);
|
|
|
+ List<EnrollmentEdu> enrollmentEduList = enrollmentEduService.selectByMainId(main.getId());
|
|
|
+ vo.setEnrollmentEduList(enrollmentEduList);
|
|
|
+ pageList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step.4 AutoPoi 导出Excel
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "入职登记列表");
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, EnrollmentPage.class);
|
|
|
+ mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("入职登记数据", "导出人:"+sysUser.getRealname(), "入职登记"));
|
|
|
+ mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
+ Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
+ for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
+ MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
+ ImportParams params = new ImportParams();
|
|
|
+ params.setTitleRows(2);
|
|
|
+ params.setHeadRows(1);
|
|
|
+ params.setNeedSave(true);
|
|
|
+ try {
|
|
|
+ List<EnrollmentPage> list = ExcelImportUtil.importExcel(file.getInputStream(), EnrollmentPage.class, params);
|
|
|
+ for (EnrollmentPage page : list) {
|
|
|
+ Enrollment po = new Enrollment();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ enrollmentService.saveMain(po, page.getEnrollmentJobList(),page.getEnrollmentContactList(),page.getEnrollmentEduList());
|
|
|
+ }
|
|
|
+ return Result.ok("文件导入成功!数据行数:" + list.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ return Result.error("文件导入失败:"+e.getMessage());
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ file.getInputStream().close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.ok("文件导入失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id提交
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "入职登记-通过id提交")
|
|
|
+ @ApiOperation(value="入职登记-通过id提交", notes="入职登记-通过id提交")
|
|
|
+ @PutMapping(value = "/submit")
|
|
|
+ public Result<?> submit(@RequestBody JSONObject jsonObject) {
|
|
|
+ String id = jsonObject.getString("id");
|
|
|
+ try {
|
|
|
+ enrollmentService.submit(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return Result.ok("提交成功!");
|
|
|
+ }
|
|
|
+}
|