| | |
| | | package org.springblade.mdm.basesetting.producedivision.controller; |
| | | |
| | | import com.alibaba.excel.util.StringUtils; |
| | | 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.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.oss.OssTemplate; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.InputStream; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/producedivision") |
| | | @Tag(name = "主制分工表", description = "主制分工表") |
| | | public class QinzheFgbController { |
| | | |
| | | @Autowired |
| | | private ParamService paramService; |
| | | @Autowired |
| | | private QinzheFgbService qinzheFgbService; |
| | | |
| | | @Autowired |
| | | private OssTemplate ossTemplate; |
| | | /** |
| | | * 分页 |
| | | */ |
| | |
| | | public R<IPage<QinzheFgb>> page(String ljh,String zggy, Query query) { |
| | | return R.data(qinzheFgbService.lambdaQuery().like(StringUtils.isNotBlank(ljh), QinzheFgb::getLjh,ljh).like(StringUtils.isNotBlank(zggy), QinzheFgb::getZggy,zggy).page(Condition.getPage(query))); |
| | | } |
| | | @Operation(summary = "修改勤哲", description = "修改勤哲") |
| | | @PostMapping("/update-qz") |
| | | public R<Void> update(@RequestBody QinzheFgb fgb) { |
| | | try { |
| | | qinzheFgbService.updateFgb(fgb); |
| | | return R.success(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Operation(summary = "删除勤哲", description = "删除勤哲") |
| | | @PostMapping("/remove-qz") |
| | | public R<Void> remove(@RequestParam String ljhs) { |
| | | try { |
| | | |
| | | List<String> ljhlist = Func.toStrList(",",ljhs); |
| | | qinzheFgbService.lambdaUpdate().in(QinzheFgb::getLjh,ljhlist).remove(); |
| | | return R.success(); |
| | | } catch (Exception e) { |
| | | log.error("删除异常",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "导入勤哲分工表", description = "导入勤哲分工表") |
| | | @PostMapping("/import-qinzhe") |
| | | public R<ImportResult> importQinzheFgb(@RequestParam MultipartFile file) { |
| | | public R<Void> importQinzheFgb(@RequestParam MultipartFile file) { |
| | | try { |
| | | qinzheFgbService.importFgb(file); |
| | | return R.success("导入成功"); |
| | |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "下载勤哲分工表导入模板", description = "下载勤哲分工表导入模板") |
| | | @GetMapping("/download-template-qz") |
| | | public void downloadTemplate(HttpServletResponse response) { |
| | | String PARAMKEY = "QINZHE_TEMPLATE"; |
| | | |
| | | try { |
| | | String filename = "qinzhetemplate.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); |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "勤哲零件号搜索建议", description = "勤哲零件号搜索建议") |
| | | @GetMapping("/select-data") |
| | | public R<List<QinzheFgb>> selectData(@RequestParam String drawingNo) { |
| | | if(StringUtils.isBlank(drawingNo)){ |
| | | return R.data(Collections.emptyList()); |
| | | } |
| | | try { |
| | | String ljh = drawingNo.trim(); |
| | | return R.data(qinzheFgbService.lambdaQuery().likeRight(QinzheFgb::getLjh,ljh).last("LIMIT 20").list()); |
| | | } catch (Exception e) { |
| | | log.error("获取零件号异常",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |