| | |
| | | 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.CommonUtil; |
| | | 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.entity.excel.MatnrsTemplate; |
| | | import com.vincent.rsf.server.manager.service.MatnrService; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping("/matnr/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | // if (!Objects.isNull(map.get("groupId"))) { |
| | | // return R.ok(matnrService.getPages(map)); |
| | | // } else { |
| | | // BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | // PageParam<Matnr, BaseParam> pageParam = new PageParam<>(baseParam, Matnr.class); |
| | | // return R.ok().add(buildPageRowsUtils.rowsMap(matnrService.getMatnrPage(pageParam, map))); |
| | | // } |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Matnr, BaseParam> pageParam = new PageParam<>(baseParam, Matnr.class); |
| | | return R.ok().add(matnrService.getMatnrPage(pageParam)); |
| | | PageParam<Matnr, BaseParam> page = matnrService.getMatnrPage(pageParam, map); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping("/matnr/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(matnrService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(matnrService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping({"/matnr/many/{ids}", "/matnrs/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(matnrService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(matnrService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | |
| | | @OperationLog("Update 物料信息表") |
| | | @PostMapping("/matnr/update") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R update(@RequestBody Map<String, Object> params) { |
| | | public R update(@RequestBody Map<String, Object> params) throws Exception { |
| | | Matnr matnr = JSONObject.parseObject(JSONObject.toJSONString(params), Matnr.class); |
| | | if (Objects.isNull(matnr.getCode())) { |
| | | throw new CoolException("编码不能为空!!"); |
| | |
| | | throw new CoolException("名称不能为空!!"); |
| | | } |
| | | matnr.setUpdateBy(getLoginUserId()); |
| | | if (!matnrService.updateById(matnr)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | |
| | | if (!FieldsUtils.getFieldsSta().isEmpty()) { |
| | | Matnr matnr1 = matnrService.getById(matnr.getId()); |
| | | params.put("fieldsIndex", matnr1.getFieldsIndex()); |
| | | if (!Objects.isNull(matnr1.getFieldsIndex())) { |
| | | params.put("fieldsIndex", matnr1.getFieldsIndex()); |
| | | } else { |
| | | String uuid16 = CommonUtil.randomUUID16(); |
| | | params.put("index", uuid16); |
| | | matnr.setFieldsIndex(uuid16); |
| | | } |
| | | FieldsUtils.updateFieldsValue(params); |
| | | } |
| | | |
| | | return R.ok("Update Success").add(matnr); |
| | | if (!matnrService.updateById(matnr)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(matnr)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:remove')") |
| | |
| | | if (!matnrService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | return R.ok("Delete Success").add(buildPageRowsUtils.rowsMap(ids)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | |
| | | matnrService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getName())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | matnrs = matnrService.list(new LambdaQueryWrapper<Matnr>().in(Matnr::getId, map.get("ids")).eq(Matnr::getStatus, 1)); |
| | | } else { |
| | | matnrs = matnrService.list(new LambdaQueryWrapper<Matnr>().last("limit 1")); |
| | | matnrs = matnrService.list(); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(null, MatnrsTemplate.class, true), response); |
| | | ExcelUtil.build(ExcelUtil.create(matnrs, Matnr.class, false), response); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @ApiOperation("下载物料模板") |
| | | @PostMapping("/matnr/template/download") |
| | | public void download(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(null, MatnrsTemplate.class, true), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(null), MatnrsTemplate.class), response); |
| | | } |
| | | |
| | | |