| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.controller.params.IsptItemsParams; |
| | | import com.vincent.rsf.server.manager.controller.params.QlyInspectAndItem; |
| | | import com.vincent.rsf.server.manager.entity.QlyIsptItem; |
| | | import com.vincent.rsf.server.manager.service.QlyIsptItemService; |
| | | 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.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "质检明细") |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<QlyIsptItem, BaseParam> pageParam = new PageParam<>(baseParam, QlyIsptItem.class); |
| | | return R.ok().add(qlyIsptItemService.page(pageParam, pageParam.buildWrapper(true))); |
| | | QueryWrapper<QlyIsptItem> queryWrapper = pageParam.buildWrapper(true); |
| | | /**拼接扩展字段*/ |
| | | PageParam<QlyIsptItem, BaseParam> page = qlyIsptItemService.page(pageParam, queryWrapper); |
| | | List<QlyIsptItem> records = page.getRecords(); |
| | | for (QlyIsptItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/5/12 |
| | | * @description: 获取质检信息修改 |
| | | * @version 1.0 |
| | | */ |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @PostMapping("/qlyIsptItem/ispts/page") |
| | | public R getQlyList(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<QlyIsptItem, BaseParam> pageParam = new PageParam<>(baseParam, QlyIsptItem.class); |
| | | QueryWrapper<QlyIsptItem> queryWrapper = pageParam.buildWrapper(true); |
| | | IPage<QlyIsptItem> page = qlyIsptItemService.pageByWrapper(pageParam, queryWrapper); |
| | | List<QlyIsptItem> records = page.getRecords(); |
| | | for (QlyIsptItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @PostMapping("/qlyIsptItem/ispt/result/page") |
| | | public R getIsptResultList(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<QlyIsptItem, BaseParam> pageParam = new PageParam<>(baseParam, QlyIsptItem.class); |
| | | QueryWrapper<QlyIsptItem> queryWrapper = pageParam.buildWrapper(true); |
| | | IPage<QlyIsptItem> page = qlyIsptItemService.pageByIsptResult(pageParam, queryWrapper); |
| | | List<QlyIsptItem> records = page.getRecords(); |
| | | for (QlyIsptItem record : records) { |
| | | if (!Objects.isNull(record.getFieldsIndex())) { |
| | | Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); |
| | | record.setExtendFields(fields); |
| | | } |
| | | } |
| | | page.setRecords(records); |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @PostMapping("/qlyIsptItem/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(qlyIsptItemService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(qlyIsptItemService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @PostMapping({"/qlyIsptItem/many/{ids}", "/qlyIsptItems/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(qlyIsptItemService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(qlyIsptItemService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @GetMapping("/qlyIsptItem/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(qlyIsptItemService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(qlyIsptItemService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:save')") |
| | |
| | | if (!qlyIsptItemService.save(qlyIsptItem)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(qlyIsptItem); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(qlyIsptItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:update')") |
| | |
| | | if (!qlyIsptItemService.updateById(qlyIsptItem)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(qlyIsptItem); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(qlyIsptItem)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:remove')") |
| | |
| | | if (!qlyIsptItemService.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:qlyIsptItem:list')") |
| | |
| | | qlyIsptItemService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getId())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:list')") |
| | | @PostMapping("/qlyIsptItem/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(qlyIsptItemService.list(), QlyIsptItem.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(buildPageRowsUtils.rowsMap(qlyIsptItemService.list()), QlyIsptItem.class), response); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:qlyIsptItem:update')") |
| | |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (qlyIsptItemService.batchUpdate(params)) { |
| | | if (qlyIsptItemService.batchUpdate(params, getLoginUserId())) { |
| | | return R.ok("修改成功!!"); |
| | | } else { |
| | | return R.error("修改失败!!"); |