| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.cal.team.vo.MesCalTeamImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.cal.team.vo.MesCalTeamImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.cal.team.vo.MesCalTeamPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.cal.team.vo.MesCalTeamRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.cal.team.vo.MesCalTeamSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.cal.team.MesCalTeamService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | BeanUtils.toBean(list, MesCalTeamRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得班组导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesCalTeamImportExcelVO> list = Collections.singletonList( |
| | | MesCalTeamImportExcelVO.builder().code("TEAM-A").name("示例班组") |
| | | .calendarType(1).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "班组导入模板.xls", "班组列表", MesCalTeamImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入班组") |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "Excel 文件", required = true), |
| | | @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('mes:cal-team:import')") |
| | | public CommonResult<MesCalTeamImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesCalTeamImportExcelVO> list = ExcelUtils.read(file, MesCalTeamImportExcelVO.class); |
| | | return success(teamService.importTeamList(list, updateSupport)); |
| | | } |
| | | |
| | | } |