| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.domain.PageResult; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | |
| | | import com.vincent.rsf.server.manager.entity.Matnr; |
| | | import com.vincent.rsf.server.manager.service.MatnrService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @Api(tags = "物料表接口") |
| | | public class MatnrController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @ApiOperation(value = "获取分类物料明细列表") |
| | | @PostMapping("/matnr/group") |
| | | public R getGroupMatnrs(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Matnr, BaseParam> pageParam = new PageParam<>(baseParam, Matnr.class); |
| | | LambdaQueryWrapper<Matnr> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | wrapper.like(Matnr::getName, map.get("condition")); |
| | | } |
| | | if (Cools.isEmpty(map.get("groupId"))) { |
| | | throw new CoolException("分类ID不能为空!!"); |
| | | } |
| | | wrapper.eq(Matnr::getGroupId, map.get("groupId")); |
| | | Page<Matnr> matnrPage = matnrService.page(new Page<>(1, 30), wrapper); |
| | | return R.ok(new PageResult().setRecords(matnrPage.getRecords()).setTotal(matnrPage.getTotal())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping("/matnr/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(matnrService.list(), Matnr.class), response); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:save')") |
| | | @ApiOperation(value = "excel表格导入物料信息") |
| | | @PostMapping("/matnr/import") |
| | | public R listImport(@RequestParam MultipartFile file) throws Exception { |
| | | if (Objects.isNull(file)) { |
| | | throw new CoolException("文件不能为空!!"); |
| | | } |
| | | matnrService.importExcels(file); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |