Commit bb39e31b authored by 赵啸非's avatar 赵啸非

更新部门,异步更新关联名称

parent 8a869d7e
...@@ -6,6 +6,7 @@ import com.mortals.framework.exception.AppException; ...@@ -6,6 +6,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.common.code.SourceEnum; import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
...@@ -21,17 +22,17 @@ import com.mortals.xhx.module.dept.service.DeptService; ...@@ -21,17 +22,17 @@ import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matters.model.MattersDeptEntity; import com.mortals.xhx.module.matters.model.MattersDeptEntity;
import com.mortals.xhx.module.matters.model.MattersDeptQuery; import com.mortals.xhx.module.matters.model.MattersDeptQuery;
import com.mortals.xhx.module.matters.service.MattersDeptService; import com.mortals.xhx.module.matters.service.MattersDeptService;
import com.mortals.xhx.module.site.model.SiteBusinessEntity; import com.mortals.xhx.module.site.model.*;
import com.mortals.xhx.module.site.model.SiteBusinessQuery;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteBusinessService; import com.mortals.xhx.module.site.service.SiteBusinessService;
import com.mortals.xhx.module.site.service.SiteMatterService;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.module.window.model.WindowBusinessEntity; import com.mortals.xhx.module.window.model.*;
import com.mortals.xhx.module.window.model.WindowBusinessQuery;
import com.mortals.xhx.module.window.model.WindowEntity;
import com.mortals.xhx.module.window.model.WindowQuery;
import com.mortals.xhx.module.window.service.WindowBusinessService; import com.mortals.xhx.module.window.service.WindowBusinessService;
import com.mortals.xhx.module.window.service.WindowMatterService;
import com.mortals.xhx.module.window.service.WindowService; import com.mortals.xhx.module.window.service.WindowService;
import com.mortals.xhx.module.workman.model.WorkmanEntity;
import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -57,6 +58,12 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE ...@@ -57,6 +58,12 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
private MattersDeptService mattersDeptService; private MattersDeptService mattersDeptService;
@Autowired @Autowired
private WindowService windowService; private WindowService windowService;
@Autowired
private WorkmanService workmanService;
@Autowired
private WindowMatterService windowMatterService;
@Autowired
private SiteMatterService siteMatterService;
@Override @Override
...@@ -191,39 +198,9 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE ...@@ -191,39 +198,9 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
@Override @Override
public Rest<Map<String, List<DeptVo>>> getBusinessByDept(DeptQuery deptQuery, Context context) { public Rest<Map<String, List<DeptVo>>> getBusinessByDept(DeptQuery deptQuery, Context context) {
List<DeptVo> businessDeptList = this.dao.getBusinessByDept(deptQuery); List<DeptVo> businessDeptList = this.dao.getBusinessByDept(deptQuery);
Map<String, List<DeptVo>> collect = businessDeptList.parallelStream().collect(Collectors.groupingBy(x -> x.getId().toString())); Map<String, List<DeptVo>> collect = businessDeptList.parallelStream().collect(Collectors.groupingBy(x -> x.getId().toString()));
return Rest.ok(collect); return Rest.ok(collect);
/* //查询部门窗口
List<WindowEntity> windowEntities = windowService.find(new WindowQuery().deptId(deptQuery.getId()));
//查询窗口业务
WindowBusinessQuery windowBusinessQuery = new WindowBusinessQuery();
List<Long> windowList = windowEntities.stream().map(WindowEntity::getId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(windowList)) {
return Rest.ok("窗口查询结果为空", Collections.EMPTY_LIST);
}
windowBusinessQuery.setWindowIdList(windowList);
List<WindowBusinessEntity> windowBusinessEntities = windowBusinessService.find(windowBusinessQuery);
SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
List<Long> siteBusinessList = windowBusinessEntities.stream().map(WindowBusinessEntity::getSiteBusinessId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(siteBusinessList)) {
return Rest.ok("站点业务查询结果为空", Collections.EMPTY_LIST);
}
siteBusinessQuery.setBusinessIdList(siteBusinessList);
List<SiteBusinessEntity> siteBusinessEntities = siteBusinessService.find(siteBusinessQuery);
BusinessQuery businessQuery = new BusinessQuery();
List<Long> businessList = siteBusinessEntities.stream().map(SiteBusinessEntity::getBusinessId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(businessList)) {
return Rest.ok("业务查询结果为空", Collections.EMPTY_LIST);
}
businessQuery.setIdList(businessList);
List<BusinessEntity> businessEntities = businessService.find(businessQuery);*/
//return Rest.ok(businessEntities);
} }
@Override @Override
...@@ -262,11 +239,56 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE ...@@ -262,11 +239,56 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
*/ */
@Override @Override
protected void updateAfter(DeptEntity entity, Context context) throws AppException { protected void updateAfter(DeptEntity entity, Context context) throws AppException {
List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().deptId(entity.getId()));
windowEntityList.forEach(item -> { //异步更新
Runnable runnable = new Runnable() {
/**
*
*/
@Override
public void run() {
List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().deptId(entity.getId())).stream().map(item -> {
item.setDeptName(entity.getName()); item.setDeptName(entity.getName());
}); return item;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(windowEntityList)) {
windowService.update(windowEntityList, context); windowService.update(windowEntityList, context);
}
List<WorkmanEntity> workmanEntityList = workmanService.find(new WorkmanQuery().deptId(entity.getId())).stream().map(item -> {
item.setDeptName(entity.getName());
return item;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(workmanEntityList)) {
workmanService.update(workmanEntityList, context);
}
List<WindowMatterEntity> windowMatterEntityList = windowMatterService.find(new WindowMatterQuery().deptId(entity.getId())).stream().map(item -> {
item.setDeptName(entity.getName());
return item;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(windowMatterEntityList)) {
windowMatterService.update(windowMatterEntityList, context);
}
List<SiteMatterEntity> siteMatterEntityList = siteMatterService.find(new SiteMatterQuery().deptId(entity.getId())).stream().map(item -> {
item.setDeptName(entity.getName());
return item;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(siteMatterEntityList)) {
siteMatterService.update(siteMatterEntityList, context);
}
}
};
ThreadPool.getInstance().execute(runnable);
super.updateAfter(entity, context); super.updateAfter(entity, 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