提交 82255fd8 作者: luyincheng

辅材导入返回物料编码、名称同时验证发货数量不能大于审批数量

父级 e3299a99
...@@ -12,6 +12,7 @@ import com.starcharge.wios.vo.DeliveryAddVo; ...@@ -12,6 +12,7 @@ import com.starcharge.wios.vo.DeliveryAddVo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.Validator; import javax.validation.Validator;
...@@ -46,9 +47,9 @@ public class AuxiliaryMaterialDeliveryImport implements Import { ...@@ -46,9 +47,9 @@ public class AuxiliaryMaterialDeliveryImport implements Import {
List<String> rowdata = (List<String>)list.get(i); List<String> rowdata = (List<String>)list.get(i);
DeliveryAddVo deliveryAddVo=new DeliveryAddVo(); DeliveryAddVo deliveryAddVo=new DeliveryAddVo();
deliveryAddVo.setInstallOrder(rowdata.get(0)); deliveryAddVo.setInstallOrder(rowdata.get(0));
deliveryAddVo.setLogisticOrder(rowdata.get(1)); //deliveryAddVo.setLogisticOrder(rowdata.get(1));
try { try {
deliveryAddVo.setQuantity(Integer.parseInt(rowdata.get(2))); deliveryAddVo.setQuantity(Float.parseFloat(rowdata.get(1)));
}catch (Exception e){ }catch (Exception e){
rowdata.add("error:发货数量必填且为整数"); rowdata.add("error:发货数量必填且为整数");
} }
...@@ -70,9 +71,26 @@ public class AuxiliaryMaterialDeliveryImport implements Import { ...@@ -70,9 +71,26 @@ public class AuxiliaryMaterialDeliveryImport implements Import {
List<Tauxiliarymaterials> tauxiliarymaterials=this.tauxiliarymaterialsMapper.selectTAuxiliaryMaterialsList(tauxiliarymaterialsquery); List<Tauxiliarymaterials> tauxiliarymaterials=this.tauxiliarymaterialsMapper.selectTAuxiliaryMaterialsList(tauxiliarymaterialsquery);
if(CollectionUtils.isEmpty(tauxiliarymaterials)){ if(CollectionUtils.isEmpty(tauxiliarymaterials)){
rowdata.add("error:找不到已审批通过辅材申请单"); rowdata.add("error:找不到已审批通过辅材申请单");
}else if(tauxiliarymaterials.stream().noneMatch(t->TauxiliarymaterialStatusEnum.未发货.name().equals(t.getLogisticStatus()))){ continue;
}
Tauxiliarymaterials tauxiliarymaterial= tauxiliarymaterials.stream().filter(t->TauxiliarymaterialStatusEnum.未发货.name().equals(t.getLogisticStatus())).findFirst().orElse(null);
if(tauxiliarymaterial==null){
rowdata.add("");
rowdata.add("");
rowdata.add("");
rowdata.add("error:找不到已审批且未发货的辅材申请单"); rowdata.add("error:找不到已审批且未发货的辅材申请单");
}else{
rowdata.add(tauxiliarymaterial.getMaterialCode());
rowdata.add(tauxiliarymaterial.getMaterialName());
rowdata.add(tauxiliarymaterial.getApprovedQuantity());
if(!StringUtils.hasLength(tauxiliarymaterial.getApprovedQuantity())){
tauxiliarymaterial.setApprovedQuantity("0");
}
if(deliveryAddVo.getQuantity()>Float.parseFloat(tauxiliarymaterial.getApprovedQuantity())){
rowdata.add("error:发货数量大于已审批数量");
}
} }
} }
return list; return list;
} }
......
...@@ -56,7 +56,7 @@ public class DeliveryAddVo { ...@@ -56,7 +56,7 @@ public class DeliveryAddVo {
*/ */
@ApiModelProperty(value = "发货数量") @ApiModelProperty(value = "发货数量")
@Min(value = 1,groups = CreateEntityGroup.class,message = "发货数量必须大于0") @Min(value = 1,groups = CreateEntityGroup.class,message = "发货数量必须大于0")
private Integer quantity; private Float quantity;
/** /**
* 物料类别 * 物料类别
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论