no message

main
huojin\hj 2025-07-29 17:41:31 +08:00
parent 8d901caf5f
commit 3c8a28ad7c
3 changed files with 106 additions and 80 deletions

View File

@ -1,18 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.youchain.basicdata.rest;
import cn.hutool.poi.excel.ExcelReader;
@ -73,10 +73,10 @@ import static org.springframework.http.HttpStatus.OK;
/**
* @website https://eladmin.vip
* @author houjianlan
* @date 2023-08-16
**/
* @author houjianlan
* @website https://eladmin.vip
* @date 2023-08-16
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "导入管理")
@ -91,51 +91,54 @@ public class ImportDataController {
private final PickTicketService pickTicketService;
private final PickDetailService pickDetailService;
private final CodeUtils codeUtils;
@Log("导入完成品品番")
@ApiOperation("导入完成品品番")
@PostMapping(value = "/bigItem")
@Transactional
@AnonymousAccess
public ResponseEntity<Object> importBigItem( @RequestParam("file") MultipartFile multipartFile) {
public ResponseEntity<Object> importBigItem(@RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
int a=0;//新增
int b=0;//修改
int c=0;//错误
int d=0;//执行
List<String> cList=new ArrayList<>();
int a = 0;//新增
int b = 0;//修改
int c = 0;//错误
int d = 0;//执行
List<String> cList = new ArrayList<>();
for (int i = 0; i < readAll.size(); i++) {
String code =readAll.get(i).get("完成品品番")==null?null:readAll.get(i).get("完成品品番").toString();
if(code==null||code.equals("")){
String code = readAll.get(i).get("完成品品番") == null ? null : readAll.get(i).get("完成品品番").toString();
if (code == null || code.equals("")) {
break;
}
String re = importDataService.importBigItem(readAll.get(i));
}
return new ResponseEntity("导入成功",HttpStatus.OK);
return new ResponseEntity("导入成功", HttpStatus.OK);
}
@Log("导入部品品番")
@ApiOperation("导入部品品番")
@PostMapping(value = "/item")
@Transactional
@AnonymousAccess
public ResponseEntity<Object> importItem( @RequestParam("file") MultipartFile multipartFile) {
public ResponseEntity<Object> importItem(@RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
int a=0;//新增
int b=0;//修改
int a = 0;//新增
int b = 0;//修改
for (int i = 0; i < readAll.size(); i++) {
Map<String, Object> map=readAll.get(i);
String code =(String) map.get("品番");
if(code==null||code.equals("")){
Map<String, Object> map = readAll.get(i);
String code = (String) map.get("品番");
if (code == null || code.equals("")) {
break;
}
String re = importDataService.importItem(map);
if (re.equals("a")){
a=a+1;
}else if (re.equals("b")){
b=b+1;
if (re.equals("a")) {
a = a + 1;
} else if (re.equals("b")) {
b = b + 1;
}
}
return new ResponseEntity("导入成功:执行"+(a+b)+"行 新增"+a+"行,修改"+b+"行",HttpStatus.OK);
return new ResponseEntity("导入成功:执行" + (a + b) + "行 新增" + a + "行,修改" + b + "行", HttpStatus.OK);
}
@Log("导入其他入库")
@ApiOperation("导入其他入库")
@PostMapping(value = "/importAsnDetail")
@ -143,23 +146,23 @@ public class ImportDataController {
@AnonymousAccess
public ResponseEntity<Object> importAsnDetail(@RequestParam Long asnId, @RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
List<String> cList=new ArrayList<>();
Asn asn=asnService.getEntity(asnId);
if(asn==null){
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
List<String> cList = new ArrayList<>();
Asn asn = asnService.getEntity(asnId);
if (asn == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
}
if(!asn.getStatus().equals(BizStatus.OPEN))
{
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
if (!asn.getStatus().equals(BizStatus.OPEN)) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
}
for (int i = 0; i < readAll.size(); i++) {
String re = importDataService.importAsnDetail(readAll.get(i),asn);
if(re!=null&&!re.equals("")){
throw new BadRequestException(HttpStatus.NOT_FOUND, (i+1)+"行"+re);
String re = importDataService.importAsnDetail(readAll.get(i), asn);
if (re != null && !re.equals("")) {
throw new BadRequestException(HttpStatus.NOT_FOUND, (i + 1) + "行" + re);
}
}
return new ResponseEntity("导入成功", HttpStatus.OK);
}
@Log("导入其他出库")
@ApiOperation("导入其他出库")
@PostMapping(value = "/importPickDetail")
@ -167,22 +170,21 @@ public class ImportDataController {
@AnonymousAccess
public ResponseEntity<Object> importPickDetail(@RequestParam Long ptId, @RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
List<String> cList=new ArrayList<>();
PickTicket pt=pickTicketService.getEntity(ptId);
if(pt==null){
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
List<String> cList = new ArrayList<>();
PickTicket pt = pickTicketService.getEntity(ptId);
if (pt == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
}
if(!pt.getStatus().equals(BizStatus.OPEN)&&!pt.getStatus().equals(BizStatus.ALLOCATE))
{
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
if (!pt.getStatus().equals(BizStatus.OPEN) && !pt.getStatus().equals(BizStatus.ALLOCATE)) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
}
for (int i = 0; i < readAll.size(); i++) {
String re = importDataService.importPickDetail(readAll.get(i),pt);
if(re!=null&&!re.equals("")){
throw new BadRequestException(HttpStatus.NOT_FOUND, (i+1)+"行"+re);
String re = importDataService.importPickDetail(readAll.get(i), pt);
if (re != null && !re.equals("")) {
throw new BadRequestException(HttpStatus.NOT_FOUND, (i + 1) + "行" + re);
}
}
List<PickDetail> ds=pickDetailService.queryPickDetailList(pt.getId());
List<PickDetail> ds = pickDetailService.queryPickDetailList(pt.getId());
// for(PickDetail d:ds) {
// pickDetailService.allocate(d.getId(),d.getOrderQty());
// }
@ -205,9 +207,9 @@ public class ImportDataController {
@PostMapping(value = "/importCountMoveDetail")
@Transactional
@AnonymousAccess
public ResponseEntity<Object> importCountMoveDetail(@RequestParam Long countId,@RequestParam("file") MultipartFile multipartFile) {
public ResponseEntity<Object> importCountMoveDetail(@RequestParam Long countId, @RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
importDataService.importCountMoveDetail(countId,readAll);
importDataService.importCountMoveDetail(countId, readAll);
return new ResponseEntity("导入成功", HttpStatus.OK);
}
@ -216,17 +218,18 @@ public class ImportDataController {
@PostMapping(value = "/bomAccount")
@Transactional
@AnonymousAccess
public ResponseEntity<Object> importBomAccount( @RequestParam("file") MultipartFile multipartFile) {
public ResponseEntity<Object> importBomAccount(@RequestParam("file") MultipartFile multipartFile) {
List<Map<String, Object>> readAll = getMaps(multipartFile);
for (int i = 0; i < readAll.size(); i++) {
importDataService.importBomAccount(i,readAll.get(i));
importDataService.importBomAccount(i, readAll.get(i));
}
return new ResponseEntity("导入成功"+ readAll.size()+"行", HttpStatus.OK);
return new ResponseEntity("导入成功" + readAll.size() + "行", HttpStatus.OK);
}
/**
*
*
* @param multipartFile
* @return
*/
@ -248,12 +251,11 @@ public class ImportDataController {
@ApiOperation("导入asn")
@AnonymousAccess
public ResponseEntity<Object> importAsn(@RequestParam("file") MultipartFile file, @RequestParam("templateType") String templateType) {
try {
log.info("导入开始");
importDataService.importAsn(file, templateType);
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), e.getMessage(), null), HttpStatus.BAD_REQUEST);
}
log.info("开始导入");
long start = System.currentTimeMillis();
importDataService.importAsn(file, templateType);
log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start));
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), HttpStatus.OK);
}
}

View File

@ -435,10 +435,6 @@ public class ImportDataServiceImpl implements ImportDataService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importAsn(MultipartFile file, String templateType) {
// 验证模板类型
if (StringUtils.isEmpty(templateType)) {
throw new BadRequestException("模板类型不能为空");
}
// 验证模板类型是否有效
if (!isValidTemplateType(templateType)) {
@ -489,17 +485,23 @@ public class ImportDataServiceImpl implements ImportDataService {
// TODO: 实现标准导入逻辑
log.info("处理标准导入,数据条数: {}", dataList.size());
//获取文件中所有的托盘号
List<String> codes = dataList.stream().map(AsnImportForm::getCNo).collect(Collectors.toList());
//验证托盘号
validateAsn(codes);
//获取文件中所有的品番
List<String> itemCodes = dataList.stream().map(AsnImportForm::getPartNo).collect(Collectors.toList());
//验证品番
Map<String, Item> exitItemMap = validateItem(itemCodes);
//获取文件中所有的托盘号
List<String> codes = dataList.stream().map(AsnImportForm::getCNo).collect(Collectors.toList());
//库区
Area area=areaService.findByCode(BaseStatus.DEFAULT_AREA);
//验证托盘号
validateAsn(codes);
//单据类型
BillType billType=billTypeRepository.findByName(BaseStatus.RK);
Map<String, Asn> asnMap = new HashMap<>();
List<Asn> insertToAsn=new ArrayList<>();//批量新增ASN
@ -513,17 +515,25 @@ public class ImportDataServiceImpl implements ImportDataService {
Double orderQty = data.getQty();//数量
String code = data.getCNo();//托盘号
//品番
Item item=exitItemMap.get(itemCode);
Asn asn = null;
if (asnMap.containsKey(code)) {
asn=asnMap.get(code);
asn.setOrderQuantity(asn.getOrderQuantity() + orderQty);
}else{
asn = Asn.builder()
.relatedBill1(relatedBill1)
.code(code)
.area(area)
.status(BizStatus.OPEN)
.orderDate(new Timestamp(new Date().getTime()))
.orderQuantity(orderQty)
.billType(billType)
.receivedQuantity(0d)
.putawayQuantity(0d)
.build();
asnMap.put(code, asn);
insertToAsn.add(asn);
@ -532,10 +542,17 @@ public class ImportDataServiceImpl implements ImportDataService {
AsnDetail asnDetail = AsnDetail.builder()
.propC2(propC2)
.po(po)
.item(exitItemMap.get(itemCode))
.item(item)
.remark( remark)
.orderQty(orderQty)
.asn(asn)
.status(BizStatus.OPEN)
.receivedQty(0d)
.moveQty(0d)
.putQty(0d)
.weight(0d)
.volume(0d)
.dept(item.getDept())
.build();
insertToAsnDetail.add(asnDetail);
}
@ -590,6 +607,8 @@ public class ImportDataServiceImpl implements ImportDataService {
// 获取两个集合的交集说明ASN重复导入了直接提示
List<String> difference = SmartStringUtil.getIntersection(codes, existingAsnCodes);
if (CollectionUtils.isNotEmpty(difference)) {
//去重difference
difference = difference.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
throw new BadRequestException(difference + "托盘号已导入,请勿重复导入");
}
}

View File

@ -82,5 +82,10 @@ public interface BaseStatus {
* -
*/
public static String BT_DD = "单点";
/**
* -
*/
public static String RK = "正常入库";
}