yangpeilai 2 тижднів тому
джерело
коміт
e709175174

+ 2
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/warehouse/InvwWarehouseDetailRequestDTO.java Переглянути файл

@@ -1,5 +1,6 @@
package cn.com.taiji.invw.dto.warehouse;

import cn.com.taiji.invw.dto.AbstractBizRequestDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -12,7 +13,7 @@ import javax.validation.constraints.NotBlank;
@Getter
@Setter
@Accessors(chain = true)
public class InvwWarehouseDetailRequestDTO {
public class InvwWarehouseDetailRequestDTO extends AbstractBizRequestDTO {
@ApiModelProperty(value = "仓库ID")
@NotBlank(message = "id不能为空")
private String id;

+ 20
- 13
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/transfer/InvwTransferApplyManagerImpl.java Переглянути файл

@@ -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) {

Завантаження…
Відмінити
Зберегти