no message
parent
8d901caf5f
commit
3c8a28ad7c
|
|
@ -73,8 +73,8 @@ import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
|
||||||
* @author houjianlan
|
* @author houjianlan
|
||||||
|
* @website https://eladmin.vip
|
||||||
* @date 2023-08-16
|
* @date 2023-08-16
|
||||||
**/
|
**/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
@ -91,6 +91,7 @@ public class ImportDataController {
|
||||||
private final PickTicketService pickTicketService;
|
private final PickTicketService pickTicketService;
|
||||||
private final PickDetailService pickDetailService;
|
private final PickDetailService pickDetailService;
|
||||||
private final CodeUtils codeUtils;
|
private final CodeUtils codeUtils;
|
||||||
|
|
||||||
@Log("导入完成品品番")
|
@Log("导入完成品品番")
|
||||||
@ApiOperation("导入完成品品番")
|
@ApiOperation("导入完成品品番")
|
||||||
@PostMapping(value = "/bigItem")
|
@PostMapping(value = "/bigItem")
|
||||||
|
|
@ -112,6 +113,7 @@ public class ImportDataController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity("导入成功", HttpStatus.OK);
|
return new ResponseEntity("导入成功", HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("导入部品品番")
|
@Log("导入部品品番")
|
||||||
@ApiOperation("导入部品品番")
|
@ApiOperation("导入部品品番")
|
||||||
@PostMapping(value = "/item")
|
@PostMapping(value = "/item")
|
||||||
|
|
@ -136,6 +138,7 @@ public class ImportDataController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity("导入成功:执行" + (a + b) + "行 新增" + a + "行,修改" + b + "行", HttpStatus.OK);
|
return new ResponseEntity("导入成功:执行" + (a + b) + "行 新增" + a + "行,修改" + b + "行", HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("导入其他入库")
|
@Log("导入其他入库")
|
||||||
@ApiOperation("导入其他入库")
|
@ApiOperation("导入其他入库")
|
||||||
@PostMapping(value = "/importAsnDetail")
|
@PostMapping(value = "/importAsnDetail")
|
||||||
|
|
@ -148,8 +151,7 @@ public class ImportDataController {
|
||||||
if (asn == null) {
|
if (asn == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
|
||||||
}
|
}
|
||||||
if(!asn.getStatus().equals(BizStatus.OPEN))
|
if (!asn.getStatus().equals(BizStatus.OPEN)) {
|
||||||
{
|
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < readAll.size(); i++) {
|
for (int i = 0; i < readAll.size(); i++) {
|
||||||
|
|
@ -160,6 +162,7 @@ public class ImportDataController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity("导入成功", HttpStatus.OK);
|
return new ResponseEntity("导入成功", HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("导入其他出库")
|
@Log("导入其他出库")
|
||||||
@ApiOperation("导入其他出库")
|
@ApiOperation("导入其他出库")
|
||||||
@PostMapping(value = "/importPickDetail")
|
@PostMapping(value = "/importPickDetail")
|
||||||
|
|
@ -172,8 +175,7 @@ public class ImportDataController {
|
||||||
if (pt == null) {
|
if (pt == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
|
||||||
}
|
}
|
||||||
if(!pt.getStatus().equals(BizStatus.OPEN)&&!pt.getStatus().equals(BizStatus.ALLOCATE))
|
if (!pt.getStatus().equals(BizStatus.OPEN) && !pt.getStatus().equals(BizStatus.ALLOCATE)) {
|
||||||
{
|
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < readAll.size(); i++) {
|
for (int i = 0; i < readAll.size(); i++) {
|
||||||
|
|
@ -227,6 +229,7 @@ public class ImportDataController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析导入文件
|
* 解析导入文件
|
||||||
|
*
|
||||||
* @param multipartFile
|
* @param multipartFile
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -248,12 +251,11 @@ public class ImportDataController {
|
||||||
@ApiOperation("导入asn")
|
@ApiOperation("导入asn")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> importAsn(@RequestParam("file") MultipartFile file, @RequestParam("templateType") String templateType) {
|
public ResponseEntity<Object> importAsn(@RequestParam("file") MultipartFile file, @RequestParam("templateType") String templateType) {
|
||||||
try {
|
log.info("开始导入");
|
||||||
log.info("导入开始");
|
long start = System.currentTimeMillis();
|
||||||
importDataService.importAsn(file, templateType);
|
importDataService.importAsn(file, templateType);
|
||||||
|
log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start));
|
||||||
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), HttpStatus.OK);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -435,10 +435,6 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void importAsn(MultipartFile file, String templateType) {
|
public void importAsn(MultipartFile file, String templateType) {
|
||||||
// 验证模板类型
|
|
||||||
if (StringUtils.isEmpty(templateType)) {
|
|
||||||
throw new BadRequestException("模板类型不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证模板类型是否有效
|
// 验证模板类型是否有效
|
||||||
if (!isValidTemplateType(templateType)) {
|
if (!isValidTemplateType(templateType)) {
|
||||||
|
|
@ -489,17 +485,23 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
// TODO: 实现标准导入逻辑
|
// TODO: 实现标准导入逻辑
|
||||||
log.info("处理标准导入,数据条数: {}", dataList.size());
|
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());
|
List<String> itemCodes = dataList.stream().map(AsnImportForm::getPartNo).collect(Collectors.toList());
|
||||||
|
|
||||||
//验证品番
|
//验证品番
|
||||||
Map<String, Item> exitItemMap = validateItem(itemCodes);
|
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<>();
|
Map<String, Asn> asnMap = new HashMap<>();
|
||||||
List<Asn> insertToAsn=new ArrayList<>();//批量新增ASN
|
List<Asn> insertToAsn=new ArrayList<>();//批量新增ASN
|
||||||
|
|
@ -513,17 +515,25 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
Double orderQty = data.getQty();//数量
|
Double orderQty = data.getQty();//数量
|
||||||
String code = data.getCNo();//托盘号
|
String code = data.getCNo();//托盘号
|
||||||
|
|
||||||
|
//品番
|
||||||
|
Item item=exitItemMap.get(itemCode);
|
||||||
|
|
||||||
Asn asn = null;
|
Asn asn = null;
|
||||||
if (asnMap.containsKey(code)) {
|
if (asnMap.containsKey(code)) {
|
||||||
asn=asnMap.get(code);
|
asn=asnMap.get(code);
|
||||||
asn.setOrderQuantity(asn.getOrderQuantity() + orderQty);
|
asn.setOrderQuantity(asn.getOrderQuantity() + orderQty);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
asn = Asn.builder()
|
asn = Asn.builder()
|
||||||
.relatedBill1(relatedBill1)
|
.relatedBill1(relatedBill1)
|
||||||
.code(code)
|
.code(code)
|
||||||
|
.area(area)
|
||||||
.status(BizStatus.OPEN)
|
.status(BizStatus.OPEN)
|
||||||
.orderDate(new Timestamp(new Date().getTime()))
|
.orderDate(new Timestamp(new Date().getTime()))
|
||||||
.orderQuantity(orderQty)
|
.orderQuantity(orderQty)
|
||||||
|
.billType(billType)
|
||||||
|
.receivedQuantity(0d)
|
||||||
|
.putawayQuantity(0d)
|
||||||
.build();
|
.build();
|
||||||
asnMap.put(code, asn);
|
asnMap.put(code, asn);
|
||||||
insertToAsn.add(asn);
|
insertToAsn.add(asn);
|
||||||
|
|
@ -532,10 +542,17 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
AsnDetail asnDetail = AsnDetail.builder()
|
AsnDetail asnDetail = AsnDetail.builder()
|
||||||
.propC2(propC2)
|
.propC2(propC2)
|
||||||
.po(po)
|
.po(po)
|
||||||
.item(exitItemMap.get(itemCode))
|
.item(item)
|
||||||
.remark( remark)
|
.remark( remark)
|
||||||
.orderQty(orderQty)
|
.orderQty(orderQty)
|
||||||
.asn(asn)
|
.asn(asn)
|
||||||
|
.status(BizStatus.OPEN)
|
||||||
|
.receivedQty(0d)
|
||||||
|
.moveQty(0d)
|
||||||
|
.putQty(0d)
|
||||||
|
.weight(0d)
|
||||||
|
.volume(0d)
|
||||||
|
.dept(item.getDept())
|
||||||
.build();
|
.build();
|
||||||
insertToAsnDetail.add(asnDetail);
|
insertToAsnDetail.add(asnDetail);
|
||||||
}
|
}
|
||||||
|
|
@ -590,6 +607,8 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
// 获取两个集合的交集说明ASN重复导入了,直接提示
|
// 获取两个集合的交集说明ASN重复导入了,直接提示
|
||||||
List<String> difference = SmartStringUtil.getIntersection(codes, existingAsnCodes);
|
List<String> difference = SmartStringUtil.getIntersection(codes, existingAsnCodes);
|
||||||
if (CollectionUtils.isNotEmpty(difference)) {
|
if (CollectionUtils.isNotEmpty(difference)) {
|
||||||
|
//去重difference
|
||||||
|
difference = difference.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
throw new BadRequestException(difference + "托盘号已导入,请勿重复导入");
|
throw new BadRequestException(difference + "托盘号已导入,请勿重复导入");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,5 +82,10 @@ public interface BaseStatus {
|
||||||
* 单据类型-单点
|
* 单据类型-单点
|
||||||
*/
|
*/
|
||||||
public static String BT_DD = "单点";
|
public static String BT_DD = "单点";
|
||||||
|
/**
|
||||||
|
* 单据类型-正常入库
|
||||||
|
*/
|
||||||
|
public static String RK = "正常入库";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue