| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 导出销售台账列表(包含产品明细,两个sheet页) |
| | | */ |
| | | @Log(title = "销售台账", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportWithProducts") |
| | | @ApiOperation("导出销售台账及产品明细(两个sheet页)") |
| | | public void exportWithProducts(HttpServletResponse response, SalesLedgerDto salesLedgerDto) { |
| | | salesLedgerService.exportWithProducts(response, salesLedgerDto); |
| | | } |
| | | |
| | | /** |
| | | * 导出售后台账工艺路线 |
| | | */ |
| | | @Log(title = "销售台账工艺路线", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportProcessRoute") |
| | | @ApiOperation("导出售后台账工艺路线") |
| | | public void exportProcessRoute(HttpServletResponse response, |
| | | HttpServletRequest request, |
| | | @RequestParam(value = "completedTimeStart", required = false) String completedTimeStart, |
| | | @RequestParam(value = "completedTimeEnd", required = false) String completedTimeEnd) { |
| | | List<Long> salesLedgerIds = parseSalesLedgerIds(request); |
| | | salesLedgerService.exportProcessRoute(response, salesLedgerIds, completedTimeStart, completedTimeEnd); |
| | | } |
| | | |
| | | /** |
| | | * 导出开票登记列表 |
| | | */ |
| | | @Log(title = "导出开票登记列表", businessType = BusinessType.EXPORT) |
| | |
| | | */ |
| | | @PostMapping("/saleProcessBind") |
| | | @ApiOperation("销售订单绑定工艺路线") |
| | | public AjaxResult saleProcessBind(@RequestBody SalesLedgerProcessRoute salesLedgerProcessRoute) { |
| | | salesLedgerService.saleProcessBind(salesLedgerProcessRoute); |
| | | public AjaxResult saleProcessBind(@RequestBody SalesLedgerProcessRouteDto salesLedgerProcessRouteDto) { |
| | | salesLedgerService.saleProcessBind(salesLedgerProcessRouteDto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | @ApiOperation("标记订单完成(不可撤销)") |
| | | public AjaxResult markOrderCompleted(@RequestBody Map<String, Object> params) { |
| | | @SuppressWarnings("unchecked") |
| | | List<Long> ids = (List<Long>) params.get("ids"); |
| | | List<Long> ids = ((List<Object>) params.get("ids")).stream() |
| | | .map(obj -> Long.valueOf(obj.toString())) |
| | | .collect(Collectors.toList()); |
| | | if (ids == null || ids.isEmpty()) { |
| | | return AjaxResult.error("请选择要标记完成的订单"); |
| | | } |
| | |
| | | excelUtil.importTemplateExcel(response, "未出库导入模板下载"); |
| | | } |
| | | |
| | | private List<Long> parseSalesLedgerIds(HttpServletRequest request) { |
| | | if (request == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | List<Long> ids = new ArrayList<>(); |
| | | Map<String, String[]> parameterMap = request.getParameterMap(); |
| | | if (parameterMap == null || parameterMap.isEmpty()) { |
| | | return ids; |
| | | } |
| | | |
| | | String directValue = request.getParameter("salesLedgerIds"); |
| | | if (StringUtils.hasText(directValue)) { |
| | | for (String value : directValue.split(",")) { |
| | | addParsedLong(ids, value); |
| | | } |
| | | } |
| | | |
| | | for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) { |
| | | String key = entry.getKey(); |
| | | if (!StringUtils.hasText(key)) { |
| | | continue; |
| | | } |
| | | if (!"salesLedgerIds".equals(key) && !key.startsWith("salesLedgerIds[")) { |
| | | continue; |
| | | } |
| | | String[] values = entry.getValue(); |
| | | if (values == null) { |
| | | continue; |
| | | } |
| | | for (String value : values) { |
| | | addParsedLong(ids, value); |
| | | } |
| | | } |
| | | |
| | | return ids.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | private void addParsedLong(List<Long> target, String value) { |
| | | if (target == null || !StringUtils.hasText(value)) { |
| | | return; |
| | | } |
| | | try { |
| | | target.add(Long.valueOf(value.trim())); |
| | | } catch (Exception ignored) { |
| | | // ignore invalid id values |
| | | } |
| | | } |
| | | |
| | | } |