|
|
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigInteger; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
@@ -312,25 +313,31 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements |
|
|
|
|
|
|
|
String startId = details.getStartId(); |
|
|
|
String endId = details.getEndId(); |
|
|
|
long start = Long.parseLong(startId); |
|
|
|
long end = Long.parseLong(endId); |
|
|
|
if (end < start) { |
|
|
|
BigInteger start = new BigInteger(startId); |
|
|
|
BigInteger end = new BigInteger(endId); |
|
|
|
|
|
|
|
// 使用 BigInteger 的 compareTo 方法进行比较 |
|
|
|
if (end.compareTo(start) < 0) { |
|
|
|
throw new ManagerException("调拨申请失败,结束编号不能小于起始编号"); |
|
|
|
} |
|
|
|
long total = end - start + 1; |
|
|
|
long count = 0; |
|
|
|
if (InventoryType.CARD == inventoryType) { |
|
|
|
count = cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId()); |
|
|
|
// count = cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, 1, details.getStartId(), details.getEndId()); |
|
|
|
} else if (InventoryType.OBU == inventoryType) { |
|
|
|
count = obuDetailsRepo.findCountByStoreCodeStatusObuId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId()); |
|
|
|
|
|
|
|
// 使用 BigInteger 的 subtract 和 add 方法进行计算 |
|
|
|
BigInteger total = end.subtract(start).add(BigInteger.ONE); |
|
|
|
BigInteger count; |
|
|
|
|
|
|
|
if (InventoryType.CARD.equals(inventoryType)) { |
|
|
|
count = BigInteger.valueOf(cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId())); |
|
|
|
} else if (InventoryType.OBU.equals(inventoryType)) { |
|
|
|
count = BigInteger.valueOf(obuDetailsRepo.findCountByStoreCodeStatusObuId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId())); |
|
|
|
} else { |
|
|
|
throw new ManagerException("调拨申请失败,请检查设备类型是否正确"); |
|
|
|
} |
|
|
|
if (count != total) { |
|
|
|
throw new ManagerException("库存校验失败,该仓库["+start+"-"+end+"]号段在库设备量为:"+count); |
|
|
|
|
|
|
|
if (count.compareTo(total) != 0) { |
|
|
|
throw new ManagerException("库存校验失败,该仓库[" + start + "-" + end + "]号段在库设备量为:" + count); |
|
|
|
} |
|
|
|
return total; |
|
|
|
|
|
|
|
return total.longValueExact(); // 使用 longValueExact 确保可以安全转换为 long |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |