|
@@ -69,7 +69,10 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
|
|
|
for (int k = 0; k < dmpProductInfo.size(); k++) {
|
|
|
if (checkNameUnique(dmpProductInfo.get(k))){
|
|
|
- throw new BusinessException("新增产品信息'" + dmpProductInfo.get(k).getProductCode() + "'失败,产品信息已存在");
|
|
|
+ throw new BusinessException("新增产品信息'" + dmpProductInfo.get(k).getProductCode() + "'失败,产品编码已存在");
|
|
|
+ }
|
|
|
+ if (checkProductNameUnique(dmpProductInfo.get(k))){
|
|
|
+ throw new BusinessException("新增产品信息'" + dmpProductInfo.get(k).getProductName() + "'失败,产品名称已存在");
|
|
|
}
|
|
|
int deviceType = dmpProductInfo.get(k).getDeviceType();
|
|
|
LambdaQueryWrapper<DmpDeviceType> queryWrapper = Wrappers.lambdaQuery();
|
|
@@ -111,8 +114,6 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
int data_type = obj.getInteger("data_type");
|
|
|
int attribute_length = obj.getInteger("attribute_length");
|
|
|
String attribute_unit = obj.getString("attribute_unit");
|
|
|
- int maximum = obj.getInteger("maximum");
|
|
|
- int minimum = obj.getInteger("minimum");
|
|
|
|
|
|
DmpProductAttribute dmpProductAttribute = new DmpProductAttribute();
|
|
|
dmpProductAttribute.setProductId(productId);
|
|
@@ -123,8 +124,12 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
dmpProductAttribute.setDataType(data_type);
|
|
|
dmpProductAttribute.setAttributeLength(attribute_length);
|
|
|
dmpProductAttribute.setAttributeUnit(attribute_unit);
|
|
|
- dmpProductAttribute.setMaximum(BigDecimal.valueOf(maximum));
|
|
|
- dmpProductAttribute.setMinimum(BigDecimal.valueOf(minimum));
|
|
|
+ if(Objects.nonNull(obj.getInteger("maximum"))){
|
|
|
+ dmpProductAttribute.setMaximum(BigDecimal.valueOf(obj.getInteger("maximum")));
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(obj.getInteger("minimum"))){
|
|
|
+ dmpProductAttribute.setMinimum(BigDecimal.valueOf(obj.getInteger("minimum")));
|
|
|
+ }
|
|
|
if(!(obj.getString("attribute_dict")).equals("")){
|
|
|
dmpProductAttribute.setAttributeDict(obj.getString("attribute_dict"));
|
|
|
}
|
|
@@ -181,7 +186,10 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
public void update(DmpProductInfo dmpProductInfo) {
|
|
|
dmpProductInfo.setUpdatedTime(new Date());
|
|
|
if (checkNameUnique(dmpProductInfo)){
|
|
|
- throw new BusinessException("修改产品信息'" + dmpProductInfo.getProductCode() + "'失败,产品信息已存在");
|
|
|
+ throw new BusinessException("修改产品信息'" + dmpProductInfo.getProductCode() + "'失败,产品编码已存在");
|
|
|
+ }
|
|
|
+ if (checkProductNameUnique(dmpProductInfo)){
|
|
|
+ throw new BusinessException("修改产品信息'" + dmpProductInfo.getProductName() + "'失败,产品名称已存在");
|
|
|
}
|
|
|
this.updateById(dmpProductInfo);
|
|
|
}
|
|
@@ -197,6 +205,17 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
return null != one && !Objects.equals(one.getId(), id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean checkProductNameUnique(DmpProductInfo dmpProductInfo) { //根据产品名称判断唯一
|
|
|
+ Integer id = null == dmpProductInfo.getId() ? -1 : dmpProductInfo.getId();
|
|
|
+ LambdaQueryWrapper<DmpProductInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpProductInfo::getProductName,dmpProductInfo.getProductName())
|
|
|
+ .eq(DmpProductInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
+ .eq(DmpProductInfo::getDeleteFlag,0);
|
|
|
+ DmpProductInfo one = this.getOne(queryWrapper);
|
|
|
+ return null != one && !Objects.equals(one.getId(), id);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public CommonPage<DmpProductInfo> page(DmpProductInfoRequest piRequest) {
|