Commit c0f703f9 by 墨竹

Merge remote-tracking branch 'origin/developer' into developer

parents 5be5cd8c 96ea0b5c
...@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service; ...@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
@Service @Service
public class DepartmentServiceImpl implements DepartmentService { public class DepartmentServiceImpl implements DepartmentService {
...@@ -76,16 +77,17 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -76,16 +77,17 @@ public class DepartmentServiceImpl implements DepartmentService {
if (department.getTempFlag() == null) { if (department.getTempFlag() == null) {
department.setTempFlag(0); department.setTempFlag(0);
} }
mapper.insert(tab); mapper.insert(tab);
try {
syncWelcomeSuitDepartment(tab.getParentDepartmentId(), tab.getDepartmentId(), tab.getDepartmentName(), tab.getWxEnterpriseId()); syncWelcomeSuitAddDepartment(tab.getParentDepartmentId(), tab.getDepartmentId(), tab.getDepartmentName(), tab.getWxEnterpriseId());
} catch (Exception e) {
logger.error("同步部门-新增欢迎语适用部门信息异常", e);
}
return tab.getDepartmentId(); return tab.getDepartmentId();
} }
private void syncWelcomeSuitDepartment(String parentDepartmentId, String currentDepartmentId, private void syncWelcomeSuitAddDepartment(String parentDepartmentId, String currentDepartmentId,
String currentDepartmentName, String wxEnterpriseId) { String currentDepartmentName, String wxEnterpriseId) {
logger.info("同步欢迎语适用部门, parentDepartmentId:{}, currentDepartmentId:{}, wxEnterpriseId:{}", logger.info("同步欢迎语适用部门, parentDepartmentId:{}, currentDepartmentId:{}, wxEnterpriseId:{}",
parentDepartmentId, currentDepartmentId, wxEnterpriseId); parentDepartmentId, currentDepartmentId, wxEnterpriseId);
...@@ -130,18 +132,68 @@ public class DepartmentServiceImpl implements DepartmentService { ...@@ -130,18 +132,68 @@ public class DepartmentServiceImpl implements DepartmentService {
TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department); TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department);
tab.setUpdateTime(now); tab.setUpdateTime(now);
mapper.updateByPrimaryKeySelective(tab); mapper.updateByPrimaryKeySelective(tab);
try {
syncWelcomeSuitEditDepartment(tab);
} catch (Exception e) {
logger.error("同步部门-修改欢迎语适用部门信息异常", e);
}
}
private void syncWelcomeSuitEditDepartment(TabHaobanDepartment tab) {
if (StringUtils.isEmpty(tab.getWxEnterpriseId())) {
return;
}
// 列举部门被关联的欢迎语
TabHaobanWelcomeSuitRang query = new TabHaobanWelcomeSuitRang();
query.setWxEnterpriseId(tab.getWxEnterpriseId());
query.setSuitDepartmentId(tab.getDepartmentId());
query.setDeleteFlag(0);
List<TabHaobanWelcomeSuitRang> welcomeSuitRangList = welcomeSuitRangMapper.queryAll(query);
if (CollectionUtils.isEmpty(welcomeSuitRangList)) {
logger.info("部门查询为空");
return;
}
// 更新名称
welcomeSuitRangList.forEach(one -> {
one.setUpdateTime(new Date());
one.setSuitDepartmentName(tab.getDepartmentName());
welcomeSuitRangMapper.update(one);
});
} }
@Override @Override
public void del(String departmentId) { public void del(String departmentId) {
TabHaobanDepartment tab = mapper.selectByPrimaryKey(departmentId); TabHaobanDepartment tab = mapper.selectByPrimaryKey(departmentId);
if (tab != null) { if (Objects.isNull(tab)) {
return;
}
tab.setStatusFlag(0); tab.setStatusFlag(0);
tab.setUpdateTime(new Date()); tab.setUpdateTime(new Date());
}
mapper.updateByPrimaryKeySelective(tab); mapper.updateByPrimaryKeySelective(tab);
try {
syncWelcomeSuitDeleteDepartment(departmentId, tab.getWxEnterpriseId());
} catch (Exception e) {
logger.error("同步部门-删除欢迎语适用部门信息异常", e);
}
}
private void syncWelcomeSuitDeleteDepartment(String departmentId, String wxEnterperiseId) {
// 列举部门被关联的欢迎语
TabHaobanWelcomeSuitRang query = new TabHaobanWelcomeSuitRang();
query.setWxEnterpriseId(wxEnterperiseId);
query.setSuitDepartmentId(departmentId);
query.setDeleteFlag(0);
List<TabHaobanWelcomeSuitRang> welcomeSuitRangList = welcomeSuitRangMapper.queryAll(query);
if (CollectionUtils.isEmpty(welcomeSuitRangList)) {
logger.info("部门查询为空");
return;
}
// 删除
welcomeSuitRangList.forEach(one -> {
one.setUpdateTime(new Date());
one.setDeleteFlag(1);
welcomeSuitRangMapper.update(one);
});
} }
@Override @Override
......
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