Commit 747eceb3 by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents c24594d8 c83f1420
......@@ -7,6 +7,8 @@ public class BlockSyncRequest {
String blockId;
Long area;
String points;
String parts;
RegionDTO region;
}
package com.dituhui.pea.order.controller;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -11,6 +13,8 @@ import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.service.IBlockService;
import com.dituhui.pea.pojo.BlockSyncRequest;
import com.dituhui.pea.pojo.PointBase;
import com.dituhui.pea.pojo.RegionDTO;
/**
* 服务范围相关接口
......@@ -36,12 +40,41 @@ public class BlockController {
if (request == null || StringUtils.isBlank(request.getBlockId())) {
return Result.failure("缺少参数blockId");
}
if (null == request.getRegion()) {
return Result.failure("缺少参数region");
if (StringUtils.isBlank(request.getPoints())) {
return Result.failure("缺少参数points");
}
Result<Boolean> res = null;
try {
RegionDTO region = new RegionDTO();
String[] xys = request.getPoints().split(";");
Arrays.asList(xys).stream().map(xy -> {
String[] temp = xy.split(",");
PointBase p = new PointBase();
p.setX(Double.parseDouble(temp[0]));
p.setY(Double.parseDouble(temp[1]));
return p;
});
PointBase[] points = new PointBase[xys.length];
for (int i = 0; i < points.length; i++) {
String xy = xys[i];
String[] temp = xy.split(",");
PointBase p = new PointBase();
p.setX(Double.parseDouble(temp[0]));
p.setY(Double.parseDouble(temp[1]));
points[i] = p;
}
region.setPoints(points);
if (StringUtils.isNotBlank(request.getParts())) {
String[] temp = request.getParts().split(",");
Integer[] parts = new Integer[temp.length];
for (int i = 0; i < parts.length; i++) {
parts[i] = Integer.parseInt(temp[i]);
}
region.setParts(parts);
}
res = blockService.synchronizeBlock(request.getBlockId(), request.getArea(), request.getRegion());
} catch (BusinessException e) {
return Result.failure(e.getMessage());
......
......@@ -16,29 +16,13 @@
package com.dituhui.pea.order.feign.dto;
/**
* @author TrevorLink
*/
public class AccountDTO {
private String userId;
private Integer price;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
import lombok.Data;
public Integer getPrice() {
return price;
}
@Data
public class LayerDTO {
public void setPrice(Integer price) {
this.price = price;
}
private String id;
private String code;
private String name;
}
/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dituhui.pea.order.feign.dto;
/**
* @author TrevorLink
*/
public class StorageDTO {
private String commodityCode;
private Integer count;
public String getCommodityCode() {
return commodityCode;
}
public void setCommodityCode(String commodityCode) {
this.commodityCode = commodityCode;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}
......@@ -47,6 +47,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
@Value("${SaaS.ak}")
String ak;
@Value("${SaaS.url}")
String url;
@Override
public Result<?> businessServerBlocks(String levelType, String levelValue, long page, long size, String layerId, String teamId) {
......@@ -195,9 +198,15 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
if (block == null) {
throw new BusinessException("区块不存在");
}
// 跳转规则: TODO
// TODO 根据当前block转换成分部,再转换成对应账号信息
String userAccount = "sMvf3yZWA69lKcvlgKcOHQ==";
String password = "qjOHxpQPXLnJP+Jq1CZGBQ==";
// 跳转SaaS url
HashMap<String, String> res = new HashMap<>();
res.put("url", "https://pea-test.bshg.com.cn/mlAutoLogin?userAccount=WVyjhzcOeIUc5rl74hdaqw==&password=qjOHxpQPXLnJP+Jq1CZGBQ==&jump=basedata&navHidden=true");
res.put("url", url + "/mlAutoLogin?userAccount=" + userAccount + "&password=" + password
+ "&jump=basedata&navHidden=true&layerId=" + block.getLayerId() + "&areaId=" + block.getBlockId());
return Result.success(res);
}
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.order.feign.ISaaSRemoteService;
import com.dituhui.pea.order.feign.dto.LayerDTO;
import com.dituhui.pea.order.service.BusinessLayerService;
import com.dituhui.pea.order.utils.TypeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class BusinessLayerServiceImpl implements BusinessLayerService {
@Autowired
private ISaaSRemoteService saasRemoteService;
@Value("${SaaS.ak}")
String ak;
@Override
public Result<?> businessLayers() {
return null;
......@@ -30,7 +45,18 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public Result<?> businessCustomLayerAdd() {
return null;
String layerName = "上海大区苏州分部基础技能";
// 同步创建saas图层,返回layerId
String result = saasRemoteService.addLayer(ak, layerName, 1, 1);
log.info("addLayer params:{} result:{}", layerName, result);
Result<LayerDTO> saasResult = TypeUtils.<LayerDTO>convertResult(result);
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure(saasResult.getMessage());
}
String layerId = saasResult.getResult().getId();// 存入pea
return Result.success(null);
}
@Override
......@@ -40,6 +66,16 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
@Override
public Result<?> businessCustomLayerRemove() {
String layerId = "";
// 同步创建saas图层,返回layerId
String result = saasRemoteService.deleteLayer(ak, layerId);
log.info("deleteLayer params:{} result:{}", layerId, result);
Result<Boolean> saasResult = TypeUtils.<Boolean>convertResult(result);
if (!ResultEnum.SUCCESS.getCode().equals(saasResult.getCode())) {
return Result.failure(saasResult.getMessage());
}
return null;
}
}
......@@ -12,6 +12,12 @@ public class TypeUtils {
private final static Gson gson = new Gson();
/**
* 文本转Result对象
*
* @param text
* @return
*/
public static <T> Result<T> convertResult(String text) {
if (StringUtils.isEmpty(text)) {
return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!