소스 검색

invw入库管理调整接口

master
huminghao 2 달 전
부모
커밋
ed78217627

+ 30
- 30
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/enter/InvwEnterApplyCodeValidRequestDTO.java 파일 보기

import cn.com.taiji.core.entity.dict.basic.ObuType; import cn.com.taiji.core.entity.dict.basic.ObuType;
import cn.com.taiji.core.entity.dict.invw.InventoryType; import cn.com.taiji.core.entity.dict.invw.InventoryType;
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO;
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel;
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;


import javax.persistence.EnumType; import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.List;


/** /**
* @Auther: humh * @Auther: humh
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private ObuType obuType; private ObuType obuType;


@ApiModelProperty(value = "起始-结束号段list")
@NotNull
private List<EnterApplyDetailModel> enterApplyDetailModels;
@ApiModelProperty(value = "起始编码")
@NotBlank
private String startId;

@ApiModelProperty(value = "结束编码")
@NotBlank
private String endId;

@ApiModelProperty(value = "单片式OBU时有值")
private String startCardId;

@ApiModelProperty(value = "单片式OBU时有值")
private String endCardId;



public void valid() throws ManagerException { public void valid() throws ManagerException {
if (InventoryType.CARD.equals(inventoryType)){ if (InventoryType.CARD.equals(inventoryType)){
if (cardType == null){ if (cardType == null){
throw new ManagerException("未选择卡类型"); throw new ManagerException("未选择卡类型");
} }
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) {
if (detailModel.getStartId().length() != 20 || detailModel.getEndId().length() != 20){
throw new ManagerException("卡号长度必须为20");
}
if (startId.length() != 20 || endId.length() != 20){
throw new ManagerException("卡号长度必须为20");
} }


}else if (InventoryType.OBU.equals(inventoryType)){ }else if (InventoryType.OBU.equals(inventoryType)){
if (obuType == null){ if (obuType == null){
throw new ManagerException("未选择签类型"); throw new ManagerException("未选择签类型");
} }

for (EnterApplyDetailModel detailModel : enterApplyDetailModels) {
if (StringUtils.isEmpty(detailModel.getStartId()) || StringUtils.isEmpty(detailModel.getEndId())){
throw new ManagerException("起始或结束号段未填写完整");
}
if (detailModel.getStartId().length() != 16 || detailModel.getEndId().length() != 16){
throw new ManagerException("签号长度必须为16");
}
if (startId.length() != 16 || endId.length() != 16){
throw new ManagerException("签号长度必须为16");
} }

if (ObuType.SINGLE_CHIP.equals(obuType)){ if (ObuType.SINGLE_CHIP.equals(obuType)){
if (cardType == null){ if (cardType == null){
throw new ManagerException("单片式OBU时,卡类型必填"); throw new ManagerException("单片式OBU时,卡类型必填");
} }
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) {
int obuNUm = new BigInteger(detailModel.getEndId()).subtract(new BigInteger(detailModel.getStartId())).intValueExact()+1;
int cardNUm = new BigInteger(detailModel.getEndCardId()).subtract(new BigInteger(detailModel.getStartCardId())).intValueExact()+1;
if (obuNUm != cardNUm){
throw new ManagerException("单片式OBU时,签的号段与卡的号段数量必须相同");
}
if (StringUtils.isEmpty(detailModel.getStartCardId()) || StringUtils.isEmpty(detailModel.getEndCardId())){
throw new ManagerException("单片式OBU时,卡的是的段号和结束段号必填");
}
if (detailModel.getStartCardId().length() != 20 || detailModel.getEndCardId().length() != 20){
throw new ManagerException("卡号长度必须为20");
}
if (StringUtils.isEmpty(startCardId) || StringUtils.isEmpty(endCardId)){
throw new ManagerException("单片式OBU时,卡的是的段号和结束段号必填");
}
int obuNUm = new BigInteger(endId).subtract(new BigInteger(startId)).intValueExact()+1;
int cardNUm = new BigInteger(endCardId).subtract(new BigInteger(startCardId)).intValueExact()+1;
if (obuNUm != cardNUm){
throw new ManagerException("单片式OBU时,签的号段与卡的号段数量必须相同");
} }
if (startCardId.length() != 20 || endCardId.length() != 20){
throw new ManagerException("卡号长度必须为20");
}

} }
} }
} }

+ 18
- 2
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/enter/InvwEnterApplyManagerImpl.java 파일 보기

public InvwEnterApplyCodeValidResponseDTO codeValid(InvwEnterApplyCodeValidRequestDTO dto) throws ManagerException { public InvwEnterApplyCodeValidResponseDTO codeValid(InvwEnterApplyCodeValidRequestDTO dto) throws ManagerException {
dto.valid(); dto.valid();
//校验 //校验
startIdAndEndIdValid(dto.getInventoryType(),dto.getObuType(),dto.getEnterApplyDetailModels());

// startIdAndEndIdValid(dto.getInventoryType(),dto.getObuType(),dto.getEnterApplyDetailModels());
if (InventoryType.CARD.equals(dto.getInventoryType())) {
List<InvwCardDetails> detailsList = cardDetailsRepo.queryByCardIdBetween(dto.getStartId(), dto.getEndId());
if (!CollectionTools.isEmpty(detailsList)) {
throw new ManagerException("卡号段已存在!");
}
} else if (InventoryType.OBU.equals(dto.getInventoryType())) {
List<InvwObuDetails> detailsList = obuDetailsRepo.queryByObuIdBetween(dto.getStartId(), dto.getEndId());
if (!CollectionTools.isEmpty(detailsList)) {
throw new ManagerException("签号段已存在!");
}
if (ObuType.SINGLE_CHIP.equals(dto.getObuType())) {
List<InvwCardDetails> cardDetailsList = cardDetailsRepo.queryByCardIdBetween(dto.getStartCardId(), dto.getEndCardId());
if (!CollectionTools.isEmpty(cardDetailsList)) {
throw new ManagerException("卡号段已存在!");
}
}
}
return new InvwEnterApplyCodeValidResponseDTO(true); return new InvwEnterApplyCodeValidResponseDTO(true);
} }



Loading…
취소
저장