Commit 037d814a authored by 赵啸非's avatar 赵啸非

更细业务,异步更新关联业务名称

parent bb39e31b
...@@ -7,6 +7,7 @@ import com.mortals.framework.model.Context; ...@@ -7,6 +7,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.message.MessageService; import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.busiz.req.ApiThirdPartyReq; import com.mortals.xhx.busiz.req.ApiThirdPartyReq;
import com.mortals.xhx.busiz.req.BussinessThirdPartyReq; import com.mortals.xhx.busiz.req.BussinessThirdPartyReq;
...@@ -84,36 +85,52 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa ...@@ -84,36 +85,52 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
@Override @Override
protected void updateAfter(BusinessEntity entity, Context context) throws AppException { protected void updateAfter(BusinessEntity entity, Context context) throws AppException {
//同步更新所有站点
List<SiteBusinessEntity> collect = siteBusinessService.find(new SiteBusinessQuery().businessId(entity.getId())).stream()
.map(item -> {
BeanUtils.copyProperties(entity, item, new String[]{"id"});
item.setBusinessName(entity.getName());
return item;
}).collect(Collectors.toList());
siteBusinessService.update(collect, context);
//更新事项业务表中字段
List<SiteBusinessEntity> siteBusinessEntities = siteBusinessService.find(new SiteBusinessQuery().businessId(entity.getId()))
.stream()
.filter(item -> !item.getBusinessName().equals(entity.getName()))
.peek(item -> item.setBusinessName(entity.getName()))
.collect(Collectors.toList());
if (!ObjectUtils.isEmpty(siteBusinessEntities)) {
siteBusinessService.update(siteBusinessEntities, context);
}
//通知第三方平台 Runnable runnable = new Runnable() {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); /**
phpUrl += "/inter/device/baseDataSave"; *
BussinessThirdPartyReq bussinessThirdPartyReq = new BussinessThirdPartyReq(); */
BeanUtils.copyProperties(entity, bussinessThirdPartyReq, BeanUtil.getNullPropertyNames(entity)); @Override
ApiThirdPartyReq<BussinessThirdPartyReq> apiThirdPartyReq = new ApiThirdPartyReq<>(); public void run() {
apiThirdPartyReq.setCode(YesNoEnum.YES.getValue()); //同步更新所有站点
apiThirdPartyReq.setType(ThirdPartyTypeEnum.业务.getValue()); List<SiteBusinessEntity> siteBusinessEntityList = siteBusinessService.find(new SiteBusinessQuery().businessId(entity.getId())).stream()
apiThirdPartyReq.setStatus(ThirdPartyStatusEnum.修改.getValue()); .map(item -> {
apiThirdPartyReq.setData(bussinessThirdPartyReq); item.setBusinessName(entity.getName());
messageService.sendThirdParty(phpUrl, JSON.toJSONString(apiThirdPartyReq)); return item;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(siteBusinessEntityList)) {
siteBusinessService.update(siteBusinessEntityList, context);
}
for (SiteBusinessEntity siteBusinessEntity : siteBusinessEntityList) {
List<WindowBusinessEntity> windowBusinessEntityList = windowBusinessService.find(new WindowBusinessQuery().siteBusinessId(siteBusinessEntity.getId())).stream().map(item -> {
item.setBusinessName(entity.getName());
return item;
}).collect(Collectors.toList());
if( !ObjectUtils.isEmpty(windowBusinessEntityList)) {
windowBusinessService.update(windowBusinessEntityList, context);
}
}
//通知第三方平台
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl += "/inter/device/baseDataSave";
BussinessThirdPartyReq bussinessThirdPartyReq = new BussinessThirdPartyReq();
BeanUtils.copyProperties(entity, bussinessThirdPartyReq, BeanUtil.getNullPropertyNames(entity));
ApiThirdPartyReq<BussinessThirdPartyReq> apiThirdPartyReq = new ApiThirdPartyReq<>();
apiThirdPartyReq.setCode(YesNoEnum.YES.getValue());
apiThirdPartyReq.setType(ThirdPartyTypeEnum.业务.getValue());
apiThirdPartyReq.setStatus(ThirdPartyStatusEnum.修改.getValue());
apiThirdPartyReq.setData(bussinessThirdPartyReq);
messageService.sendThirdParty(phpUrl, JSON.toJSONString(apiThirdPartyReq));
}
};
ThreadPool.getInstance().execute(runnable);
super.updateAfter(entity, context); super.updateAfter(entity, context);
} }
...@@ -217,7 +234,7 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa ...@@ -217,7 +234,7 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
private void updateOrSave(BusinessEntity item, Long siteId, Context context) { private void updateOrSave(BusinessEntity item, Long siteId, Context context) {
SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity(); SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity();
// BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item)); // BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item));
SiteEntity siteEntity = siteService.get(siteId); SiteEntity siteEntity = siteService.get(siteId);
if (ObjectUtils.isEmpty(siteEntity)) { if (ObjectUtils.isEmpty(siteEntity)) {
throw new AppException("未找到相应站点!"); throw new AppException("未找到相应站点!");
......
...@@ -41,7 +41,7 @@ client.global.set("SiteBusiness_id", JSON.parse(response.body).data.id); ...@@ -41,7 +41,7 @@ client.global.set("SiteBusiness_id", JSON.parse(response.body).data.id);
%} %}
###站点业务查看 ###站点业务查看
GET {{baseUrl}}/site/business/info?id={{SiteBusiness_id}} GET {{baseUrl}}/site/business/interinfo?id=24
Accept: application/json Accept: application/json
###站点业务编辑 ###站点业务编辑
......
...@@ -5,6 +5,12 @@ Content-Type: application/json ...@@ -5,6 +5,12 @@ Content-Type: application/json
{"windowIdList":["77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99"],"size":-1} {"windowIdList":["77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99"],"size":-1}
###窗口业务列表
POST {{baseUrl}}/window/business/interlist
Content-Type: application/json
{"windowIdList":["16"],"size":-1}
###窗口业务列表缓存 ###窗口业务列表缓存
......
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