yzc 2 жил өмнө
parent
commit
756c024553

+ 10 - 4
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -275,6 +275,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         if (ObjectUtil.isEmpty(productInfoEhsdJson.getCustomerId())) {
             //如果客户id为空就赋值为0 公司产品
             productInfoEhsdJson.setCustomerId(0l);
+            productInfoEhsdJson.setType("1");//默认公司产品
         }
         productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
 
@@ -307,10 +308,15 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         ProductInfoVo result = BeanUtil.toBean(ProductInfo, ProductInfoVo.class);
 
         ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(result.getEhsdJson(), ProductInfoEhsdJson.class);
-        //赋值客户名称
-        Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
-        productInfoEhsdJson.setCustomerName(customer.getName());
-        result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
+        //判断客户id不为空
+        if (ObjectUtil.isNotEmpty(productInfoEhsdJson) && ObjectUtil.isNotEmpty(productInfoEhsdJson.getCustomerId())) {
+            //赋值客户名称
+            Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
+            if(ObjectUtil.isNotEmpty(customer)) {
+                productInfoEhsdJson.setCustomerName(customer.getName());
+                result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
+            }
+        }
         //赋值创建人名称
         UserUtil.assignmentNickName(Arrays.asList(result), ProductInfoVo::getCreateUser, ProductInfoVo::setCreateUserName);
         return result;