入库整理

main
HUOJIN\92525 2024-09-23 18:16:03 +08:00
parent c7989bec9a
commit 00cfa17fe6
7 changed files with 135 additions and 99 deletions

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.youchain.basicdata.rest; package com.youchain.basicdata.rest;
import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelReader;
@ -48,13 +48,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
/** /**
* @website https://eladmin.vip * @author liuxue
* @author liuxue * @website https://eladmin.vip
* @date 2023-07-28 * @date 2023-07-28
**/ **/
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@ -67,6 +68,7 @@ public class StockController {
private final FileProperties properties; private final FileProperties properties;
private final StockTypeService stockTypeService; private final StockTypeService stockTypeService;
@Log("导出数据") @Log("导出数据")
@ApiOperation("导出数据") @ApiOperation("导出数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
@ -78,7 +80,7 @@ public class StockController {
@PostMapping(value = "/import_stock") @PostMapping(value = "/import_stock")
@ApiOperation("容器导入") @ApiOperation("容器导入")
@AnonymousAccess @AnonymousAccess
public ResponseEntity<Object> importStock( @RequestParam("file") MultipartFile multipartFile) { public ResponseEntity<Object> importStock(@RequestParam("file") MultipartFile multipartFile) {
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize()); FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename()); String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
String type = FileUtil.getFileType(suffix); String type = FileUtil.getFileType(suffix);
@ -87,53 +89,53 @@ public class StockController {
log.error("--" + file.getPath()); log.error("--" + file.getPath());
//代码、库区 //代码、库区
ExcelReader reader = ExcelUtil.getReader(file); ExcelReader reader = ExcelUtil.getReader(file);
int i=0; int i = 0;
int edit_len=0; int edit_len = 0;
int new_len=0; int new_len = 0;
try{ try {
List<Map<String, Object>> readAll = reader.readAll(); List<Map<String, Object>> readAll = reader.readAll();
for ( i = 0; i < readAll.size(); i++) { for (i = 0; i < readAll.size(); i++) {
int j=0; int j = 0;
String code=readAll.get(i).get("代码").toString().trim(); String code = readAll.get(i).get("代码").toString().trim();
String stockTypeCode=readAll.get(i).get("类型").toString().trim(); String stockTypeCode = readAll.get(i).get("类型").toString().trim();
StockType st=stockTypeService.findByCode(stockTypeCode); StockType st = stockTypeService.findByCode(stockTypeCode);
if(code==null || code.length()<=0){ if (code == null || code.length() <= 0) {
break; break;
} }
if(st==null){ if (st == null) {
ApiError apiError = ApiError.errorJosn(BAD_REQUEST.value(),"找不到容器类型"+stockTypeCode); ApiError apiError = ApiError.errorJosn(BAD_REQUEST.value(), "找不到容器类型" + stockTypeCode);
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus())); return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
} }
Stock stock=stockService.findByCode(code,null); Stock stock = stockService.findByCode(code, null);
if(stock==null){ if (stock == null) {
stock=new Stock(); stock = new Stock();
stock.setCode(code); stock.setCode(code);
stock.setName(code); stock.setName(code);
log.error(j+++"====="); log.error(j++ + "=====");
stock.setStatus(BaseStatus.FREE); stock.setStatus(BaseStatus.FREE);
stock.setEnabled(true); stock.setEnabled(true);
new_len++; new_len++;
stock.setStockType(st); stock.setStockType(st);
log.error(j+++"====="); log.error(j++ + "=====");
stock.setDept(UserUtils.getDept()); stock.setDept(UserUtils.getDept());
log.error(j+++"====="); log.error(j++ + "=====");
stockService.create(stock); stockService.create(stock);
log.error(j+++"====="); log.error(j++ + "=====");
}else{ } else {
edit_len++; edit_len++;
} }
log.error(j+++"a====="); log.error(j++ + "a=====");
stock.setStockType(st); stock.setStockType(st);
stockService.update(stock); stockService.update(stock);
log.error(j+++"a====="); log.error(j++ + "a=====");
} }
}catch (Exception e){ } catch (Exception e) {
ApiError apiError = ApiError.errorJosn(HttpStatus.BAD_REQUEST.value(), "导入异常---第"+(i+1)+"行:"+e.toString()); ApiError apiError = ApiError.errorJosn(HttpStatus.BAD_REQUEST.value(), "导入异常---第" + (i + 1) + "行:" + e.toString());
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus())); return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
} }
ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:"+(i)+"行 新增("+new_len+")修改("+edit_len+")"); ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:" + (i) + "行 新增(" + new_len + ")修改(" + edit_len + ")");
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus())); return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
} }
@ -142,33 +144,33 @@ public class StockController {
@Log("查询stock") @Log("查询stock")
@ApiOperation("查询stock") @ApiOperation("查询stock")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> queryStock(StockQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> queryStock(StockQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(stockService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(stockService.queryAll(criteria, pageable), HttpStatus.OK);
} }
@Log("查询可用空闲的容器stock") @Log("查询可用空闲的容器stock")
@ApiOperation("查询可用空闲的容器stock") @ApiOperation("查询可用空闲的容器stock")
@GetMapping(value = "/queryKyStockList") @GetMapping(value = "/queryKyStockList")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> queryKyStockList(StockQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> queryKyStockList(StockQueryCriteria criteria) {
return new ResponseEntity<>(stockService.queryKyStockList("124"),HttpStatus.OK); return new ResponseEntity<>(stockService.queryKyStockList(criteria.getCode()), HttpStatus.OK);
} }
@PostMapping @PostMapping
@Log("新增stock") @Log("新增stock")
@ApiOperation("新增stock") @ApiOperation("新增stock")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> createStock(@Validated @RequestBody Stock resources){ public ResponseEntity<Object> createStock(@Validated @RequestBody Stock resources) {
resources.setDept(UserUtils.getDept()); resources.setDept(UserUtils.getDept());
resources.setEnabled(true); resources.setEnabled(true);
return new ResponseEntity<>(stockService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(stockService.create(resources), HttpStatus.CREATED);
} }
@PutMapping @PutMapping
@Log("修改stock") @Log("修改stock")
@ApiOperation("修改stock") @ApiOperation("修改stock")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> updateStock(@Validated @RequestBody Stock resources){ public ResponseEntity<Object> updateStock(@Validated @RequestBody Stock resources) {
stockService.update(resources); stockService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
@ -177,7 +179,7 @@ public class StockController {
@Log("修改stock") @Log("修改stock")
@ApiOperation("修改stock") @ApiOperation("修改stock")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> updateStockOK(@Validated @RequestBody Stock resources){ public ResponseEntity<Object> updateStockOK(@Validated @RequestBody Stock resources) {
stockService.update(resources); stockService.update(resources);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@ -186,7 +188,7 @@ public class StockController {
@Log("批量修改stock的状态") @Log("批量修改stock的状态")
@ApiOperation("批量修改stock的状态") @ApiOperation("批量修改stock的状态")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> updateStockStatus(@Validated @RequestBody List<Stock> stockList){ public ResponseEntity<Object> updateStockStatus(@Validated @RequestBody List<Stock> stockList) {
for (Stock s : stockList) { for (Stock s : stockList) {
stockService.update(s); stockService.update(s);
} }

View File

@ -51,8 +51,7 @@ public class Asn extends BaseEntity implements Serializable {
private String code; private String code;
@OneToOne @OneToOne
@JoinColumn(name = "`area_id`",nullable = false) @JoinColumn(name = "`area_id`")
@NotNull
@ApiModelProperty(value = "库区") @ApiModelProperty(value = "库区")
private Area area; private Area area;
@ -61,7 +60,7 @@ public class Asn extends BaseEntity implements Serializable {
private String status; private String status;
@Column(name = "`cus_code`") @Column(name = "`cus_code`")
@ApiModelProperty(value = "客户订单号") @ApiModelProperty(value = "SAP接口号")
private String cusCode; private String cusCode;
@Column(name = "`related_bill1`") @Column(name = "`related_bill1`")
@ -106,11 +105,11 @@ public class Asn extends BaseEntity implements Serializable {
private String fromTel; private String fromTel;
@Column(name = "`order_quantity`") @Column(name = "`order_quantity`")
@ApiModelProperty(value = "订单数量") @ApiModelProperty(value = "待收数量")
private Double orderQuantity; private Double orderQuantity;
@Column(name = "`received_quantity`") @Column(name = "`received_quantity`")
@ApiModelProperty(value = "数量") @ApiModelProperty(value = "收数量")
private Double receivedQuantity; private Double receivedQuantity;
@Column(name = "`putaway_quantity`") @Column(name = "`putaway_quantity`")
@ -136,14 +135,14 @@ public class Asn extends BaseEntity implements Serializable {
private String description; private String description;
@Column(name = "`zl_by`") @Column(name = "`zl_by`")
@ApiModelProperty(value = "整理人") @ApiModelProperty(value = "SAP收货人")
private String zlBy; private String zlBy;
@Column(name = "`zl_date`") @Column(name = "`zl_date`")
@ApiModelProperty(value = "整理日期") @ApiModelProperty(value = "整理日期")
private Timestamp zlDate; private Timestamp zlDate;
@Column(name = "`cy_by`") @Column(name = "`cy_by`")
@ApiModelProperty(value = "抽样人") @ApiModelProperty(value = "申请人")
private String cyBy; private String cyBy;
@Column(name = "`cy_date`") @Column(name = "`cy_date`")

View File

@ -50,7 +50,7 @@ public class AsnDetail extends BaseEntity implements Serializable {
@OneToOne @OneToOne
@JoinColumn(name = "`asn_id`") @JoinColumn(name = "`asn_id`")
@ApiModelProperty(value = "订单序号") @ApiModelProperty(value = "入库单")
private Asn asn; private Asn asn;
@OneToOne @OneToOne

View File

@ -25,6 +25,7 @@ import com.youchain.businessdata.repository.AsnRepository;
import com.youchain.businessdata.service.AsnService; import com.youchain.businessdata.service.AsnService;
import com.youchain.businessdata.service.dto.AsnQueryCriteria; import com.youchain.businessdata.service.dto.AsnQueryCriteria;
import com.youchain.exception.BadRequestException; import com.youchain.exception.BadRequestException;
import com.youchain.exception.handler.ApiResult;
import com.youchain.utils.BizStatus; import com.youchain.utils.BizStatus;
import com.youchain.utils.CodeUtils; import com.youchain.utils.CodeUtils;
import com.youchain.utils.SecurityUtils; import com.youchain.utils.SecurityUtils;
@ -76,7 +77,7 @@ public class AsnController {
@ApiOperation("查询最大单号") @ApiOperation("查询最大单号")
@AnonymousAccess @AnonymousAccess
public ResponseEntity<Object> maxNo(@RequestParam("code") String code) { public ResponseEntity<Object> maxNo(@RequestParam("code") String code) {
return new ResponseEntity<>(codeUtils.getCode_yyMMdd(code,3), HttpStatus.OK); return new ResponseEntity<>(codeUtils.getCode_yyMMdd(code, 3), HttpStatus.OK);
} }
@ -89,7 +90,6 @@ public class AsnController {
} }
@GetMapping("/getIdByAsn") @GetMapping("/getIdByAsn")
@Log("查询asn") @Log("查询asn")
@ApiOperation("查询asn") @ApiOperation("查询asn")
@ -132,6 +132,22 @@ public class AsnController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@DeleteMapping(value = "/deleteAsnAndDetail")
@Log("删除入库单和入库明细")
@ApiOperation("删除入库单和入库明细")
@PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> deleteAsnAndDetail(@RequestBody Long[] ids) {
try {
for (Long id : ids) {
asnService.deleteAsnAndDetail(id);
}
return new ResponseEntity<>(ApiResult.success("删除成功", null), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.fail(HttpStatus.BAD_REQUEST.value(), e.getMessage(), null), HttpStatus.BAD_REQUEST);
}
}
@PostMapping("/zlRegister") @PostMapping("/zlRegister")
@Log("入库整理登记") @Log("入库整理登记")
@ApiOperation("入库整理登记") @ApiOperation("入库整理登记")
@ -140,21 +156,21 @@ public class AsnController {
@DuplicateSubmission(5) @DuplicateSubmission(5)
public ResponseEntity<Object> zlRegister(@RequestBody Long[] ids) { public ResponseEntity<Object> zlRegister(@RequestBody Long[] ids) {
for (Long id : ids) { for (Long id : ids) {
Asn asn=asnService.getEntity(id); Asn asn = asnService.getEntity(id);
BillType bt=asn.getBillType(); BillType bt = asn.getBillType();
if(bt.getBezl()){ if (bt.getBezl()) {
if(!asn.getStatus().equals(BizStatus.OPEN)){ if (!asn.getStatus().equals(BizStatus.OPEN)) {
throw new BadRequestException(asn.getCode()+"状态不正确,打开状态才能操作"); throw new BadRequestException(asn.getCode() + "状态不正确,打开状态才能操作");
} }
asn.setZlBy(SecurityUtils.getCurrentUsername()); asn.setZlBy(SecurityUtils.getCurrentUsername());
asn.setZlDate(new Timestamp(new Date().getTime())); asn.setZlDate(new Timestamp(new Date().getTime()));
asn.setStatus(BizStatus.ZL); asn.setStatus(BizStatus.ZL);
asnService.update(asn); asnService.update(asn);
}else{ } else {
throw new BadRequestException(asn.getCode()+"不需要整理"); throw new BadRequestException(asn.getCode() + "不需要整理");
} }
} }
return new ResponseEntity<>("操作成功",HttpStatus.OK); return new ResponseEntity<>("操作成功", HttpStatus.OK);
} }
@PostMapping("/cyRegister") @PostMapping("/cyRegister")
@ -165,25 +181,26 @@ public class AsnController {
@DuplicateSubmission(5) @DuplicateSubmission(5)
public ResponseEntity<Object> cyRegister(@RequestBody Long[] ids) { public ResponseEntity<Object> cyRegister(@RequestBody Long[] ids) {
for (Long id : ids) { for (Long id : ids) {
Asn asn=asnService.getEntity(id); Asn asn = asnService.getEntity(id);
BillType bt=asn.getBillType(); BillType bt = asn.getBillType();
if(bt.getBezl()&&asn.getZlBy()==null){ if (bt.getBezl() && asn.getZlBy() == null) {
throw new BadRequestException(asn.getCode()+"该单子还未整理,请先整理"); throw new BadRequestException(asn.getCode() + "该单子还未整理,请先整理");
} }
if(bt.getBecy()){ if (bt.getBecy()) {
if(!asn.getStatus().equals(BizStatus.OPEN)&&!asn.getStatus().equals(BizStatus.ZL)){ if (!asn.getStatus().equals(BizStatus.OPEN) && !asn.getStatus().equals(BizStatus.ZL)) {
throw new BadRequestException(asn.getCode()+"状态不正确,打开或整理状态才能操作"); throw new BadRequestException(asn.getCode() + "状态不正确,打开或整理状态才能操作");
} }
asn.setCyBy(SecurityUtils.getCurrentUsername()); asn.setCyBy(SecurityUtils.getCurrentUsername());
asn.setCyDate(new Timestamp(new Date().getTime())); asn.setCyDate(new Timestamp(new Date().getTime()));
asn.setStatus(BizStatus.CY); asn.setStatus(BizStatus.CY);
asnService.update(asn); asnService.update(asn);
}else{ } else {
throw new BadRequestException(asn.getCode()+"不需要抽样"); throw new BadRequestException(asn.getCode() + "不需要抽样");
} }
} }
return new ResponseEntity<>("操作成功",HttpStatus.OK); return new ResponseEntity<>("操作成功", HttpStatus.OK);
} }
@PostMapping("/zjRegister") @PostMapping("/zjRegister")
@Log("入库质检登记") @Log("入库质检登记")
@ApiOperation("入库质检登记") @ApiOperation("入库质检登记")
@ -192,26 +209,26 @@ public class AsnController {
@DuplicateSubmission(5) @DuplicateSubmission(5)
public ResponseEntity<Object> zjRegister(@RequestBody Long[] ids) { public ResponseEntity<Object> zjRegister(@RequestBody Long[] ids) {
for (Long id : ids) { for (Long id : ids) {
Asn asn=asnService.getEntity(id); Asn asn = asnService.getEntity(id);
BillType bt=asn.getBillType(); BillType bt = asn.getBillType();
if(bt.getBezl()&&asn.getZlBy()==null){ if (bt.getBezl() && asn.getZlBy() == null) {
throw new BadRequestException(asn.getCode()+"该单子还未整理,请先整理"); throw new BadRequestException(asn.getCode() + "该单子还未整理,请先整理");
} }
if(bt.getBecy()&&asn.getCyBy()==null){ if (bt.getBecy() && asn.getCyBy() == null) {
throw new BadRequestException(asn.getCode()+"该单子还未抽样,请先抽样"); throw new BadRequestException(asn.getCode() + "该单子还未抽样,请先抽样");
} }
if(bt.getBezj()){ if (bt.getBezj()) {
if(!asn.getStatus().equals(BizStatus.OPEN)&&!asn.getStatus().equals(BizStatus.ZL)&&!asn.getStatus().equals(BizStatus.CY)){ if (!asn.getStatus().equals(BizStatus.OPEN) && !asn.getStatus().equals(BizStatus.ZL) && !asn.getStatus().equals(BizStatus.CY)) {
throw new BadRequestException(asn.getCode()+"状态不正确,打开或整理或抽样状态才能操作"); throw new BadRequestException(asn.getCode() + "状态不正确,打开或整理或抽样状态才能操作");
} }
asn.setZjBy(SecurityUtils.getCurrentUsername()); asn.setZjBy(SecurityUtils.getCurrentUsername());
asn.setZjDate(new Timestamp(new Date().getTime())); asn.setZjDate(new Timestamp(new Date().getTime()));
asn.setStatus(BizStatus.ZJ); asn.setStatus(BizStatus.ZJ);
asnService.update(asn); asnService.update(asn);
}else{ } else {
throw new BadRequestException(asn.getCode()+"不需要质检"); throw new BadRequestException(asn.getCode() + "不需要质检");
} }
} }
return new ResponseEntity<>("操作成功",HttpStatus.OK); return new ResponseEntity<>("操作成功", HttpStatus.OK);
} }
} }

View File

@ -149,9 +149,6 @@ public class AsnDetailController {
@ApiOperation("新增asn_detail") @ApiOperation("新增asn_detail")
@PreAuthorize("@el.check('super:man')") @PreAuthorize("@el.check('super:man')")
public ResponseEntity<Object> createAsnDetail(@Validated @RequestBody AsnDetail asnDetail) { public ResponseEntity<Object> createAsnDetail(@Validated @RequestBody AsnDetail asnDetail) {
if(asnDetail.getAsn()==null){
return new ResponseEntity<>(ApiResult.fail(HttpStatus.BAD_REQUEST.value(), "请先提交入库单!", null),HttpStatus.BAD_REQUEST);
}
asnDetail.setStatus(BizStatus.OPEN); asnDetail.setStatus(BizStatus.OPEN);
asnDetail.setDept(UserUtils.getDept()); asnDetail.setDept(UserUtils.getDept());
if (asnDetail.getRemark() == null && asnDetail.getAsn().getDescription() != null) { if (asnDetail.getRemark() == null && asnDetail.getAsn().getDescription() != null) {

View File

@ -82,4 +82,10 @@ public interface AsnService {
* @throws Exception / * @throws Exception /
*/ */
void download(List<AsnDto> all, HttpServletResponse response) throws Exception, Exception; void download(List<AsnDto> all, HttpServletResponse response) throws Exception, Exception;
}
/**
* asnasnDetail
* @param id
*/
void deleteAsnAndDetail(Long id);
}

View File

@ -19,6 +19,7 @@ import com.youchain.businessdata.domain.Asn;
import com.youchain.businessdata.domain.AsnDetail; import com.youchain.businessdata.domain.AsnDetail;
import com.youchain.businessdata.repository.AsnDetailRepository; import com.youchain.businessdata.repository.AsnDetailRepository;
import com.youchain.businessdata.service.AsnDetailService; import com.youchain.businessdata.service.AsnDetailService;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.*; import com.youchain.utils.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.AsnRepository; import com.youchain.businessdata.repository.AsnRepository;
@ -147,4 +148,18 @@ public class AsnServiceImpl implements AsnService {
} }
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAsnAndDetail(Long id) {
Asn asn = asnRepository.findById(id).get();
if (!BizStatus.OPEN.equals(asn.getStatus())) {
throw new BadRequestException("该单据状态不允许删除");
}
List<AsnDetail> asnDetails = asnDetailRepository.queryByAsnId(id);
for (AsnDetail asnDetail : asnDetails) {
asnDetailRepository.delete(asnDetail);
}
asnRepository.delete(asn);
}
}