package cn.fw.morax.server.controller.erp; import cn.fw.common.exception.BusinessException; import cn.fw.common.page.AppPage; import cn.fw.common.web.annotation.ControllerMethod; import cn.fw.common.web.auth.LoginAuthBean; import cn.fw.common.web.auth.annotation.CurrentUser; import cn.fw.data.base.domain.common.Message; import cn.fw.morax.common.utils.PublicUtil; import cn.fw.morax.domain.db.eval.EvalIndicatorImportDetail; import cn.fw.morax.domain.dto.query.EvalIndicatorImportQueryDTO; import cn.fw.morax.domain.vo.eval.*; import cn.fw.morax.domain.vo.salary.StaffPersonTaxVO; import cn.fw.morax.service.biz.eval.EvalIndicatorBizService; import cn.fw.morax.service.biz.eval.EvalIndicatorReportService; import cn.fw.security.auth.client.annotation.Authorization; import cn.fw.security.auth.client.annotation.IgnoreAuth; import cn.fw.security.auth.client.enums.AuthType; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import java.util.List; import static cn.fw.common.web.util.ResultBuilder.success; /** * @author jiangchao * @des: 导入考评指标控制器 * @date 2023/2/8 16:57 */ @Slf4j @RequiredArgsConstructor @Authorization(AuthType.ERP) @Validated @IgnoreAuth @RestController @RequestMapping("/erp/eval-indicator") public class EvalIndicatorController { private final EvalIndicatorReportService evalIndicatorReportService; private final EvalIndicatorBizService evalIndicatorBizService; /** * 考评指标 * * @return */ @IgnoreAuth @GetMapping("/indicators") @ControllerMethod("考评指标") public Message> getEvalIndicators() { return success(evalIndicatorBizService.getEvalIndicators()); } /** * 导入记录分页查询 * * @return */ @IgnoreAuth @GetMapping("/import-page") @ControllerMethod("导入记录分页查询") public Message> importPage(EvalIndicatorImportQueryDTO dto) { return success(evalIndicatorReportService.importPage(dto)); } /** * 导入记录详情查询 * * @return */ @IgnoreAuth @GetMapping("/import-detail") @ControllerMethod("导入记录详情查询") public Message> importDetail(@NotNull(message = "导入记录id不能为空") Long id, Boolean querySuccess) { return success(evalIndicatorReportService.importDetail(id, querySuccess)); } /** * 人员模板文件 * * @return */ @IgnoreAuth @GetMapping("/staff/template-file") @ControllerMethod("人员模板文件") public Message staffTemplateFile(HttpServletRequest request, HttpServletResponse response) { evalIndicatorReportService.staffTemplateFile(request, response); return success(); } /** * 门店模板文件 * * @return */ @IgnoreAuth @GetMapping("/shop/template-file") @ControllerMethod("门店模板文件") public Message shopTemplateFile(HttpServletRequest request, HttpServletResponse response) { evalIndicatorReportService.shopTemplateFile(request, response); return success(); } /** * 上传人员指标 * * @return */ @IgnoreAuth @PostMapping("/analysis-staff") @ControllerMethod("上传人员指标") public Message analysisStaffExcel(@RequestParam("file") MultipartFile file, @CurrentUser LoginAuthBean user) { if (file.isEmpty()) { throw new BusinessException("请上传文件"); } return success(evalIndicatorReportService.uploadStaffIndicator(file, user)); } /** * 上传门店指标 * * @return */ @IgnoreAuth @PostMapping("/analysis-shop") @ControllerMethod("上传门店指标") public Message uploadShopIndicator(@RequestParam("file") MultipartFile file, @CurrentUser LoginAuthBean user) { if (file.isEmpty()) { throw new BusinessException("请上传文件"); } evalIndicatorReportService.uploadShopIndicator(file, user); return success(); } /** * 保存上传人员数据 * * @return */ @GetMapping("/save-import") @ControllerMethod("保存上传人员数据") public Message uploadStaffIndicator(String key) { if (PublicUtil.isEmpty(key)) { throw new BusinessException("参数错误"); } evalIndicatorReportService.saveImportIndicator(key); return success(); } }