|
@@ -0,0 +1,139 @@
|
|
|
+package com.persagy.dmp.rwd.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+import com.persagy.common.criteria.JacksonCriteria;
|
|
|
+import com.persagy.common.web.MapResponse;
|
|
|
+import com.persagy.common.web.PagedResponse;
|
|
|
+import com.persagy.dmp.config.DmpParameterStorage;
|
|
|
+import com.persagy.dmp.rwd.config.RwdConstants;
|
|
|
+import com.persagy.dmp.rwd.feign.OrgClient;
|
|
|
+import com.persagy.dmp.rwd.model.GroupAndSchemaModel;
|
|
|
+import com.persagy.dmp.rwd.model.GroupModel;
|
|
|
+import com.persagy.dmp.rwd.model.SchemaModel;
|
|
|
+import com.persagy.dmp.rwd.service.BaseService;
|
|
|
+import com.persagy.dmp.rwd.service.GroupAndSchemaService;
|
|
|
+import com.persagy.dmp.rwd.service.SchemaService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class GroupAndSchemaServiceImpl extends BaseService implements GroupAndSchemaService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrgClient orgClient;
|
|
|
+ @Autowired
|
|
|
+ private SchemaService schemaService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public MapResponse create(GroupAndSchemaModel param) {
|
|
|
+ // 1.创建集团
|
|
|
+ MapResponse response = createGroup(param);
|
|
|
+ if (!response.success()){
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 4.构建集团方案创建参数
|
|
|
+ DmpParameterStorage.setGroupCode(param.getCode());
|
|
|
+ MapResponse schemaResponse = schemaService.create(SchemaModel.builder()
|
|
|
+ .name(param.getSchemaName())
|
|
|
+ .id(param.getSchemaId())
|
|
|
+ .build());
|
|
|
+ // 5.处理返回结果
|
|
|
+ if (!schemaResponse.success()){
|
|
|
+ response.setFail("集团创建成功但集团方案创建失败,请通过编辑集团重新创建集团方案");
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * Description:编辑集团及集团方案
|
|
|
+ * @param param : 请求参数
|
|
|
+ * @return : com.persagy.common.web.MapResponse
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/7/21 15:19
|
|
|
+ * Update By lijie 2021/7/21 15:19
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MapResponse update(GroupAndSchemaModel param) {
|
|
|
+ // 1.更新集团
|
|
|
+ MapResponse response = updateGroup(param);
|
|
|
+ if (!response.success()){
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 4.构建集团方案创建参数
|
|
|
+ DmpParameterStorage.setGroupCode(param.getCode());
|
|
|
+ MapResponse schemaResponse;
|
|
|
+ if (StrUtil.isNotBlank(param.getSchemaId())){
|
|
|
+ // 更新集团方案
|
|
|
+ schemaResponse = schemaService.update(SchemaModel.builder()
|
|
|
+ .name(param.getSchemaName())
|
|
|
+ .id(param.getSchemaId())
|
|
|
+ .build());
|
|
|
+ }else {
|
|
|
+ // 创建集团方案
|
|
|
+ schemaResponse = schemaService.create(SchemaModel.builder()
|
|
|
+ .name(param.getSchemaName())
|
|
|
+ .id(param.getSchemaId())
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+ // 5.处理返回结果
|
|
|
+ if (!schemaResponse.success()){
|
|
|
+ response.setFail("集团更新成功但集团方案更新失败,请通过编辑集团重新创建/更新集团方案");
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 更新集团
|
|
|
+ * @param param : 请求参数
|
|
|
+ * @return : com.persagy.common.web.MapResponse
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/7/21 15:20
|
|
|
+ * Update By lijie 2021/7/21 15:20
|
|
|
+ */
|
|
|
+ private MapResponse updateGroup(GroupAndSchemaModel param) {
|
|
|
+ MapResponse response = new MapResponse();
|
|
|
+ super.checkParam(response, RwdConstants.QUERY_USERID);
|
|
|
+ if (!response.success()) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 1.构建集团创建的接口参数
|
|
|
+ // 2.RPC调用dmp-org的创建集团接口
|
|
|
+ // 3.处理返回结果
|
|
|
+ return orgClient.groupUpdate(DmpParameterStorage.getUserId(), GroupModel.builder()
|
|
|
+ .id(param.getId())
|
|
|
+ .code(param.getCode())
|
|
|
+ .name(param.getName())
|
|
|
+ .remark(param.getRemark())
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * Description: 创建集团
|
|
|
+ * @param param : 请求参数
|
|
|
+ * @return : com.persagy.common.web.MapResponse
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/7/21 15:20
|
|
|
+ * Update By lijie 2021/7/21 15:20
|
|
|
+ */
|
|
|
+ private MapResponse createGroup(GroupAndSchemaModel param) {
|
|
|
+ MapResponse response = new MapResponse();
|
|
|
+ super.checkParam(response, RwdConstants.QUERY_USERID);
|
|
|
+ if (!response.success()) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ // 1.构建集团创建的接口参数
|
|
|
+ // 2.RPC调用dmp-org的创建集团接口
|
|
|
+ // 3.处理返回结果
|
|
|
+ return orgClient.groupCreate(DmpParameterStorage.getUserId(), GroupModel.builder()
|
|
|
+ .id(param.getId())
|
|
|
+ .code(param.getCode())
|
|
|
+ .name(param.getName())
|
|
|
+ .remark(param.getRemark())
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+}
|