| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.oss.OssTemplate; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.producedivision.service.ProduceDivisionService; |
| | | import org.springblade.mdm.basesetting.producedivision.vo.ImportResult; |
| | | import org.springblade.mdm.basesetting.producedivision.vo.ProduceDivisionVO; |
| | | import org.springblade.mdm.basesetting.producedivision.vo.ProduceDivisionViewVO; |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private ProduceDivisionService service; |
| | | |
| | | @Autowired |
| | | private ParamService paramService; |
| | | @Autowired |
| | | private OssTemplate ossTemplate; |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @Operation(summary = "新增", description = "主制计划表") |
| | | public R<Boolean> save(@RequestBody ProduceDivisionVO vo) { |
| | | try { |
| | | service.saveDivision(vo); |
| | | return R.success(); |
| | | }catch(Exception e) { |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | |
| | | service.savePlan(vo); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping("/update") |
| | | public R<Boolean> update(@RequestBody ProduceDivisionVO vo) { |
| | | |
| | | return R.<Boolean>status(service.updatePlan(vo)); |
| | | return R.<Boolean>status(service.updateDivision(vo)); |
| | | } |
| | | |
| | | /** |
| | |
| | | IPage<ProduceDivisionViewVO> pages = service.pageQuery(name,query); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | @Operation(summary = "导入分工表", description = "导入分工表") |
| | | @PostMapping("/import-division") |
| | | public R<ImportResult> importDivision(@RequestParam MultipartFile file) { |
| | | try { |
| | | return R.data(service.importDivision(file)); |
| | | }catch(Exception e) { |
| | | log.error("导入异常",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | @Operation(summary = "下载分工表导入模板", description = "下载分工表导入模板") |
| | | @GetMapping("/download-template") |
| | | public void downloadTemplate(HttpServletResponse response) { |
| | | String PARAMKEY = "DIVISION_TEMPLATE"; |
| | | |
| | | try { |
| | | String filename = "divisiontemplate.xlsx"; |
| | | response.setHeader("Content-Disposition", "attachment; filename="+filename); |
| | | response.setContentType("application/octet-stream"); |
| | | String ossName = paramService.getParamValue(PARAMKEY,""); |
| | | try(InputStream ins = ossTemplate.statFileStream(ossName);){ |
| | | IOUtils.copy(ins,response.getOutputStream()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("导出分工表模板异常", e); |
| | | } |
| | | } |
| | | |
| | | } |