no message
							parent
							
								
									8d901caf5f
								
							
						
					
					
						commit
						3c8a28ad7c
					
				| 
						 | 
				
			
			@ -73,8 +73,8 @@ import static org.springframework.http.HttpStatus.OK;
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @website https://eladmin.vip
 | 
			
		||||
 * @author houjianlan
 | 
			
		||||
 * @website https://eladmin.vip
 | 
			
		||||
 * @date 2023-08-16
 | 
			
		||||
 **/
 | 
			
		||||
@RestController
 | 
			
		||||
| 
						 | 
				
			
			@ -91,6 +91,7 @@ public class ImportDataController {
 | 
			
		|||
    private final PickTicketService pickTicketService;
 | 
			
		||||
    private final PickDetailService pickDetailService;
 | 
			
		||||
    private final CodeUtils codeUtils;
 | 
			
		||||
 | 
			
		||||
    @Log("导入完成品品番")
 | 
			
		||||
    @ApiOperation("导入完成品品番")
 | 
			
		||||
    @PostMapping(value = "/bigItem")
 | 
			
		||||
| 
						 | 
				
			
			@ -112,6 +113,7 @@ public class ImportDataController {
 | 
			
		|||
        }
 | 
			
		||||
        return new ResponseEntity("导入成功", HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Log("导入部品品番")
 | 
			
		||||
    @ApiOperation("导入部品品番")
 | 
			
		||||
    @PostMapping(value = "/item")
 | 
			
		||||
| 
						 | 
				
			
			@ -136,6 +138,7 @@ public class ImportDataController {
 | 
			
		|||
        }
 | 
			
		||||
        return new ResponseEntity("导入成功:执行" + (a + b) + "行 新增" + a + "行,修改" + b + "行", HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Log("导入其他入库")
 | 
			
		||||
    @ApiOperation("导入其他入库")
 | 
			
		||||
    @PostMapping(value = "/importAsnDetail")
 | 
			
		||||
| 
						 | 
				
			
			@ -148,8 +151,7 @@ public class ImportDataController {
 | 
			
		|||
        if (asn == null) {
 | 
			
		||||
            throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据不存在");
 | 
			
		||||
        }
 | 
			
		||||
        if(!asn.getStatus().equals(BizStatus.OPEN))
 | 
			
		||||
        {
 | 
			
		||||
        if (!asn.getStatus().equals(BizStatus.OPEN)) {
 | 
			
		||||
            throw new BadRequestException(HttpStatus.NOT_FOUND, "该单据状态不正确");
 | 
			
		||||
        }
 | 
			
		||||
        for (int i = 0; i < readAll.size(); i++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -160,6 +162,7 @@ public class ImportDataController {
 | 
			
		|||
        }
 | 
			
		||||
        return new ResponseEntity("导入成功", HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Log("导入其他出库")
 | 
			
		||||
    @ApiOperation("导入其他出库")
 | 
			
		||||
    @PostMapping(value = "/importPickDetail")
 | 
			
		||||
| 
						 | 
				
			
			@ -172,8 +175,7 @@ public class ImportDataController {
 | 
			
		|||
        if (pt == null) {
 | 
			
		||||
            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, "该单据状态不正确");
 | 
			
		||||
        }
 | 
			
		||||
        for (int i = 0; i < readAll.size(); i++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -227,6 +229,7 @@ public class ImportDataController {
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * 解析导入文件
 | 
			
		||||
     *
 | 
			
		||||
     * @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("导入开始");
 | 
			
		||||
        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);
 | 
			
		||||
        } 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
 | 
			
		||||
    @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 + "托盘号已导入,请勿重复导入");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,5 +82,10 @@ public interface BaseStatus {
 | 
			
		|||
     * 单据类型-单点
 | 
			
		||||
     */
 | 
			
		||||
    public static String BT_DD = "单点";
 | 
			
		||||
    /**
 | 
			
		||||
     * 单据类型-正常入库
 | 
			
		||||
     */
 | 
			
		||||
    public static String RK = "正常入库";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue