| | |
| | | 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.manager.entity.WaitPakinItemLog; |
| | | import com.vincent.rsf.server.manager.entity.WaitPakinLog; |
| | | import com.vincent.rsf.server.manager.service.WaitPakinItemLogService; |
| | | import com.vincent.rsf.server.manager.service.WaitPakinLogService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | public class WaitPakinLogController extends BaseController { |
| | | |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | @Autowired |
| | | private WaitPakinItemLogService waitPakinItemLogService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:list')") |
| | | @PostMapping("/waitPakinLog/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<WaitPakinLog, BaseParam> pageParam = new PageParam<>(baseParam, WaitPakinLog.class); |
| | | return R.ok().add(waitPakinLogService.page(pageParam, pageParam.buildWrapper(true))); |
| | | Page<WaitPakinLog> page = waitPakinLogService.page(pageParam, pageParam.buildWrapper(true)); |
| | | fillAsnCodesForLog(page.getRecords()); |
| | | return R.ok().add(page); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:list')") |
| | | @PostMapping("/waitPakinLog/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(waitPakinLogService.list()); |
| | | List<WaitPakinLog> list = waitPakinLogService.list(); |
| | | fillAsnCodesForLog(list); |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:list')") |
| | | @PostMapping({"/waitPakinLog/many/{ids}", "/waitPakinLogs/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(waitPakinLogService.listByIds(Arrays.asList(ids))); |
| | | List<WaitPakinLog> list = waitPakinLogService.listByIds(Arrays.asList(ids)); |
| | | fillAsnCodesForLog(list); |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:list')") |
| | | @GetMapping("/waitPakinLog/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(waitPakinLogService.getById(id)); |
| | | WaitPakinLog one = waitPakinLogService.getById(id); |
| | | if (one != null) { |
| | | fillAsnCodesForLog(Collections.singletonList(one)); |
| | | } |
| | | return R.ok().add(one); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:save')") |
| | |
| | | @PreAuthorize("hasAuthority('manager:waitPakinLog:list')") |
| | | @PostMapping("/waitPakinLog/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(waitPakinLogService.list(), WaitPakinLog.class), response); |
| | | List<WaitPakinLog> list = waitPakinLogService.list(); |
| | | fillAsnCodesForLog(list); |
| | | ExcelUtil.build(ExcelUtil.create(list, WaitPakinLog.class), response); |
| | | } |
| | | |
| | | /** |
| | | * 根据组托历史明细填充主档的关联入库通知单号(asnCodes),与组托通知档保持一致 |
| | | */ |
| | | private void fillAsnCodesForLog(List<WaitPakinLog> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> logIds = list.stream().map(WaitPakinLog::getId).collect(Collectors.toList()); |
| | | List<WaitPakinItemLog> items = waitPakinItemLogService.list( |
| | | new LambdaQueryWrapper<WaitPakinItemLog>() |
| | | .in(WaitPakinItemLog::getLogId, logIds) |
| | | .select(WaitPakinItemLog::getLogId, WaitPakinItemLog::getAsnCode)); |
| | | Map<Long, String> asnCodesByLogId = logIds.stream().collect(Collectors.toMap( |
| | | logId -> logId, |
| | | logId -> items.stream() |
| | | .filter(i -> logId.equals(i.getLogId()) && i.getAsnCode() != null && !i.getAsnCode().trim().isEmpty()) |
| | | .map(WaitPakinItemLog::getAsnCode) |
| | | .distinct() |
| | | .collect(Collectors.joining(",")))); |
| | | for (WaitPakinLog p : list) { |
| | | p.setAsnCodes(asnCodesByLogId.get(p.getId())); |
| | | } |
| | | } |
| | | |
| | | } |