|
@@ -1,7 +1,9 @@
|
|
package com.fdkk.sxz.webApi.service.custom.impl;
|
|
package com.fdkk.sxz.webApi.service.custom.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.file.FileReader;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -11,16 +13,15 @@ import com.fdkk.sxz.base.impl.BaseServiceImpl;
|
|
import com.fdkk.sxz.entity.ComponentModelUploadEntity;
|
|
import com.fdkk.sxz.entity.ComponentModelUploadEntity;
|
|
import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
|
|
import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
|
|
import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
|
|
import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
|
|
-import com.fdkk.sxz.entity.custuom.CustomProductEntity;
|
|
|
|
import com.fdkk.sxz.exception.BusinessException;
|
|
import com.fdkk.sxz.exception.BusinessException;
|
|
import com.fdkk.sxz.util.OkHttpUtils;
|
|
import com.fdkk.sxz.util.OkHttpUtils;
|
|
import com.fdkk.sxz.util.SnowFlakeUUidUtils;
|
|
import com.fdkk.sxz.util.SnowFlakeUUidUtils;
|
|
import com.fdkk.sxz.util.UploadToOssUtil;
|
|
import com.fdkk.sxz.util.UploadToOssUtil;
|
|
import com.fdkk.sxz.vo.request.RequestCustom;
|
|
import com.fdkk.sxz.vo.request.RequestCustom;
|
|
import com.fdkk.sxz.vo.request.RequestCustomComponent;
|
|
import com.fdkk.sxz.vo.request.RequestCustomComponent;
|
|
|
|
+import com.fdkk.sxz.vo.request.RequestDataBucket;
|
|
import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
|
|
import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
|
|
import com.fdkk.sxz.vo.response.ResponseCustomComponent;
|
|
import com.fdkk.sxz.vo.response.ResponseCustomComponent;
|
|
-import com.fdkk.sxz.vo.response.ResponseCustomProduct;
|
|
|
|
import com.fdkk.sxz.webApi.mapper.custom.ICustomComponentMapper;
|
|
import com.fdkk.sxz.webApi.mapper.custom.ICustomComponentMapper;
|
|
import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
|
|
import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
|
|
@@ -66,36 +67,36 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param) {
|
|
public PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param) {
|
|
- LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
- if (ObjectUtil.isNotNull(param.getName())&& StrUtil.isNotEmpty(param.getName())){
|
|
|
|
- wrapper.like(CustomComponentEntity::getName,param.getName());
|
|
|
|
|
|
+ LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ if (ObjectUtil.isNotNull(param.getName()) && StrUtil.isNotEmpty(param.getName())) {
|
|
|
|
+ wrapper.like(CustomComponentEntity::getName, param.getName());
|
|
}
|
|
}
|
|
- if (ObjectUtil.isNotNull(param.getUserId())){
|
|
|
|
- wrapper.eq(CustomComponentEntity::getUserId,param.getUserId());
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(param.getUserId())) {
|
|
|
|
+ wrapper.eq(CustomComponentEntity::getUserId, param.getUserId());
|
|
}
|
|
}
|
|
param.setOrderBy("create_time");
|
|
param.setOrderBy("create_time");
|
|
param.setSortBy("desc");
|
|
param.setSortBy("desc");
|
|
- return super.listByPage(param,wrapper);
|
|
|
|
|
|
+ return super.listByPage(param, wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public CustomComponentEntity findByFileId(String FileId) {
|
|
public CustomComponentEntity findByFileId(String FileId) {
|
|
- LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
- if (ObjectUtil.isNotNull(FileId)&&StrUtil.isNotEmpty(FileId)){
|
|
|
|
- wrapper.in(CustomComponentEntity::getFileId,FileId);
|
|
|
|
|
|
+ LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ if (ObjectUtil.isNotNull(FileId) && StrUtil.isNotEmpty(FileId)) {
|
|
|
|
+ wrapper.in(CustomComponentEntity::getFileId, FileId);
|
|
}
|
|
}
|
|
return getOne(wrapper);
|
|
return getOne(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<CustomComponentEntity> list(RequestCustomComponent param) {
|
|
public List<CustomComponentEntity> list(RequestCustomComponent param) {
|
|
- LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
- if (ObjectUtil.isNotNull(param.getIds())){
|
|
|
|
- wrapper.in(CustomComponentEntity::getId,param.getIds());
|
|
|
|
|
|
+ LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ if (ObjectUtil.isNotNull(param.getIds())) {
|
|
|
|
+ wrapper.in(CustomComponentEntity::getId, param.getIds());
|
|
}
|
|
}
|
|
- if (ObjectUtil.isNotNull(param.getModelId())){
|
|
|
|
- wrapper.in(CustomComponentEntity::getModelId,param.getModelId());
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(param.getModelId())) {
|
|
|
|
+ wrapper.in(CustomComponentEntity::getModelId, param.getModelId());
|
|
}
|
|
}
|
|
return list(wrapper);
|
|
return list(wrapper);
|
|
}
|
|
}
|
|
@@ -103,17 +104,17 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ResponseCustomComponent> findComponentByParentId(RequestCustom param) {
|
|
public List<ResponseCustomComponent> findComponentByParentId(RequestCustom param) {
|
|
- LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
- if (ObjectUtil.isNotNull(param.getParentId())){
|
|
|
|
- wrapper.eq(CustomComponentEntity::getComponentTypeId,param.getParentId());
|
|
|
|
|
|
+ LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ if (ObjectUtil.isNotNull(param.getParentId())) {
|
|
|
|
+ wrapper.eq(CustomComponentEntity::getComponentTypeId, param.getParentId());
|
|
}
|
|
}
|
|
- wrapper.eq(CustomComponentEntity::getExamine,1);
|
|
|
|
- wrapper.eq(CustomComponentEntity::getIsShow,1);
|
|
|
|
- return list(wrapper).stream().map(a ->{
|
|
|
|
- ResponseCustomComponent customComponent=new ResponseCustomComponent();
|
|
|
|
|
|
+ wrapper.eq(CustomComponentEntity::getExamine, 1);
|
|
|
|
+ wrapper.eq(CustomComponentEntity::getIsShow, 1);
|
|
|
|
+ return list(wrapper).stream().map(a -> {
|
|
|
|
+ ResponseCustomComponent customComponent = new ResponseCustomComponent();
|
|
BeanUtils.copyProperties(a, customComponent);
|
|
BeanUtils.copyProperties(a, customComponent);
|
|
CustomComponentClassifyEntity componentClassifyEntity = componentClassifyService.findById(a.getComponentTypeId());
|
|
CustomComponentClassifyEntity componentClassifyEntity = componentClassifyService.findById(a.getComponentTypeId());
|
|
- if (ObjectUtil.isNotNull(componentClassifyEntity)){
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(componentClassifyEntity)) {
|
|
customComponent.setComponentTypeName(componentClassifyEntity.getName());
|
|
customComponent.setComponentTypeName(componentClassifyEntity.getName());
|
|
}
|
|
}
|
|
customComponent.setType("component");
|
|
customComponent.setType("component");
|
|
@@ -129,9 +130,9 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
|
|
componentEntity.setExamine(param.getExamine());
|
|
componentEntity.setExamine(param.getExamine());
|
|
componentEntity.setExamineTime(new Date());
|
|
componentEntity.setExamineTime(new Date());
|
|
ComponentModelUploadEntity modelUploadEntity = componentModelUploadService.findByPartsDetailId(componentEntity.getId());
|
|
ComponentModelUploadEntity modelUploadEntity = componentModelUploadService.findByPartsDetailId(componentEntity.getId());
|
|
- if (ObjectUtil.isNotNull(modelUploadEntity)){
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(modelUploadEntity)) {
|
|
//入库前先提交模型到模型库,失败返回提示
|
|
//入库前先提交模型到模型库,失败返回提示
|
|
- JSONArray syncDataArray=new JSONArray();
|
|
|
|
|
|
+ JSONArray syncDataArray = new JSONArray();
|
|
JSONObject object = new JSONObject();
|
|
JSONObject object = new JSONObject();
|
|
object.put("Name", modelUploadEntity.getFileId());
|
|
object.put("Name", modelUploadEntity.getFileId());
|
|
object.put("UserID", modelUploadEntity.getUserId());
|
|
object.put("UserID", modelUploadEntity.getUserId());
|
|
@@ -141,16 +142,16 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
|
|
String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
|
|
- log.info("更新模型库,syncmodel接口参数:" );
|
|
|
|
|
|
+ CustomComponentServiceImpl.log.info("更新模型库,syncmodel接口参数:");
|
|
uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
|
|
uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
|
|
version + "/SyncData.json");
|
|
version + "/SyncData.json");
|
|
- log.info("上传完成SyncData.jsn:"+version);
|
|
|
|
|
|
+ CustomComponentServiceImpl.log.info("上传完成SyncData.jsn:" + version);
|
|
jsonObject.put("version", version);
|
|
jsonObject.put("version", version);
|
|
synchronized (componentEntity.getId()) {
|
|
synchronized (componentEntity.getId()) {
|
|
String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
|
|
String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
|
|
JSONObject resultJson = JSONObject.parseObject(resultData);
|
|
JSONObject resultJson = JSONObject.parseObject(resultData);
|
|
if ("error".equals(resultJson.getString("state"))) {
|
|
if ("error".equals(resultJson.getString("state"))) {
|
|
- log.info("更新模型库,syncmodel接口失败:" + resultData);
|
|
|
|
|
|
+ CustomComponentServiceImpl.log.info("更新模型库,syncmodel接口失败:" + resultData);
|
|
throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
|
|
throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -159,4 +160,44 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
|
|
}
|
|
}
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public JSONArray dataPostHandler(RequestDataBucket param) {
|
|
|
|
+ LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ List<CustomComponentEntity> list = list(wrapper);
|
|
|
|
+ JSONArray res = new JSONArray();
|
|
|
|
+ CustomComponentServiceImpl.log.info("需迁移数据数量为{}", list.size());
|
|
|
|
+ list.forEach(a -> {
|
|
|
|
+ /****1:处理 tb_custom_component 表 *****/
|
|
|
|
+ JSONObject entity = (JSONObject) JSONObject.toJSON(a);
|
|
|
|
+ entity.remove("id");
|
|
|
|
+ res.add(entity);
|
|
|
|
+ });
|
|
|
|
+ CustomComponentServiceImpl.log.info("数据准备完毕");
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean dataGetHandler(String path) {
|
|
|
|
+ FileReader fileReader = new FileReader(path);
|
|
|
|
+ try {
|
|
|
|
+ JSONArray dataList = JSON.parseArray(fileReader.readString());
|
|
|
|
+ CustomComponentServiceImpl.log.info("需迁移数据数量为{}", dataList.size());
|
|
|
|
+ if (dataList.size() > 0) {
|
|
|
|
+ dataList.forEach(a -> {
|
|
|
|
+ JSONObject componentEntityJson = (JSONObject) JSONObject.toJSON(a);
|
|
|
|
+ CustomComponentEntity componentEntity = JSONObject.toJavaObject(componentEntityJson, CustomComponentEntity.class);
|
|
|
|
+ boolean saveFlag = save(componentEntity);
|
|
|
|
+ CustomComponentServiceImpl.log.info("组件保存结果{}", saveFlag);
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ CustomComponentServiceImpl.log.info("处理完成", path);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ CustomComponentServiceImpl.log.info("数据处理报错");
|
|
|
|
+ throw new RuntimeException("数据处理报错");
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|