Commit 99e0c29e by xugaojun

新增部门同时同步欢迎语

parent 7ebf418a
package com.gic.haoban.manage.service.service.impl;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.DepartmentShortDTO;
import com.gic.haoban.manage.api.enums.WelcomeSuitTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanWelcomeSuitRangMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanWelcomeSuitRang;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.task.QywxDeptSyncOperation;
import com.github.pagehelper.Page;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -19,9 +27,11 @@ import java.util.List;
@Service
public class DepartmentServiceImpl implements DepartmentService {
private static final Logger logger = LoggerFactory.getLogger(DepartmentServiceImpl.class);
@Autowired
private DepartmentMapper mapper;
@Autowired
private TabHaobanWelcomeSuitRangMapper welcomeSuitRangMapper;
@Override
public List<TabHaobanDepartment> listByParentId(String parentId) {
......@@ -69,10 +79,49 @@ public class DepartmentServiceImpl implements DepartmentService {
}
mapper.insert(tab);
syncWelcomeSuitDepartment(tab.getParentDepartmentId(), tab.getDepartmentId(), tab.getDepartmentName(), tab.getWxEnterpriseId());
return tab.getDepartmentId();
}
private void syncWelcomeSuitDepartment(String parentDepartmentId, String currentDepartmentId,
String currentDepartmentName, String wxEnterpriseId) {
logger.info("同步欢迎语适用部门, parentDepartmentId:{}, currentDepartmentId:{}, wxEnterpriseId:{}",
parentDepartmentId, currentDepartmentId, wxEnterpriseId);
// 列举父部门被关联的欢迎语
TabHaobanWelcomeSuitRang query = new TabHaobanWelcomeSuitRang();
query.setWxEnterpriseId(wxEnterpriseId);
query.setSuitDepartmentId(parentDepartmentId);
query.setDeleteFlag(0);
List<TabHaobanWelcomeSuitRang> welcomeSuitRangList = welcomeSuitRangMapper.queryAll(query);
if (CollectionUtils.isEmpty(welcomeSuitRangList)) {
logger.info("父部门查询为空");
return;
}
logger.info("父部门匹配到的欢迎语适用部门, welcomeSuitRangList:{}", JSON.toJSONString(welcomeSuitRangList));
// 为每一个父部门匹配到的欢迎语, 添加当前部门适用范围
welcomeSuitRangList.forEach(one -> {
TabHaobanWelcomeSuitRang entity = new TabHaobanWelcomeSuitRang();
entity.setWelcomeSuitRangId(UniqueIdUtils.uniqueLong());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setWelcomeId(one.getWelcomeId());
entity.setSuitType(WelcomeSuitTypeEnum.DEPARTMENT.getCode());
entity.setSuitDepartmentId(currentDepartmentId);
entity.setSuitDepartmentName(currentDepartmentName);
entity.setSuitStaffId("-1");
entity.setSuitStaffName("-1");
entity.setStaffBelongDepartmentId("-1");
entity.setStaffBelongDepartmentName("-1");
entity.setSelectType(1);
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
entity.setDeleteFlag(0);
welcomeSuitRangMapper.insert(entity);
});
}
@Override
public void edit(DepartmentDTO department) {
Date now = new Date();
......
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