|
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
|
|
|
import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
@@ -16,6 +15,7 @@ import com.persagy.proxy.dictionary.model.AdmObjectType;
|
|
|
import com.persagy.proxy.dictionary.service.IAdmDictService;
|
|
|
import com.persagy.proxy.object.model.AdmComponent;
|
|
|
import com.persagy.proxy.object.service.IAdmComponentService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -32,7 +33,7 @@ import java.util.Map;
|
|
|
* @author lvxy
|
|
|
* @date 2021/8/16
|
|
|
*/
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/object/component")
|
|
|
public class AdmComponentController {
|
|
@@ -78,7 +79,8 @@ public class AdmComponentController {
|
|
|
fullDictMap.put(dict.getCode(), dict);
|
|
|
}
|
|
|
// 设备属性调整
|
|
|
- vos.stream().forEach(component -> {
|
|
|
+ List<AdmComponent> filterVOs = new ArrayList<>();
|
|
|
+ for(AdmComponent component:vos) {
|
|
|
// 如果不是Eq开头,则重新生成ID
|
|
|
if(StrUtil.startWith(component.getId(), "Ec")) {
|
|
|
component.setId("Ec"+ IdUtil.simpleUUID());
|
|
@@ -88,8 +90,10 @@ public class AdmComponentController {
|
|
|
// 如果编码为空,或在4位、6位里都不存在,则报错
|
|
|
if(StrUtil.isBlank(classCode) ||
|
|
|
(shortDictMap.get(classCode) == null && fullDictMap.get(classCode) == null)) {
|
|
|
- throw new BusinessException(StrUtil.format("没有找到对象类型【{}】!", component.getClassCode()));
|
|
|
+ log.error(StrUtil.format("没有找到对象类型【{}】!", component.getClassCode()));
|
|
|
+ continue;
|
|
|
}
|
|
|
+ filterVOs.add(component);
|
|
|
// 如果少于6位,则需要适配新编码
|
|
|
if(classCode.length() < 8) {
|
|
|
AdmObjectType dict = MapUtil.get(shortDictMap, classCode, AdmObjectType.class);
|
|
@@ -101,9 +105,12 @@ public class AdmComponentController {
|
|
|
String preName = dict == null ? "部件" : dict.getName();
|
|
|
component.setName(ObjectNameUtil.objectName(preName + "-"));
|
|
|
}
|
|
|
- });
|
|
|
- vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmComponent.class, vos);
|
|
|
- return AdmResponse.success(vos);
|
|
|
+ }
|
|
|
+ if(CollUtil.isEmpty(filterVOs)){
|
|
|
+ return AdmResponse.success();
|
|
|
+ }
|
|
|
+ filterVOs = service.doInsert(AdmContextUtil.toDmpContext(), AdmComponent.class, filterVOs);
|
|
|
+ return AdmResponse.success(filterVOs);
|
|
|
}
|
|
|
|
|
|
/**
|