| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.BomImportDto; |
| | | import com.ruoyi.production.dto.ProductBomDto; |
| | | import com.ruoyi.production.dto.ProductProcessDto; |
| | | import com.ruoyi.production.pojo.ProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductBom; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.pojo.ProductProcessRoute; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProcessRouteService; |
| | | import com.ruoyi.production.service.ProductBomService; |
| | | import com.ruoyi.production.service.ProductProcessService; |
| | | import com.ruoyi.production.service.ProductProcessRouteService; |
| | | import com.ruoyi.production.service.ProductStructureService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/productBom") |
| | | @Api(tags = "BOM") |
| | | public class ProductBomController { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private ProcessRouteService processRouteService; |
| | | |
| | | @Autowired |
| | | private ProductProcessRouteService productProcessRouteService; |
| | | |
| | | @Autowired |
| | | private ProductStructureService productStructureService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Log(title = "BOM-分页查询", businessType = BusinessType.OTHER) |
| | |
| | | @ApiModelProperty("新增BOM") |
| | | @PostMapping("/add") |
| | | @Log(title = "新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult add( @RequestBody ProductBom productBom) { |
| | | public AjaxResult add(@RequestBody ProductBom productBom) { |
| | | return productBomService.add(productBom); |
| | | } |
| | | |
| | |
| | | @Log(title = "删除", businessType = BusinessType.DELETE) |
| | | public AjaxResult batchDelete(@RequestBody List<Integer> ids) { |
| | | List<ProcessRoute> list = processRouteService.list(Wrappers.<ProcessRoute>lambdaQuery().in(ProcessRoute::getBomId, ids)); |
| | | if (list.size()>0){ |
| | | List<ProductProcessRoute> list2 = productProcessRouteService.list(Wrappers.<ProductProcessRoute>lambdaQuery().in(ProductProcessRoute::getBomId, ids)); |
| | | if (list.size() > 0 || list2.size() > 0) { |
| | | return AjaxResult.error("该BOM已经存在对应的工艺路线,无法进行删除"); |
| | | } |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return AjaxResult.error("请选择至少一条数据"); |
| | | } |
| | | //删除bom子表 |
| | | productStructureService.remove(Wrappers.<ProductStructure>lambdaQuery().in(ProductStructure::getBomId, ids)); |
| | | return AjaxResult.success(productBomService.removeBatchByIds(ids)); |
| | | } |
| | | |
| | |
| | | return AjaxResult.success(productBoms); |
| | | } |
| | | |
| | | @PostMapping("uploadBom") |
| | | @PreAuthorize("@ss.hasPermi('product:bom:import')") |
| | | @Log(title = "根据Excel导入BOM", businessType = BusinessType.IMPORT) |
| | | @ApiOperation("根据Excel导入BOM") |
| | | public AjaxResult uploadBom(@RequestParam("file") MultipartFile file) { |
| | | return productBomService.uploadBom(file); |
| | | } |
| | | |
| | | @PostMapping("exportBom") |
| | | @PreAuthorize("@ss.hasPermi('product:bom:export')") |
| | | @ApiOperation("导出BOM文件") |
| | | @Log(title = "导出BOM文件", businessType = BusinessType.EXPORT) |
| | | public void exportBom(HttpServletResponse response, @RequestParam Integer bomId) { |
| | | productBomService.exportBom(response, bomId); |
| | | } |
| | | |
| | | @GetMapping("/downloadTemplate") |
| | | @Log(title = "下载BOM导入模板", businessType = BusinessType.EXPORT) |
| | | @ApiOperation("下载BOM导入模板") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil<BomImportDto> excelUtil = new ExcelUtil<>(BomImportDto.class); |
| | | excelUtil.importTemplateExcel(response, "BOM导入模板"); |
| | | } |
| | | |
| | | } |