|  |  | 
 |  |  | import com.vincent.rsf.server.common.domain.KeyValVo; | 
 |  |  | import com.vincent.rsf.server.common.domain.PageParam; | 
 |  |  | import com.vincent.rsf.server.common.utils.ExcelUtil; | 
 |  |  | import com.vincent.rsf.server.manager.entity.AsnOrderItem; | 
 |  |  | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; | 
 |  |  | import com.vincent.rsf.server.manager.entity.WkOrderItem; | 
 |  |  | 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 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 java.util.*; | 
 |  |  |  | 
 |  |  | 
 |  |  |     private CheckOrderItemService checkOrderItemService; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:list')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:list')") | 
 |  |  |     @PostMapping("/checkItem/page") | 
 |  |  |     public R page(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<AsnOrderItem, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrderItem.class); | 
 |  |  |         QueryWrapper<AsnOrderItem> wrapper = pageParam.buildWrapper(true); | 
 |  |  |         PageParam<WkOrderItem, BaseParam> pageParam = new PageParam<>(baseParam, WkOrderItem.class); | 
 |  |  |         QueryWrapper<WkOrderItem> wrapper = pageParam.buildWrapper(true); | 
 |  |  |         return R.ok().add(checkOrderItemService.page(pageParam, wrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:list')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:list')") | 
 |  |  |     @PostMapping("/checkItem/list") | 
 |  |  |     public R list(@RequestBody Map<String, Object> map) { | 
 |  |  |         return R.ok().add(checkOrderItemService.list()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem: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))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:list')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:list')") | 
 |  |  |     @GetMapping("/checkItem/{id}") | 
 |  |  |     public R get(@PathVariable("id") Long id) { | 
 |  |  |         return R.ok().add(checkOrderItemService.getById(id)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:save')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:save')") | 
 |  |  |     @OperationLog("Create 字典数据集") | 
 |  |  |     @PostMapping("/checkItem/save") | 
 |  |  |     public R save(@RequestBody AsnOrderItem order) { | 
 |  |  |     public R save(@RequestBody WkOrderItem order) { | 
 |  |  |         String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_CHECK_RULE_CODE, order); | 
 |  |  |         if (Objects.isNull(ruleCode)) { | 
 |  |  |             throw new RuntimeException("盘点单号生成失败!!"); | 
 |  |  | 
 |  |  |         return R.ok("Save Success").add(order); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:update')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:update')") | 
 |  |  |     @OperationLog("Update 字典数据集") | 
 |  |  |     @PostMapping("/checkItem/update") | 
 |  |  |     public R update(@RequestBody AsnOrderItem order) { | 
 |  |  |     public R update(@RequestBody WkOrderItem order) { | 
 |  |  |         order.setUpdateTime(null); | 
 |  |  |         order.setUpdateBy(getLoginUserId()); | 
 |  |  |         if (!checkOrderItemService.updateById(order)) { | 
 |  |  | 
 |  |  |         return R.ok("Update Success").add(order); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:remove')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:remove')") | 
 |  |  |     @OperationLog("Delete 字典数据集") | 
 |  |  |     @PostMapping("/checkItem/remove/{ids}") | 
 |  |  |     public R remove(@PathVariable Long[] ids) { | 
 |  |  | 
 |  |  |         return R.ok("Delete Success").add(ids); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem:list')") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:check:list')") | 
 |  |  |     @PostMapping("/checkItem/query") | 
 |  |  |     public R query(@RequestParam(required = false) String condition) { | 
 |  |  |         List<KeyValVo> vos = new ArrayList<>(); | 
 |  |  |         LambdaQueryWrapper<AsnOrderItem> wrapper = new LambdaQueryWrapper<>(); | 
 |  |  |         LambdaQueryWrapper<WkOrderItem> wrapper = new LambdaQueryWrapper<>(); | 
 |  |  |         if (!Cools.isEmpty(condition)) { | 
 |  |  |             wrapper.like(AsnOrderItem::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:checkItem:list')") | 
 |  |  |     @PostMapping("/checkItem/export") | 
 |  |  |     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
 |  |  |         List<AsnOrderItem> orders = new ArrayList<>(); | 
 |  |  |         if (!Objects.isNull(map.get("ids"))) { | 
 |  |  |             orders = checkOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getId, map.get("ids"))); | 
 |  |  |         } else { | 
 |  |  |             orders = checkOrderItemService.list(); | 
 |  |  |         } | 
 |  |  |         ExcelUtil.build(ExcelUtil.create(orders, AsnOrderItem.class), response); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description 下载模板 | 
 |  |  |      * @param | 
 |  |  |      * @return | 
 |  |  |      * @time 2025/4/18 08:17 | 
 |  |  |      */ | 
 |  |  |     @PostMapping("/checkItem/template/download") | 
 |  |  |     @ApiOperation("下载盘点单模板") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:checkItem: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); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |