Commit 43869524 authored by 张展弋's avatar 张展弋

完成“换流站系统风险区域数据同步至仓库货位”同步推送功能

parent 9214b0ca
......@@ -15,6 +15,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -121,6 +122,23 @@ public class RiskSourceController extends BaseController {
return CommonResponseUtil.success(getRiskSourcesTree(riskSources));
}
@Permission
@ApiOperation(value = "远程同步", notes = "将本地 风险模型推送到远程同步")
@PutMapping(value = "/synToEquipManage")
public CommonResponse synToEquipManage() {
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
if(!riskSourceService.isSynEquipManage()) {
return CommonResponseUtil.failure("同步功能未开启");
}
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode);
String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources));
if (synMsg != null) {
return CommonResponseUtil.failure(synMsg);
}
return CommonResponseUtil.success();
}
/**
* 获取区域树型结构
*
......
......@@ -276,6 +276,30 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return isSyn;
}
@Override
public String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree) {
// 必须使用树形结构,一条一条的树杈到叶子遍历同步,否则底层节点会因为找不到父节点而同步失败
return doSynToEquipManage(appKey, product, token, success, riskSourcesTree);
}
private String doSynToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree) {
if(riskSourcesTree == null) {
return null;
}
String res = null;
for(RiskSourceTreeResponse rst : riskSourcesTree) {
res = saveToEquipManage(appKey, product, token, success, rst.getId(), rst.getCode(), rst.getName(), rst.getParentId());
if(res != null) {
return res;
}
res = doSynToEquipManage(appKey, product, token, success, rst.getChildren());
if(res != null) {
return res;
}
}
return null;
}
/**
*
* 风险模型新增及维护时远程同步
......
......@@ -17,7 +17,6 @@ import com.yeejoin.amos.fas.business.service.model.ProtalDataRo;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
......@@ -45,8 +44,23 @@ public interface IRiskSourceService {
* @author 张展弋
* @date 2020-9-8 17:39:32
*/
public String saveToEquipManage(String appKey, String product, String token, String success, long id,
String saveToEquipManage(String appKey, String product, String token, String success, long id,
String code, String name, Long parentId);
/**
* 将本地 风险模型推送到远程同步
*
* @param appKey
* @param product
* @param token
* @param success
* @param riskSources
* @return String
* @throws <br>
* @author 张展弋
* @date 2020-9-9 15:40:18
*/
String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree);
/**
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment