Selaa lähdekoodia

调拨调整

master
yangpeilai 2 kuukautta sitten
vanhempi
commit
e709175174

+ 2
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/warehouse/InvwWarehouseDetailRequestDTO.java Näytä tiedosto

package cn.com.taiji.invw.dto.warehouse; package cn.com.taiji.invw.dto.warehouse;


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

+ 20
- 13
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/transfer/InvwTransferApplyManagerImpl.java Näytä tiedosto

import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


import java.math.BigInteger;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;


String startId = details.getStartId(); String startId = details.getStartId();
String endId = details.getEndId(); 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("调拨申请失败,结束编号不能小于起始编号"); 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 { } else {
throw new ManagerException("调拨申请失败,请检查设备类型是否正确"); 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) { public static void main(String[] args) {

Loading…
Peruuta
Tallenna