| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | 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.Delivery; |
| | | import com.vincent.rsf.server.manager.entity.DeliveryItem; |
| | | import com.vincent.rsf.server.manager.entity.excel.DeliveryTemplate; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.enums.OrderWorkType; |
| | | import com.vincent.rsf.server.manager.service.CompanysService; |
| | | import com.vincent.rsf.server.manager.service.DeliveryItemService; |
| | | import com.vincent.rsf.server.manager.service.DeliveryService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.system.service.SerialRuleService; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | |
| | | |
| | | @Autowired |
| | | private DeliveryService deliveryService; |
| | | @Autowired |
| | | private DeliveryItemService deliveryItemService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:delivery:list')") |
| | | @PostMapping("/delivery/page") |
| | |
| | | @PreAuthorize("hasAuthority('manager:delivery:list')") |
| | | @PostMapping("/delivery/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(deliveryService.list(), Delivery.class), response); |
| | | if (!Cools.isEmpty(map) && !Cools.isEmpty(map.get("ids"))) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | List<Delivery> orders = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | List<Long> ids = JSONArray.parseArray(JSONObject.toJSONString(map.get("ids")), Long.class); |
| | | if (!ids.isEmpty()) { |
| | | orders = deliveryService.list(new LambdaQueryWrapper<Delivery>().in(Delivery::getId, ids)); |
| | | } else { |
| | | orders = deliveryService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | } else { |
| | | orders = deliveryService.list(); |
| | | } |
| | | List<DeliveryTemplate> orderTemplates = new ArrayList<>(); |
| | | for (Delivery order : orders) { |
| | | List<DeliveryItem> orderItems = deliveryItemService.list(new LambdaQueryWrapper<DeliveryItem>().eq(DeliveryItem::getDeliveryId, order.getId())); |
| | | for (DeliveryItem item : orderItems) { |
| | | if (Objects.isNull(item)) { |
| | | continue; |
| | | } |
| | | DeliveryTemplate template = new DeliveryTemplate(); |
| | | template.setDoCode(order.getCode()) |
| | | .setType(OrderType.getValType(order.getType())) |
| | | .setWkType(OrderWorkType.getWorkDesc(order.getWkType())) |
| | | .setAnfme(item.getAnfme() + "") |
| | | .setMaktx(item.getMaktx()) |
| | | .setMemo(item.getMemo()) |
| | | .setMatnrCode(item.getMatnrCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setSplrBatch(item.getSplrBatch()) |
| | | .setSplrName(item.getSplrName()) |
| | | .setSplrCode(item.getSplrCode()); |
| | | orderTemplates.add(template); |
| | | } |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orderTemplates, DeliveryTemplate.class), response); |
| | | } |
| | | |
| | | } |
| | | @PostMapping("/delivery/import") |
| | | @ApiOperation("DO单导入接口") |
| | | @PreAuthorize("hasAuthority('manager:delivery:update')") |
| | | public R importExcel(@RequestParam(value = "file") MultipartFile file) throws Exception { |
| | | if (Objects.isNull(file)) { |
| | | return R.error("文件不能为空!!"); |
| | | } |
| | | Map<String, Object> hashMap = new HashMap<>(); |
| | | return R.ok("导入成功").add(deliveryItemService.excelImport(file, hashMap, getLoginUserId())); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 下载模板 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/18 08:17 |
| | | */ |
| | | @PostMapping("/delivery/template/download") |
| | | @ApiOperation("下载收货单模板") |
| | | @PreAuthorize("hasAuthority('manager:delivery:update')") |
| | | public void downloadTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | DeliveryTemplate template = ExcelUtil.mockData(DeliveryTemplate.class); |
| | | List<DeliveryTemplate> list = Arrays.asList(template); |
| | | ExcelUtil.build(ExcelUtil.create(list, DeliveryTemplate.class, true), response); |
| | | } |
| | | |
| | | } |