浏览代码

add ComponentTypeName Attributes

xiewenjie 4 年之前
父节点
当前提交
2654535df1

+ 1 - 1
sxz-base/src/main/java/com/fdkk/sxz/util/OkHttpUtils.java

@@ -182,7 +182,7 @@ public class OkHttpUtils {
         try {
             Response response = okHttpClient.newCall(request).execute();
             if (response.code() == 200) {
-                log.info("http Post 请求成功; [url={}, requestContent={}]", url, json);
+                log.info("http Post 请求成功; [url={}, requestContent={},return={}]", url, json,response.body().string());
                 return response.body().string();
             } else {
                 log.warn("Http POST 请求失败; [ errorCode = {}, url={}, param={}]", response.code(), url, json);

+ 1 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IModelUploadService.java

@@ -27,7 +27,7 @@ public interface IModelUploadService extends IBaseService<ModelUploadEntity> {
 
     ModelUploadEntity findById(Long id);
 
-    boolean updateById(ModelUploadEntity entity) ;
+    boolean updateById(ModelUploadEntity entity);
 
     boolean removeById(Long id) ;
 

+ 8 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomComponentClassifyService.java

@@ -1,6 +1,7 @@
 package com.fdkk.sxz.webApi.service.custom;
 
 import com.fdkk.sxz.base.IBaseService;
+import com.fdkk.sxz.entity.ModelUploadEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.vo.request.RequestCustomComponentClassify;
 import com.github.pagehelper.PageInfo;
@@ -16,4 +17,11 @@ public interface ICustomComponentClassifyService extends IBaseService<CustomComp
 
   PageInfo<CustomComponentClassifyEntity> listByPage(RequestCustomComponentClassify param);
 
+
+  CustomComponentClassifyEntity findById(Long id);
+
+  boolean updateById(CustomComponentClassifyEntity entity) ;
+
+  boolean removeById(Long id) ;
+
 }

+ 35 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomComponentClassifyServiceImpl.java

@@ -1,16 +1,19 @@
 package com.fdkk.sxz.webApi.service.custom.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
+import com.fdkk.sxz.entity.ModelUploadEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.vo.request.RequestCustomComponentClassify;
 import com.fdkk.sxz.webApi.mapper.custom.ICustomComponentClassifyMapper;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
 import com.github.pagehelper.PageInfo;
+import net.oschina.j2cache.CacheChannel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -26,14 +29,45 @@ public class CustomComponentClassifyServiceImpl extends BaseServiceImpl<ICustomC
     @Autowired
     private ICustomComponentClassifyMapper customComponentClassifyMapper;
 
+    @Autowired
+    private CacheChannel cacheChannel;
 
 
     @Override
     public PageInfo<CustomComponentClassifyEntity> listByPage(RequestCustomComponentClassify param) {
             LambdaQueryWrapper<CustomComponentClassifyEntity> wrapper =  Wrappers.lambdaQuery();
           //  if (ObjectUtil.isNotNull(param.getId())){
-          //      wrapper.eq(CustomEntity::getId,param.getId());
+          //      wrapper.eq(CustomEntity:getId,param.getId());
           //  }
             return super.listByPage(param,wrapper);
     }
+
+    @Override
+    public boolean removeById(Long id) {
+        boolean removeById=super.removeById(id);
+        if (removeById){
+            cacheChannel.evict("CustomComponentClassifyEntity","id::"+id);
+        }
+        return removeById;
+    }
+
+    @Override
+    public CustomComponentClassifyEntity findById(Long id) {
+        CustomComponentClassifyEntity entity=super.findById(id);
+        if (ObjectUtil.isNotNull(entity)){
+            cacheChannel.set("CustomComponentClassifyEntity","id:"+entity.getId(),entity,60*30 );
+        }
+        return super.findById(id);
+    }
+
+    @Override
+    public boolean updateById(CustomComponentClassifyEntity entity) {
+        boolean updateById=super.updateById(entity);
+        if (updateById){
+            cacheChannel.set("CustomComponentClassifyEntity","id:"+entity.getId(),entity,60*30  );
+        }
+        return updateById;
+    }
+
+
 }

+ 36 - 24
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomProductServiceImpl.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
+import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
 import com.fdkk.sxz.entity.custuom.CustomProductEntity;
 import com.fdkk.sxz.vo.request.RequestCustom;
@@ -19,6 +20,7 @@ import com.fdkk.sxz.vo.response.ResponseCustomComponent;
 import com.fdkk.sxz.vo.response.ResponseCustomProduct;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
 import com.fdkk.sxz.webApi.mapper.custom.ICustomProductMapper;
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
 import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
 import com.github.pagehelper.PageInfo;
@@ -48,52 +50,62 @@ public class CustomProductServiceImpl extends BaseServiceImpl<ICustomProductMapp
     @Autowired
     private ICustomComponentService customComponentService;
 
+    private ICustomComponentClassifyService componentClassifyService;
+
 
     @Override
     public PageInfo<CustomProductEntity> listByPage(RequestCustomProduct param) {
-        LambdaQueryWrapper<CustomProductEntity> wrapper =  Wrappers.lambdaQuery();
-        if (ObjectUtil.isNotNull(param.getName())&&StrUtil.isNotEmpty(param.getName())){
-              wrapper.like(CustomProductEntity::getName,param.getName());
+        LambdaQueryWrapper<CustomProductEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getName()) && StrUtil.isNotEmpty(param.getName())) {
+            wrapper.like(CustomProductEntity::getName, param.getName());
         }
-        if (ObjectUtil.isNotNull(param.getUserId())){
-            wrapper.eq(CustomProductEntity::getUserId,param.getUserId());
+        if (ObjectUtil.isNotNull(param.getUserId())) {
+            wrapper.eq(CustomProductEntity::getUserId, param.getUserId());
         }
         param.setOrderBy("create_time");
         param.setSortBy("desc");
-        return listByPage(param,wrapper);
+        return listByPage(param, wrapper);
     }
 
 
     @Override
     public List<ResponseCustomProduct> findProductByParentId(RequestCustom param) {
-        LambdaQueryWrapper<CustomProductEntity> wrapper =  Wrappers.lambdaQuery();
-          if (ObjectUtil.isNotNull(param.getParentId())){
-              wrapper.eq(CustomProductEntity::getParentId,param.getParentId());
-          }
-        wrapper.eq(CustomProductEntity::getIsShow,1);
-        wrapper.eq(CustomProductEntity::getExamine,1);
-        List<CustomProductEntity> list= this.list(wrapper);
-        List<ResponseCustomProduct> bList = list.stream().map(a ->{
+        LambdaQueryWrapper<CustomProductEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getParentId())) {
+            wrapper.eq(CustomProductEntity::getParentId, param.getParentId());
+        }
+        wrapper.eq(CustomProductEntity::getIsShow, 1);
+        wrapper.eq(CustomProductEntity::getExamine, 1);
+        List<CustomProductEntity> list = this.list(wrapper);
+        List<ResponseCustomProduct> bList = list.stream().map(a -> {
             //在此转把A转换为B
             ResponseCustomProduct responseCustomProduct = new ResponseCustomProduct();
             BeanUtils.copyProperties(a, responseCustomProduct);
             responseCustomProduct.setType("product");
             //组装配件
-            if (StrUtil.isNotEmpty(a.getComponentTypeIds())){
-                List<ResponseCustomComponent> responseCustomComponents= new ArrayList<>();
-                JSONArray components=JSONArray.parseArray(a.getComponentTypeIds());
+            if (StrUtil.isNotEmpty(a.getComponentTypeIds())) {
+                List<ResponseCustomComponent> responseCustomComponents = new ArrayList<>();
+                JSONArray components = JSONArray.parseArray(a.getComponentTypeIds());
                 //获取每个配件加入集合
-                components.forEach(c->{
-                    Long  id=Long.valueOf((String) c);
-                    CustomComponentEntity componentEntity= customComponentService.findById(id);
+                components.forEach(c -> {
+                    Long id = Long.valueOf((String) c);
+                    CustomComponentEntity componentEntity = customComponentService.findById(id);
                     if (ObjectUtil.isNotNull(componentEntity)) {
                         ResponseCustomComponent responseCustomComponent = new ResponseCustomComponent();
                         BeanUtils.copyProperties(componentEntity, responseCustomComponent);
-                        JSONObject origin=new JSONObject();
-                        origin.put("x",componentEntity.getX());
-                        origin.put("y",componentEntity.getY());
-                        origin.put("z",componentEntity.getZ());
+                        JSONObject origin = new JSONObject();
+                        origin.put("x", componentEntity.getX());
+                        origin.put("y", componentEntity.getY());
+                        origin.put("z", componentEntity.getZ());
                         responseCustomComponent.setOrigin(origin);
+
+
+                        if (ObjectUtil.isNotNull(responseCustomComponent.getComponentTypeId())) {
+                            CustomComponentClassifyEntity componentClassifyEntity = componentClassifyService.findById(responseCustomComponent.getComponentTypeId());
+                            if (ObjectUtil.isNotNull(componentClassifyEntity)) {
+                                responseCustomComponent.setComponentTypeName(componentClassifyEntity.getName());
+                            }
+                        }
                         responseCustomComponents.add(responseCustomComponent);
                     }
                 });

+ 4 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ModelUploadServiceImpl.java

@@ -86,10 +86,13 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
 
     @Override
     public boolean removeById(Long id) {
+        ModelUploadEntity entity= findById(id);
         boolean removeById=super.removeById(id);
         if (removeById){
             cacheChannel.evict("ModelUploadEntity","id::"+id);
-            cacheChannel.evict("ModelUploadEntity","fileId::"+id);
+            if (ObjectUtil.isNotNull(entity)) {
+                cacheChannel.evict("ModelUploadEntity","fileId::"+entity.getFileId());
+            }
         }
         return removeById;
     }