evo-Financial-pc/evo-admin/src/main/java/com/evo/system/controller/SysStaffController.java

207 lines
6.8 KiB
Java

package com.evo.system.controller;
import com.evo.system.domain.vo.StaffNameDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import javax.annotation.Resource;
import com.evo.system.service.ISysStaffService;
import org.springframework.web.bind.annotation.RequestBody;
import com.evo.attendance.domain.vo.RzSalaryVo;
import com.evo.common.annotation.Log;
import com.evo.common.annotation.RepeatSubmit;
import com.evo.common.core.controller.BaseController;
import com.evo.common.core.domain.AjaxResult;
import com.evo.common.core.page.TableDataInfo;
import com.evo.common.enums.BusinessType;
import com.evo.common.utils.poi.ExcelUtil;
import com.evo.system.domain.SysStaff;
import com.evo.system.domain.vo.SysStaffVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 员工管理Controller
*
* @author evo
* @date 2024-11-21
*/
@RestController
@RequestMapping("/system/staff")
public class SysStaffController extends BaseController
{
@Resource
private ISysStaffService sysStaffService;
@PostMapping("/checkName")
public AjaxResult checkStaffName(@RequestBody StaffNameDTO dto) {
boolean repeat = sysStaffService.checkNameRepeat(dto.getId(), dto.getName());
return AjaxResult.success(repeat);
}
/**
* 查询员工管理列表
*/
@PreAuthorize("@ss.hasPermi('system:staff:list')")
@GetMapping("/list")
public TableDataInfo list(SysStaff sysStaff)
{
startPage();
List<SysStaff> list = sysStaffService.selectSysStaffList(sysStaff);
return getDataTable(list);
}
/**
* 导出员工管理列表
*/
@PreAuthorize("@ss.hasPermi('system:staff:export')")
@Log(title = "员工管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysStaff sysStaff)
{
sysStaffService.exportInfo(response, sysStaff);
}
/**
* 导出员工详情
*/
@PreAuthorize("@ss.hasPermi('system:staff:exportDetail')")
@PostMapping("/exportDetail")
public void exportDetail(HttpServletResponse response, SysStaff sysStaff)
{
sysStaffService.exportInfo(response, sysStaff);
}
/**
* 获取员工管理详细信息
*/
@PreAuthorize("@ss.hasPermi('system:staff:query')")
@GetMapping(value = "/{userId}")
public AjaxResult getInfo(@PathVariable("userId") Long userId)
{
return success(sysStaffService.selectSysStaffByUserId(userId));
}
/**
* 新增员工管理
*/
@PreAuthorize("@ss.hasPermi('system:staff:add')")
@Log(title = "员工管理", businessType = BusinessType.INSERT)
@PostMapping
@RepeatSubmit
public AjaxResult add(@RequestBody SysStaff sysStaff)
{
return sysStaffService.insertSysStaff(sysStaff);
}
/**
* 修改员工管理
*/
@PreAuthorize("@ss.hasPermi('system:staff:edit')")
@Log(title = "员工管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysStaff sysStaff)
{
return sysStaffService.updateSysStaff(sysStaff);
}
/**
* 删除员工管理
*/
@PreAuthorize("@ss.hasPermi('system:staff:remove')")
@Log(title = "员工管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userId}")
public AjaxResult remove(@PathVariable Long userId)
{
SysStaff sysStaff = sysStaffService.selectSysStaffByUserId(userId);
if(!"-1".equals(sysStaff.getStatus())){
return AjaxResult.error("没有离职的员工不能删除!!");
}
return toAjax(sysStaffService.deleteSysStaffByUserId(userId));
}
/**
* 查询所有在职员工
* @return
*/
@GetMapping("/listStaffAll")
public List<SysStaff> listStaffAll()
{
List<SysStaff> list = sysStaffService.selectSysStaffListAll();
return list;
}
/**
* 上传五险一金信息文件
*/
@PreAuthorize("@ss.hasPermi('system:staff:importFund')")
@PostMapping("/uploadAccumulationFund")
public AjaxResult uploadAccumulationFund(@RequestParam("file") MultipartFile filePath) {
return sysStaffService.uploadAccumulationFund(filePath);
}
/**
* 模板导出
* @param response
*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<SysStaffVo> util = new ExcelUtil<SysStaffVo>(SysStaffVo.class);
util.importTemplateExcel(response, "员工信息");
}
/**
* 数据导入
* @param file
* @return
* @throws Exception
*/
@PreAuthorize("@ss.hasPermi('system:staff:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file) throws Exception
{
ExcelUtil<SysStaffVo> util = new ExcelUtil<SysStaffVo>(SysStaffVo.class);
List<SysStaffVo> staffList = util.importExcel(file.getInputStream());
return sysStaffService.importStaff(staffList);
}
/**
* 根据部门查询在职员工
* @return
*/
@GetMapping("/listStaffByDept/{dept}")
public List<SysStaff> listStaffByDept(@PathVariable("dept") Long dept)
{
List<SysStaff> list = sysStaffService.queryysStaffByDeptId(dept);
return list;
}
/**
* 导入销售提成
*/
@PreAuthorize("@ss.hasPermi('system:staff:importSalesCommissions')")
@Log(title = "导入销售提成", businessType = BusinessType.IMPORT)
@PostMapping("/importSalesCommissions")
public AjaxResult importSalesCommissions(MultipartFile file) throws Exception
{
ExcelUtil<RzSalaryVo> util = new ExcelUtil<>(RzSalaryVo.class);
List<RzSalaryVo> attendanceList = util.importExcel(file.getInputStream());
return success(sysStaffService.importSalesCommissions(attendanceList));
}
/**
* 离职员工重新入职
*/
@PreAuthorize("@ss.hasPermi('system:staff:reEmployment')")
@Log(title = "员工管理-离职员工重新入职", businessType = BusinessType.IMPORT)
@PostMapping("/reEmployment/{userId}")
public AjaxResult reEmployment(@PathVariable Long userId) throws Exception
{
return sysStaffService.reEmployment(userId);
}
// @Log(title = "员工管理-离职员工重新入职", businessType = BusinessType.OTHER)
@GetMapping("/tree/getDingUserId")
public AjaxResult getDingUserId(@RequestParam("userName") String userName) throws Exception
{
return sysStaffService.getDingUserId(userName);
}
}