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

添加服务检测拉起脚本

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