Commit 7d8270b1 authored by 赵啸非's avatar 赵啸非

添加服务检测拉起脚本

parent f204dbfd
...@@ -57,6 +57,7 @@ import java.util.*; ...@@ -57,6 +57,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL; import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/** /**
* SiteService * SiteService
...@@ -100,51 +101,52 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -100,51 +101,52 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Autowired @Autowired
private IDeviceFeign deviceFeign; private IDeviceFeign deviceFeign;
private volatile Boolean refresh = false;
@Override @Override
protected void updateBefore(SiteEntity entity, Context context) throws AppException { protected void updateBefore(SiteEntity entity, Context context) throws AppException {
//校验下前后名称是否一直 如果不一致 同步修改所以关联 //校验下前后名称是否一直 如果不一致 同步修改所以关联
SiteEntity oldSite = this.get(entity.getId(), context); SiteEntity oldSite = this.get(entity.getId(), context);
if(!oldSite.getSiteName().equals(entity.getSiteName())){ if (!oldSite.getSiteName().equals(entity.getSiteName())) {
//todo //todo
//更新关联站点名称 //更新关联站点名称
updateAssociateSiteName(oldSite,entity, context); updateAssociateSiteName(oldSite, entity, context);
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu(); refresh = true;
devicePdu.setSiteId(entity.getId());
Rest<Void> rest = deviceFeign.refreshMessage(devicePdu);
log.info("调用刷新结果:{}",JSON.toJSONString(rest));
} }
super.updateBefore(entity, context); super.updateBefore(entity, context);
} }
private void updateAssociateSiteName(SiteEntity oldSite,SiteEntity newSite, Context context) {
private void updateAssociateSiteName(SiteEntity oldSite, SiteEntity newSite, Context context) {
//更新窗口站点名称 //更新窗口站点名称
WindowEntity windowEntity = new WindowEntity(); WindowEntity windowEntity = new WindowEntity();
windowEntity.setSiteName(newSite.getSiteName()); windowEntity.setSiteName(newSite.getSiteName());
WindowEntity condition = new WindowEntity(); WindowEntity condition = new WindowEntity();
condition.setSiteName(oldSite.getSiteName()); condition.setSiteName(oldSite.getSiteName());
windowService.updateBatch(windowEntity,condition,context); windowService.updateBatch(windowEntity, condition, context);
//更新站点业务名称 //更新站点业务名称
SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity(); SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity();
siteBusinessEntity.setSiteName(newSite.getSiteName()); siteBusinessEntity.setSiteName(newSite.getSiteName());
SiteBusinessEntity siteBusinessCondition = new SiteBusinessEntity(); SiteBusinessEntity siteBusinessCondition = new SiteBusinessEntity();
siteBusinessCondition.setSiteName(oldSite.getSiteName()); siteBusinessCondition.setSiteName(oldSite.getSiteName());
siteBusinessService.updateBatch(siteBusinessEntity,siteBusinessCondition,context); siteBusinessService.updateBatch(siteBusinessEntity, siteBusinessCondition, context);
//更新站点事项名称 //更新站点事项名称
SiteMatterEntity siteMatterEntity = new SiteMatterEntity(); SiteMatterEntity siteMatterEntity = new SiteMatterEntity();
siteMatterEntity.setSiteName(newSite.getSiteName()); siteMatterEntity.setSiteName(newSite.getSiteName());
SiteMatterEntity siteMatterCondition = new SiteMatterEntity(); SiteMatterEntity siteMatterCondition = new SiteMatterEntity();
siteMatterCondition.setSiteName(oldSite.getSiteName()); siteMatterCondition.setSiteName(oldSite.getSiteName());
siteMatterService.updateBatch(siteMatterEntity,siteMatterCondition,context); siteMatterService.updateBatch(siteMatterEntity, siteMatterCondition, context);
//更新站点主题事项名称 //更新站点主题事项名称
SiteThemeMatterEntity siteThemeMatterEntity = new SiteThemeMatterEntity(); SiteThemeMatterEntity siteThemeMatterEntity = new SiteThemeMatterEntity();
siteThemeMatterEntity.setSiteName(newSite.getSiteName()); siteThemeMatterEntity.setSiteName(newSite.getSiteName());
SiteThemeMatterEntity siteThemeMatterCondition = new SiteThemeMatterEntity(); SiteThemeMatterEntity siteThemeMatterCondition = new SiteThemeMatterEntity();
siteThemeMatterCondition.setSiteName(oldSite.getSiteName()); siteThemeMatterCondition.setSiteName(oldSite.getSiteName());
siteThemeMatterService.updateBatch(siteThemeMatterEntity,siteThemeMatterCondition,context); siteThemeMatterService.updateBatch(siteThemeMatterEntity, siteThemeMatterCondition, context);
//更新工作人员站点 //更新工作人员站点
...@@ -152,31 +154,8 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -152,31 +154,8 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
workmanEntity.setSiteName(newSite.getSiteName()); workmanEntity.setSiteName(newSite.getSiteName());
WorkmanEntity workmanEntityCondition = new WorkmanEntity(); WorkmanEntity workmanEntityCondition = new WorkmanEntity();
workmanEntityCondition.setSiteName(oldSite.getSiteName()); workmanEntityCondition.setSiteName(oldSite.getSiteName());
workmanService.updateBatch(workmanEntity,workmanEntityCondition,context); workmanService.updateBatch(workmanEntity, workmanEntityCondition, context);
/* List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().siteId(entity.getId()));
windowEntityList.forEach(item->item.setSiteName(entity.getSiteName()));
windowService.update(windowEntityList, context);
//更新站点业务名称
List<SiteBusinessEntity> siteBusinessEntities = siteBusinessService.find(new SiteBusinessQuery().siteId(entity.getId()));
siteBusinessEntities.forEach(item->item.setSiteName(entity.getSiteName()));
siteBusinessService.update(siteBusinessEntities, context);
//更新站点主题事项名称
List<SiteMatterEntity> siteMatterEntities = siteMatterService.find(new SiteMatterQuery().siteId(entity.getId()));
siteMatterEntities.forEach(item->item.setSiteName(entity.getSiteName()));
siteMatterService.update(siteMatterEntities, context);
//更新站点主题事项名称
List<SiteThemeMatterEntity> siteThemeMatterEntities = siteThemeMatterService.find(new SiteThemeMatterQuery().siteId(entity.getId()));
siteThemeMatterEntities.forEach(item->item.setSiteName(entity.getSiteName()));
siteThemeMatterService.update(siteThemeMatterEntities, context);
//更新工作人员站点
List<WorkmanEntity> workmanEntities = workmanService.find(new WorkmanQuery().siteId(entity.getId()));
workmanEntities.forEach(item->item.setSiteName(entity.getSiteName()));
workmanService.update(workmanEntities, context);*/
} }
@Override @Override
...@@ -202,7 +181,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -202,7 +181,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
protected void saveAfter(SiteEntity entity, Context context) throws AppException { protected void saveAfter(SiteEntity entity, Context context) throws AppException {
//刷新站点树 //刷新站点树
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context)); //ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
Rest<String> rest = userFeign.synchSiteAuth(); Rest<String> rest = userFeign.synchSiteAuth();
if (rest.getCode().equals(YesNoEnum.YES.getValue())) { if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
...@@ -215,6 +193,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -215,6 +193,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
//更新同步部门相关 //更新同步部门相关
deptService.syncDeptBySiteId(entity, context); deptService.syncDeptBySiteId(entity, context);
if (refresh) {
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu();
devicePdu.setSiteId(entity.getId());
Rest<Void> rest1 = deviceFeign.refreshMessage(devicePdu);
log.info("调用刷新结果:{}", JSON.toJSONString(rest1));
refresh = false;
}
super.saveAfter(entity, context); super.saveAfter(entity, context);
} }
...@@ -418,15 +405,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -418,15 +405,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
} }
@Override @Override
public Rest< List<SiteAreaVo>> getAreaSitesBySite(SiteQuery query, Context context) { public Rest<List<SiteAreaVo>> getAreaSitesBySite(SiteQuery query, Context context) {
List<SiteAreaVo> list = new ArrayList<>(); List<SiteAreaVo> list = new ArrayList<>();
//获取当前节点的第一层子节点 //获取当前节点的第一层子节点
if(ObjectUtils.isEmpty(query.getAreaName())){ if (ObjectUtils.isEmpty(query.getAreaName())) {
throw new AppException("区域名称查询参数不能为空!"); throw new AppException("区域名称查询参数不能为空!");
} }
//SiteEntity siteCache = this.getCache(query.getId().toString()); //SiteEntity siteCache = this.getCache(query.getId().toString());
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().name(query.getAreaName()),context); AreaEntity areaEntity = areaService.selectOne(new AreaQuery().name(query.getAreaName()), context);
if(ObjectUtils.isEmpty(areaEntity)){ if (ObjectUtils.isEmpty(areaEntity)) {
throw new AppException("区域名称不存在!"); throw new AppException("区域名称不存在!");
} }
if ("False".equalsIgnoreCase(areaEntity.getHaveSonArea())) { if ("False".equalsIgnoreCase(areaEntity.getHaveSonArea())) {
...@@ -442,7 +429,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -442,7 +429,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
String matchCode = child.getAreaCode().replaceAll("(0)+$", ""); String matchCode = child.getAreaCode().replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode + "%"); siteQuery.setAreaCode(matchCode + "%");
if(!ObjectUtils.isEmpty(query.getSiteName())){ if (!ObjectUtils.isEmpty(query.getSiteName())) {
siteQuery.setSiteName(query.getSiteName()); siteQuery.setSiteName(query.getSiteName());
} }
List<SiteEntity> siteEntities = this.find(siteQuery); List<SiteEntity> siteEntities = this.find(siteQuery);
...@@ -516,7 +503,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -516,7 +503,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override @Override
public void changeUrlPath(SiteEntity siteEntity) { public void changeUrlPath(SiteEntity siteEntity) {
if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) { if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_IMAGE_URL, "http://192.168.0.98:11091"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath()); String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath());
siteEntity.setLogoFullPath(fullPath); siteEntity.setLogoFullPath(fullPath);
} }
......
package com.mortals.xhx.module.window.service.impl; package com.mortals.xhx.module.window.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
...@@ -34,12 +35,12 @@ import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE; ...@@ -34,12 +35,12 @@ import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL; import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
* WindowBusinessService * WindowBusinessService
* 窗口业务 service实现 * 窗口业务 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("windowBusinessService") @Service("windowBusinessService")
@Slf4j @Slf4j
public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService { public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService {
...@@ -50,11 +51,11 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -50,11 +51,11 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
protected void findAfter(WindowBusinessEntity entity, PageInfo pageInfo, Context context, List<WindowBusinessEntity> list) throws AppException { protected void findAfter(WindowBusinessEntity entity, PageInfo pageInfo, Context context, List<WindowBusinessEntity> list) throws AppException {
Map<Long, WindowEntity> collect = windowService.findToMap(new WindowQuery(), context); Map<Long, WindowEntity> collect = windowService.findToMap(new WindowQuery(), context);
Iterator iterator = list.iterator(); Iterator iterator = list.iterator();
while (iterator.hasNext()){ while (iterator.hasNext()) {
WindowBusinessEntity item = (WindowBusinessEntity) iterator.next(); WindowBusinessEntity item = (WindowBusinessEntity) iterator.next();
if(!ObjectUtils.isEmpty(item.getWindowId())&&!ObjectUtils.isEmpty(collect.get(item.getWindowId()))){ if (!ObjectUtils.isEmpty(item.getWindowId()) && !ObjectUtils.isEmpty(collect.get(item.getWindowId()))) {
item.setFromnum(collect.get(item.getWindowId()).getFromnum()); item.setFromnum(collect.get(item.getWindowId()).getFromnum());
}else { } else {
iterator.remove(); iterator.remove();
} }
} }
...@@ -62,6 +63,21 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -62,6 +63,21 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
} }
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).forEach(id -> {
WindowBusinessEntity windowBusinessEntity = this.get(id, context);
pushChangeMsg(windowBusinessEntity);
});
super.removeBefore(ids, context);
}
/** /**
* @param entity * @param entity
* @param context * @param context
...@@ -75,7 +91,6 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -75,7 +91,6 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
} }
/** /**
* @param entity * @param entity
* @param context * @param context
...@@ -87,12 +102,12 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -87,12 +102,12 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
super.updateAfter(entity, context); super.updateAfter(entity, context);
} }
private void pushChangeMsg(WindowBusinessEntity entity) { private void pushChangeMsg(WindowBusinessEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId()); paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo", 1);
String resp = null; String resp = null;
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
......
...@@ -13,6 +13,7 @@ import com.mortals.xhx.module.window.dao.WindowMatterDao; ...@@ -13,6 +13,7 @@ import com.mortals.xhx.module.window.dao.WindowMatterDao;
import com.mortals.xhx.module.window.model.WindowMatterEntity; import com.mortals.xhx.module.window.model.WindowMatterEntity;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -40,6 +41,32 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte ...@@ -40,6 +41,32 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte
super.saveAfter(entity, context); super.saveAfter(entity, context);
} }
/**
* @param id
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long id, Context context) throws AppException {
WindowMatterEntity windowMatterEntity = this.get(id, context);
pushChangeMsg(windowMatterEntity);
super.removeBefore(id, context);
}
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).forEach(id->{
WindowMatterEntity windowMatterEntity = this.get(id, context);
pushChangeMsg(windowMatterEntity);
});
super.removeBefore(ids, context);
}
/** /**
* @param entity * @param entity
* @param context * @param context
......
...@@ -142,6 +142,10 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -142,6 +142,10 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
List<WindowMatterEntity> windowMatterEntities = windowMatterService.find(windowMatterQuery); List<WindowMatterEntity> windowMatterEntities = windowMatterService.find(windowMatterQuery);
windowMatterService.removeList(windowMatterEntities, context); windowMatterService.removeList(windowMatterEntities, context);
} }
Arrays.asList(ids).forEach(id -> {
pushChangeMsg(id);
});
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
...@@ -154,7 +158,7 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -154,7 +158,7 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
@Override @Override
protected void updateAfter(WindowEntity entity, Context context) throws AppException { protected void updateAfter(WindowEntity entity, Context context) throws AppException {
super.updateAfter(entity, context); super.updateAfter(entity, context);
pushChangeMsg(entity); pushChangeMsg(entity.getId());
} }
/** /**
...@@ -165,18 +169,18 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -165,18 +169,18 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
@Override @Override
protected void saveAfter(WindowEntity entity, Context context) throws AppException { protected void saveAfter(WindowEntity entity, Context context) throws AppException {
super.saveAfter(entity, context); super.saveAfter(entity, context);
pushChangeMsg(entity); pushChangeMsg(entity.getId());
} }
private void pushChangeMsg(WindowEntity entity) { private void pushChangeMsg(Long windowId) {
log.info("pushChangeMsg:{}",JSON.toJSONString(entity)); log.info("pushChangeMsg:{}", JSON.toJSONString(windowId));
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getId()); paramsMap.put("windowid", windowId);
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo", 1);
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
String resp = null; String resp = null;
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
......
...@@ -81,4 +81,15 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi ...@@ -81,4 +81,15 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi
} }
return super.saveAfter(entity, model, context); return super.saveAfter(entity, model, context);
} }
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void deleteBefore(Long[] ids, Context context) throws AppException {
super.deleteBefore(ids, context);
}
} }
\ No newline at end of file
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