| | |
| | | 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.controller.params.BatchUpdateParam; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.Companys; |
| | | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; |
| | | import com.vincent.rsf.server.manager.enums.CompanysType; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.CompanysService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | 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.*; |
| | | |
| | | @Api(tags = "ASN单明细") |
| | | @RestController |
| | | public class AsnOrderItemController extends BaseController { |
| | | |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | |
| | | @Autowired |
| | | private CompanysService companysService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:list')") |
| | | @ApiOperation("分页获取列表") |
| | | @PostMapping("/asnOrderItem/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AsnOrderItem, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrderItem.class); |
| | | return R.ok().add(asnOrderItemService.page(pageParam, pageParam.buildWrapper(true))); |
| | | return R.ok().add(asnOrderItemService.listByAsnId(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:list')") |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:save')") |
| | | @OperationLog("Create ASN单据") |
| | | @PostMapping("/asnOrderItem/save") |
| | | public R save(@RequestBody AsnOrderItem asnOrderItem) { |
| | | asnOrderItem.setCreateBy(getLoginUserId()); |
| | | asnOrderItem.setUpdateBy(getLoginUserId()); |
| | | // asnOrderItemService.getFieldsExtend |
| | | if (!asnOrderItemService.save(asnOrderItem)) { |
| | | public R save(@RequestBody Map<String, Object> params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("信息不能为空!!"); |
| | | } |
| | | params.put("createBy", getLoginUserId()); |
| | | params.put("updateBy", getLoginUserId()); |
| | | |
| | | if (!asnOrderItemService.fieldsSave(params)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(asnOrderItem); |
| | | return R.ok("Save Success"); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:update')") |
| | | @OperationLog("Update ASN单据") |
| | |
| | | public R update(@RequestBody AsnOrderItem asnOrderItem) { |
| | | asnOrderItem.setUpdateBy(getLoginUserId()); |
| | | asnOrderItem.setUpdateTime(new Date()); |
| | | if (!Objects.isNull(asnOrderItem.getSplrName()) && StringUtils.isNotBlank(asnOrderItem.getSplrName())) { |
| | | Companys companys = companysService.getOne(new LambdaQueryWrapper<Companys>() |
| | | .eq(Companys::getType, CompanysType.COMPANYS_TYPE_SUPPLIER.val) |
| | | .eq(Companys::getId, asnOrderItem.getSplrName())); |
| | | if (!Objects.isNull(companys)) { |
| | | asnOrderItem.setSplrCode(companys.getCode()).setSplrName(companys.getName()); |
| | | } |
| | | } |
| | | if (!asnOrderItemService.updateById(asnOrderItem)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:list')") |
| | | @PostMapping("/asnOrderItem/export") |
| | | @ApiOperation("导出收货通知单明细") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(asnOrderItemService.list(), AsnOrderItem.class), response); |
| | | List<AsnOrderItem> orderItems = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | List<Long> ids = JSONArray.parseArray(JSONObject.toJSONString(map.get("ids")), Long.class); |
| | | if (!ids.isEmpty()) { |
| | | orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>() |
| | | .in(AsnOrderItem::getId, ids) |
| | | .eq(AsnOrderItem::getStatus, 1)); |
| | | } else { |
| | | orderItems = asnOrderItemService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | } else { |
| | | orderItems = asnOrderItemService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | |
| | | ExcelUtil.build(ExcelUtil.create(orderItems, AsnOrderItem.class, true), response); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/asnOrderItem/generate/barcode") |
| | | @ApiOperation("生成ASN标签") |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | | public R generateBarcode(@RequestBody List<Long> orders) { |
| | | if (orders.isEmpty()) { |
| | | return R.error("单据不能为空!!"); |
| | | } |
| | | return asnOrderItemService.generateBarcode(orders); |
| | | } |
| | | |
| | | /** |
| | | * ASN单据明细导入 |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping("/asnOrderItem/import") |
| | | @ApiOperation("ASN导入接口") |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:update')") |
| | | public R importExcel(@RequestParam(value = "file") MultipartFile file, @RequestParam String asnId) throws Exception { |
| | | if (Objects.isNull(file)) { |
| | | R.error("文件不能为空!!"); |
| | | } |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | return asnOrderItemService.excelImport(file, hashMap, getLoginUserId()); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 下载模板 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/18 08:17 |
| | | */ |
| | | @PostMapping("/asnOrderItem/template/download") |
| | | @ApiOperation("下载收货单模板") |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:update')") |
| | | public void downloadTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | AsnOrderTemplate template = ExcelUtil.mockData(AsnOrderTemplate.class); |
| | | List<AsnOrderTemplate> list = Arrays.asList(template); |
| | | ExcelUtil.build(ExcelUtil.create(list, AsnOrderTemplate.class, true), response); |
| | | } |
| | | |
| | | } |