| | |
| | | import com.vincent.rsf.server.manager.entity.excel.CheckOrderTemplate; |
| | | import com.vincent.rsf.server.manager.service.CheckOrderItemService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.*; |
| | | |
| | | /** |
| | |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<WkOrderItem, BaseParam> pageParam = new PageParam<>(baseParam, WkOrderItem.class); |
| | | QueryWrapper<WkOrderItem> wrapper = pageParam.buildWrapper(true); |
| | | return R.ok().add(checkOrderItemService.page(pageParam, wrapper)); |
| | | PageParam<WkOrderItem, BaseParam> page = checkOrderItemService.page(pageParam, wrapper); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(page)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @PostMapping("/checkItem/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(checkOrderItemService.list()); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(checkOrderItemService.list())); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @PostMapping({"/checkItem/many/{ids}", "/checkItem/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(checkOrderItemService.listByIds(Arrays.asList(ids))); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(checkOrderItemService.listByIds(Arrays.asList(ids)))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @GetMapping("/checkItem/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(checkOrderItemService.getById(id)); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(checkOrderItemService.getById(id))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:save')") |
| | |
| | | if (!checkOrderItemService.save(order)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(order); |
| | | return R.ok("Save Success").add(buildPageRowsUtils.rowsMap(order)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | |
| | | if (!checkOrderItemService.updateById(order)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(order); |
| | | return R.ok("Update Success").add(buildPageRowsUtils.rowsMap(order)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:remove')") |
| | |
| | | if (!checkOrderItemService.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:check:list')") |
| | |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<WkOrderItem> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(WkOrderItem::getAsnCode, condition); |
| | | wrapper.like(WkOrderItem::getOrderCode, condition); |
| | | } |
| | | checkOrderItemService.page(new Page<>(1, 20), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getAsnCode())) |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getOrderCode())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/7/14 |
| | | * @description: 盘点单导出 |
| | | * @version 1.0 |
| | | */ |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @PostMapping("/checkItem/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | List<WkOrderItem> orders = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | orders = checkOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().in(WkOrderItem::getId, map.get("ids"))); |
| | | } else { |
| | | orders = checkOrderItemService.list(); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orders, WkOrderItem.class), response); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 下载模板 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/18 08:17 |
| | | */ |
| | | @PostMapping("/checkItem/template/download") |
| | | @ApiOperation("下载盘点单模板") |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | | public void downloadTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | CheckOrderTemplate template = ExcelUtil.mockData(CheckOrderTemplate.class); |
| | | List<CheckOrderTemplate> list = Arrays.asList(template); |
| | | ExcelUtil.build(ExcelUtil.create(list, CheckOrderTemplate.class, true), response); |
| | | return R.ok().add(buildPageRowsUtils.rowsMap(vos)); |
| | | } |
| | | |
| | | } |