原材料入库
							parent
							
								
									03a3ea7e05
								
							
						
					
					
						commit
						03b8fbe116
					
				| 
						 | 
					@ -65,7 +65,7 @@ public class BydAppController {
 | 
				
			||||||
    @AnonymousAccess
 | 
					    @AnonymousAccess
 | 
				
			||||||
    public ResponseEntity<Object> bindStock(@RequestBody BindStock bindStock) {
 | 
					    public ResponseEntity<Object> bindStock(@RequestBody BindStock bindStock) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            //二维码格式:P:A17A;V:148795;M:DP_001/PCS;B:240512JFET;Lot:20240427;S:124051200181131;PO:5913490946/00020;Q:36/20/32;D:2024-04-27;SN:;YX:2025-04-26;DN:D12405120005031AS;
 | 
					            //二维码格式:P:A17A;V:148795;M:DP_001/PCS;B:240512JFET;Lot:20240427;S:124051200181131;PO:5913490946/00020;Q:36/20/32;D:2024-04-27;SN:;YX:2025-04-26;DN:D12405120005031AS
 | 
				
			||||||
            String QRCode = bindStock.getItemCode();//Mo票二维码
 | 
					            String QRCode = bindStock.getItemCode();//Mo票二维码
 | 
				
			||||||
            String stockCode = bindStock.getStockCode();//容器编号
 | 
					            String stockCode = bindStock.getStockCode();//容器编号
 | 
				
			||||||
            String pointCode = bindStock.getPointCode();//点位编号
 | 
					            String pointCode = bindStock.getPointCode();//点位编号
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,10 +279,14 @@ public class StockServiceImpl implements StockService {
 | 
				
			||||||
        String gdh = map.get("S");//工单号
 | 
					        String gdh = map.get("S");//工单号
 | 
				
			||||||
        String propC3 = map.get("P");//工厂
 | 
					        String propC3 = map.get("P");//工厂
 | 
				
			||||||
        String propD1 = map.get("D");//生产日期
 | 
					        String propD1 = map.get("D");//生产日期
 | 
				
			||||||
        double orderQty = Double.parseDouble(getStringCode(map.get("Q")));
 | 
					        double orderQty = Double.parseDouble(getStringCode(map.get("Q")));//数量
 | 
				
			||||||
 | 
					        if (asnDetailService.findByMo(QRCode)) {
 | 
				
			||||||
 | 
					            throw new RuntimeException("该MO票已入库,请勿重复操作!");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        Item item = validateItem(getStringCode(map.get("M")));//验证物料
 | 
					        Item item = validateItem(getStringCode(map.get("M")));//验证物料
 | 
				
			||||||
        Stock stock = validateStock(stockCode);//验证容器
 | 
					        Stock stock = validateStock(stockCode);//验证容器
 | 
				
			||||||
        validateStockStatus(stock);//验证容器状态
 | 
					        validateStockStatus(stock);//验证容器状态
 | 
				
			||||||
 | 
					        validateStockAndItem(stock, item);//验证容器类型和物料类型是否匹配
 | 
				
			||||||
        Point srcPoint = validateSrcPoint(pointCode);//验证点位
 | 
					        Point srcPoint = validateSrcPoint(pointCode);//验证点位
 | 
				
			||||||
        String srcPointAreaName = srcPoint.getArea().getName();
 | 
					        String srcPointAreaName = srcPoint.getArea().getName();
 | 
				
			||||||
        if (!isValidMCArea(srcPointAreaName)) {
 | 
					        if (!isValidMCArea(srcPointAreaName)) {
 | 
				
			||||||
| 
						 | 
					@ -297,7 +301,7 @@ public class StockServiceImpl implements StockService {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        String areaName = stockTypeToAreaMap.get(stock.getStockType());
 | 
					        String areaName = stockTypeToAreaMap.get(stock.getStockType());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Point endPoint = validateEndPoint(item,areaName);//验证目标点位
 | 
					        Point endPoint = validateEndPoint(item, areaName);//验证目标点位
 | 
				
			||||||
        checkPointStatus(srcPoint);//验证源点位状态
 | 
					        checkPointStatus(srcPoint);//验证源点位状态
 | 
				
			||||||
        AgvTask agvTask = createAndSendAgvTask(BizStatus.ASN, stock, srcPoint, endPoint);//生成AGV任务
 | 
					        AgvTask agvTask = createAndSendAgvTask(BizStatus.ASN, stock, srcPoint, endPoint);//生成AGV任务
 | 
				
			||||||
        AsnDetail asnDetail = asnDetailService.createAsnDetail(item, stock, srcPoint, propC1, gdh, propC3, Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(propD1))), orderQty, QRCode);
 | 
					        AsnDetail asnDetail = asnDetailService.createAsnDetail(item, stock, srcPoint, propC1, gdh, propC3, Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(propD1))), orderQty, QRCode);
 | 
				
			||||||
| 
						 | 
					@ -306,6 +310,16 @@ public class StockServiceImpl implements StockService {
 | 
				
			||||||
        updateStockAndPoints(stock, srcPoint, endPoint);
 | 
					        updateStockAndPoints(stock, srcPoint, endPoint);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void validateStockAndItem(Stock stock, Item item) {
 | 
				
			||||||
 | 
					        if (item.getGoodType().contains("大件") || item.getGoodType().contains("小件")) {
 | 
				
			||||||
 | 
					            if (!item.getGoodType().substring(0, 2).equals(stock.getStockType().substring(0, 2))) {
 | 
				
			||||||
 | 
					                throw new RuntimeException("物料类型和容器类型不匹配!");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Map<String, String> parseString(String QRCode) {
 | 
					    private Map<String, String> parseString(String QRCode) {
 | 
				
			||||||
        //P:工厂;V:客户编号;M:物料编号/PCS;B:BYD批次;Lot:供应商批次号;S:工单编号;PO:采购订单/箱号;Q:数量;D:生产日期;YX:有效天数;
 | 
					        //P:工厂;V:客户编号;M:物料编号/PCS;B:BYD批次;Lot:供应商批次号;S:工单编号;PO:采购订单/箱号;Q:数量;D:生产日期;YX:有效天数;
 | 
				
			||||||
        // 使用分号分隔字符串
 | 
					        // 使用分号分隔字符串
 | 
				
			||||||
| 
						 | 
					@ -320,9 +334,6 @@ public class StockServiceImpl implements StockService {
 | 
				
			||||||
                resultMap.put(key, value);
 | 
					                resultMap.put(key, value);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for (String key : resultMap.keySet()) {
 | 
					 | 
				
			||||||
            log.info("key:{" + key + "},value:{" + resultMap.get(key) + "}");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return resultMap;
 | 
					        return resultMap;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -371,19 +382,19 @@ public class StockServiceImpl implements StockService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Point validateSrcPoint(String pointCode) {
 | 
					    private Point validateSrcPoint(String pointCode) {
 | 
				
			||||||
        Point srcPoint = pointService.findByCode(pointCode, null, null, null, null,null);
 | 
					        Point srcPoint = pointService.findByCode(pointCode, null, null, null, null, null);
 | 
				
			||||||
        if (srcPoint == null) {
 | 
					        if (srcPoint == null) {
 | 
				
			||||||
            throw new RuntimeException("请扫描正确点位!");
 | 
					            throw new RuntimeException("请扫描正确点位!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return srcPoint;
 | 
					        return srcPoint;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Point validateEndPoint(Item item,String areaName) {
 | 
					    private Point validateEndPoint(Item item, String areaName) {
 | 
				
			||||||
        Double itemHeight = null;
 | 
					        Double itemHeight = null;
 | 
				
			||||||
        if("小件存储区".equals(areaName)){
 | 
					        if ("小件存储区".equals(areaName)) {
 | 
				
			||||||
            itemHeight=item.getExtendD2();//整托高度
 | 
					            itemHeight = item.getExtendD2();//整托高度
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Point endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaName, null,itemHeight);
 | 
					        Point endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaName, null, itemHeight);
 | 
				
			||||||
        if (endPoint == null) {
 | 
					        if (endPoint == null) {
 | 
				
			||||||
            throw new RuntimeException(areaName + "没有空闲点位!");
 | 
					            throw new RuntimeException(areaName + "没有空闲点位!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue