|
@@ -1,5 +1,6 @@
|
|
package com.persagy.dmp.rwd.service;
|
|
package com.persagy.dmp.rwd.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.persagy.common.criteria.CriteriaUtils;
|
|
import com.persagy.common.criteria.CriteriaUtils;
|
|
import com.persagy.common.criteria.JacksonCriteria;
|
|
import com.persagy.common.criteria.JacksonCriteria;
|
|
@@ -54,6 +55,7 @@ public class SchemaService extends BaseService {
|
|
@Transactional
|
|
@Transactional
|
|
public MapResponse create(SchemaModel param) {
|
|
public MapResponse create(SchemaModel param) {
|
|
MapResponse response = new MapResponse();
|
|
MapResponse response = new MapResponse();
|
|
|
|
+ // 1.校验必填参数
|
|
super.checkParam(response, RwdConstants.QUERY_GROUPCODE);
|
|
super.checkParam(response, RwdConstants.QUERY_GROUPCODE);
|
|
if (!response.success()) {
|
|
if (!response.success()) {
|
|
return response;
|
|
return response;
|
|
@@ -62,7 +64,16 @@ public class SchemaService extends BaseService {
|
|
response.setFail("集团编码不可为空");
|
|
response.setFail("集团编码不可为空");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
+ if (StrUtil.isBlank(param.getName())) {
|
|
|
|
+ response.setFail("集团方案名称不可为空");
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
// TODO
|
|
// TODO
|
|
|
|
+ // 1.根据名称和集团code查询方案,集团方案名称不能重复
|
|
|
|
+ if (checkGroupSchemaNameRepeated(param.getName(), null)){
|
|
|
|
+ response.setFail("集团方案名称不可重复");
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
Schema entity = Schema.fromModel(param);
|
|
Schema entity = Schema.fromModel(param);
|
|
if (entity.getId() == null) {
|
|
if (entity.getId() == null) {
|
|
entity.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
entity.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
@@ -73,6 +84,28 @@ public class SchemaService extends BaseService {
|
|
response.add("id", entity.getId());
|
|
response.add("id", entity.getId());
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
+ /***
|
|
|
|
+ * Description: 校验方案名称不可重复
|
|
|
|
+ * @param name : 集团方案名称
|
|
|
|
+ * @param schemaId : 集团方案id
|
|
|
|
+ * @return : java.lang.Boolean
|
|
|
|
+ * @author : lijie
|
|
|
|
+ * @date :2021/7/22 18:31
|
|
|
|
+ * Update By lijie 2021/7/22 18:31
|
|
|
|
+ */
|
|
|
|
+ private Boolean checkGroupSchemaNameRepeated(String name,String schemaId){
|
|
|
|
+ JacksonCriteria criteria = JacksonCriteria.newInstance();
|
|
|
|
+ criteria.add(RwdConstants.OBJECT_GROUPCODE, DmpParameterStorage.getGroupCode());
|
|
|
|
+ criteria.add(RwdConstants.OBJECT_NAME, name);
|
|
|
|
+ PagedResponse<Schema> resp = criteriaUtils.query(QSchema.schema, this::parse, criteria);
|
|
|
|
+ if (resp.getCount()<=0){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isBlank(schemaId)){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return !resp.getData().get(0).getId().equals(schemaId);
|
|
|
|
+ }
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
public MapResponse update(SchemaModel param) {
|
|
public MapResponse update(SchemaModel param) {
|
|
@@ -88,11 +121,19 @@ public class SchemaService extends BaseService {
|
|
// TODO
|
|
// TODO
|
|
QSchema qt = QSchema.schema;
|
|
QSchema qt = QSchema.schema;
|
|
String schemaId = param.getId();
|
|
String schemaId = param.getId();
|
|
|
|
+ if (StrUtil.isBlank(schemaId)){
|
|
|
|
+ response.setFail("集团方案id不能为空");
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
Optional<Schema> opt = schemaRepository.findOne(qt.id.eq(schemaId).and(qt.groupCode.eq(DmpParameterStorage.getGroupCode())));
|
|
Optional<Schema> opt = schemaRepository.findOne(qt.id.eq(schemaId).and(qt.groupCode.eq(DmpParameterStorage.getGroupCode())));
|
|
if (!opt.isPresent()) {
|
|
if (!opt.isPresent()) {
|
|
response.setFail("数据不存在");
|
|
response.setFail("数据不存在");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
+ if (checkGroupSchemaNameRepeated(param.getName(), schemaId)){
|
|
|
|
+ response.setFail("集团方案名称不可重复");
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
Schema entity = opt.get();
|
|
Schema entity = opt.get();
|
|
if (param.getName() != null) {
|
|
if (param.getName() != null) {
|
|
entity.setName(param.getName());
|
|
entity.setName(param.getName());
|