Commit 71eb17f7 authored by zhengjiawei's avatar zhengjiawei

注掉原仓库同步

parent c5fb067f
......@@ -86,11 +86,11 @@ public class RiskModelController extends BaseController {
} else {
// 更新的话,就放到前面,更新失败直接阻止本地
// 如果对于新增修改有什么约束,请添加到远程同步之前
String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
param.getId(), param.getCode(), param.getName(), param.getParentId());
if (synMsg != null) {
return CommonResponseUtil.failure(synMsg);
}
// String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
// param.getId(), param.getCode(), param.getName(), param.getParentId());
// if (synMsg != null) {
// return CommonResponseUtil.failure(synMsg);
// }
}
AgencyUserModel user = getUserInfo();
......@@ -104,14 +104,14 @@ public class RiskModelController extends BaseController {
CommonResponse cr = CommonResponseUtil.success(riskSourceService.editRiskSource(map));
if (id == 0) {//新增 新增的话,只能放到本地之后,因为必须拿到新增之后的ID才行
// 如果对于新增修改有什么约束,请添加到远程同步之前
String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
param.getId(), param.getCode(), param.getName(), param.getParentId());
if (synMsg != null) {
//远程新增失败,就把本地删了,有点绕,但是没办法
//由于是刚刚新建的,就直接删除,不做任何不能删校验。
riskSourceService.deleteById(param.getId());
return CommonResponseUtil.failure(synMsg);
}
// String synMsg = riskSourceService.saveToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS,
// param.getId(), param.getCode(), param.getName(), param.getParentId());
// if (synMsg != null) {
// //远程新增失败,就把本地删了,有点绕,但是没办法
// //由于是刚刚新建的,就直接删除,不做任何不能删校验。
// riskSourceService.deleteById(param.getId());
// return CommonResponseUtil.failure(synMsg);
// }
}
return cr;
} catch (Exception e) {
......
......@@ -132,15 +132,15 @@ public class RiskSourceController extends BaseController {
public CommonResponse synToEquipManage() {
ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams);
if (!riskSourceService.isSynEquipManage()) {
// if (!riskSourceService.isSynEquipManage()) {
return CommonResponseUtil.failure("同步功能未开启");
}
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode).stream().filter(source -> IS_RISK_AREA.equalsIgnoreCase(source.getIsRegion())).collect(Collectors.toList());
String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources));
if (synMsg != null) {
return CommonResponseUtil.failure(synMsg);
}
return CommonResponseUtil.success();
// }
// List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode).stream().filter(source -> IS_RISK_AREA.equalsIgnoreCase(source.getIsRegion())).collect(Collectors.toList());
// String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources));
// if (synMsg != null) {
// return CommonResponseUtil.failure(synMsg);
// }
// return CommonResponseUtil.success();
}
/**
......
......@@ -4,13 +4,13 @@ import com.yeejoin.amos.fas.core.util.CommonResponse;
public class EquipManageFeignFallback implements IEquipManageFeign{
@Override
public CommonResponse saveWarehouse(String appKey, String product, String token, String param) {
return null;
}
@Override
public CommonResponse delWarehouse(String appKey, String product, String token, String param) {
return null;
}
// @Override
// public CommonResponse saveWarehouse(String appKey, String product, String token, String param) {
// return null;
// }
//
// @Override
// public CommonResponse delWarehouse(String appKey, String product, String token, String param) {
// return null;
// }
}
......@@ -23,12 +23,12 @@ public interface IEquipManageFeign {
* @author 张展弋
* @date 2020-9-8 15:15:18
*/
@RequestMapping(value = "/equip/warehouse/saveAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
public CommonResponse saveWarehouse(
@RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestBody String param);
// @RequestMapping(value = "/equip/warehouse/saveAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
// public CommonResponse saveWarehouse(
// @RequestHeader(name="appKey",required = true) String appKey,
// @RequestHeader(name="product",required = true) String product,
// @RequestHeader(name="token",required = true) String token,
// @RequestBody String param);
/**
*
......@@ -43,11 +43,11 @@ public interface IEquipManageFeign {
* @author 张展弋
* @date 2020-9-8 17:43:11
*/
@RequestMapping(value = "/equip/warehouse/deleteAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
public CommonResponse delWarehouse(
@RequestHeader(name="appKey",required = true) String appKey,
@RequestHeader(name="product",required = true) String product,
@RequestHeader(name="token",required = true) String token,
@RequestBody String riskSourceId);
// @RequestMapping(value = "/equip/warehouse/deleteAutoSysSyn", method = RequestMethod.POST,consumes = "application/json")
// public CommonResponse delWarehouse(
// @RequestHeader(name="appKey",required = true) String appKey,
// @RequestHeader(name="product",required = true) String product,
// @RequestHeader(name="token",required = true) String token,
// @RequestBody String riskSourceId);
}
......@@ -284,77 +284,73 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iRiskSourceDao.saveAndFlush(riskSource);
return riskSource;
}
//
// @Value("${equipManage.fegin.isSyn:false}")
// private boolean isSyn;
@Value("${equipManage.fegin.isSyn:false}")
private boolean isSyn;
@Override
public boolean isSynEquipManage() {
return isSyn;
}
@Override
public String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree) {
// 必须使用树形结构,一条一条的树杈到叶子遍历同步,否则底层节点会因为找不到父节点而同步失败
return doSynToEquipManage(appKey, product, token, success, riskSourcesTree);
}
// @Override
// public boolean isSynEquipManage() {
// return isSyn;
// }
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;
}
// @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;
// }
/**
*
* 风险模型新增及维护时远程同步
*
* @param id
* @param code
* @param name
* @param parentId
* @return CommonResponse
* @throws <br>
* @author 张展弋
* @date 2020-9-8 15:39:20
*/
public String saveToEquipManage(String appKey,String product,String token,String success,long id, String code, String name, Long parentId) {
if(!isSynEquipManage()) {
return null;
}
JSONObject js = new JSONObject();
js.put("sourceId", id);
js.put("name", name);
js.put("sourceCode", code);
// 这里的parentId和那边系统的不是一回事,这里只是借用传输
js.put("id", parentId);
CommonResponse cr = null;
try {
// 父节点id为0表示根节点,对应那边的仓库
cr = equipManageFeign.saveWarehouse(appKey, product, token, js.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (cr == null) {
return "远程调用同步失败,请检查远程系统后重试!";
}
if (!success.equals(cr.getResult())) {
return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
}
return null;
}
// public String saveToEquipManage(String appKey,String product,String token,String success,long id, String code, String name, Long parentId) {
// if(!isSynEquipManage()) {
// return null;
// }
// JSONObject js = new JSONObject();
// js.put("sourceId", id);
// js.put("name", name);
// js.put("sourceCode", code);
// // 这里的parentId和那边系统的不是一回事,这里只是借用传输
// js.put("id", parentId);
// CommonResponse cr = null;
// try {
// // 父节点id为0表示根节点,对应那边的仓库
// cr = equipManageFeign.saveWarehouse(appKey, product, token, js.toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (cr == null) {
// return "远程调用同步失败,请检查远程系统后重试!";
// }
// if (!success.equals(cr.getResult())) {
// return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
// }
// return null;
// }
@Override
public void deleteRiskSource(String appKey,String product,String token,String success,Long[] riskSourceId) throws Exception {
......@@ -370,10 +366,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if (count > 0) {
throw new YeeException("该数据有关联子项,请先删除子项数据");
}
synMsg = deleteToEquipManage(appKey, product, token, success, rId);
if(synMsg !=null) {
throw new YeeException("远程删除失败,附加消息:" + synMsg);
}
// synMsg = deleteToEquipManage(appKey, product, token, success, rId);
// if(synMsg !=null) {
// throw new YeeException("远程删除失败,附加消息:" + synMsg);
// }
iRiskSourceDao.deleteById(rId);
}
//1.重新计算rpn
......@@ -384,6 +380,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
existIds.forEach(rs::addRiskSourcePointDeleteMessage);
}
@Override
public void deleteById(Long id) {
iRiskSourceDao.deleteById(id);
}
......@@ -391,35 +389,30 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*
* 风险模型删除时远程同步
*
* @param appKey
* @param product
* @param token
* @param failed
* @param rId
* @return String
* @throws <br>
* @author 张展弋
* @date 2020-9-8 17:54:12
*/
private String deleteToEquipManage(String appKey,String product,String token,String success,Long rId) {
if(!isSynEquipManage()) {
return null;
}
CommonResponse cr = null;
try {
// 父节点id为0表示根节点,对应那边的仓库
cr = equipManageFeign.delWarehouse(appKey, product, token, rId.toString());
} catch (Exception e) {
e.printStackTrace();
}
if (cr == null) {
return "远程调用同步失败,请检查远程系统后重试!";
}
if (!success.equals(cr.getResult())) {
return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
}
return null;
}
// private String deleteToEquipManage(String appKey,String product,String token,String success,Long rId) {
// if(!isSynEquipManage()) {
// return null;
// }
// CommonResponse cr = null;
// try {
// // 父节点id为0表示根节点,对应那边的仓库
// cr = equipManageFeign.delWarehouse(appKey, product, token, rId.toString());
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (cr == null) {
// return "远程调用同步失败,请检查远程系统后重试!";
// }
// if (!success.equals(cr.getResult())) {
// return "远程同步失败,请检查远程系统后重试!附加消息:" + cr.getMessage();
// }
// return null;
// }
@Override
public Page<HashMap<String, Object>> queryRiskSourceByPage(CommonPageInfoParam param) {
......@@ -1103,7 +1096,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* 设备消息规则推送
*
* @param protalData
*/
@Async
void fireEquipRuleMessagePush(AlarmParam deviceData, Toke toke) {
......
......@@ -44,8 +44,8 @@ public interface IRiskSourceService {
* @author 张展弋
* @date 2020-9-8 17:39:32
*/
String saveToEquipManage(String appKey, String product, String token, String success, long id,
String code, String name, Long parentId);
// String saveToEquipManage(String appKey, String product, String token, String success, long id,
// String code, String name, Long parentId);
/**
* 将本地 风险模型推送到远程同步
......@@ -60,7 +60,7 @@ public interface IRiskSourceService {
* @author 张展弋
* @date 2020-9-9 15:40:18
*/
String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree);
// String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree);
/**
*
......@@ -71,7 +71,7 @@ public interface IRiskSourceService {
* @author 张展弋
* @date 2020-9-8 15:45:34
*/
boolean isSynEquipManage();
// boolean isSynEquipManage();
/**
* 删除风险点
*/
......
spring.application.name = AMOS-AUTOSYS
spring.application.name = AMOS-AUTOSYS-1225
server.port = 8083
spring.profiles.active=dev
#应用product appkey
......@@ -49,7 +49,7 @@ visual.fegin.name=maas-visual
#值班系统
dutyMode.fegin.name=AMOS-DUTYMODE
#队站装备管理名称,主要用于风险区域同步至仓库货位和订阅装备信息系统
equipManage.fegin.name=AMOS-EQUIPMANAGE
equipManage.fegin.name=AMOS-EQUIPMANAGE-1225
#jpush 服务名称
......
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