| | |
| | | @RequestMapping(value = "/locDetl/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(locDetlService.selectById(String.valueOf(id))); |
| | | // asr_loc_detl 表没有 id 主键,使用 loc_no 查询 |
| | | // 注意:一个 loc_no 可能对应多条记录,返回第一条 |
| | | List<LocDetl> list = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", id).last("limit 1")); |
| | | if (!list.isEmpty()) { |
| | | return R.ok(list.get(0)); |
| | | } |
| | | // 返回 null 而不是错误,避免前端解析失败 |
| | | return R.ok(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/auth") |
| | |
| | | @RequestMapping(value = "/locDetl/update/auth") |
| | | @ManagerAuth(memo = "库位明细修改") |
| | | public R update(LocDetl locDetl) { |
| | | if (Cools.isEmpty(locDetl) || null == locDetl.getMatnr()) { |
| | | return R.error(); |
| | | if (Cools.isEmpty(locDetl) || null == locDetl.getMatnr() || Cools.isEmpty(locDetl.getLocNo())) { |
| | | return R.error("参数不完整,需要 locNo 和 matnr"); |
| | | } |
| | | locDetl.setModiUser(getUserId()); |
| | | locDetl.setModiTime(new Date()); |
| | | locDetlService.updateById(locDetl); |
| | | return R.ok(); |
| | | |
| | | // asr_loc_detl 表没有 id 主键,使用 EntityWrapper 根据 loc_no 和 matnr 更新 |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_no", locDetl.getLocNo()); |
| | | wrapper.eq("matnr", locDetl.getMatnr()); |
| | | |
| | | // 如果有批次信息,也加入条件 |
| | | if (!Cools.isEmpty(locDetl.getBatch())) { |
| | | wrapper.eq("batch", locDetl.getBatch()); |
| | | } else { |
| | | wrapper.andNew("(batch IS NULL OR batch = '')"); |
| | | } |
| | | |
| | | boolean result = locDetlService.update(locDetl, wrapper); |
| | | if (result) { |
| | | return R.ok(); |
| | | } |
| | | return R.error("更新失败,未找到匹配的记录"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/delete/auth") |