Commit c1c7227f authored by 吴泽佳's avatar 吴泽佳

代码优化

parent 5e3a7bb7
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
<artifactId>feo-job</artifactId> <artifactId>feo-job</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>feo-job</name> <name>feo-job</name>
<packaging>jar</packaging>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<skipTests>true</skipTests>
</properties> </properties>
<dependencies> <dependencies>
...@@ -141,20 +143,20 @@ ...@@ -141,20 +143,20 @@
</dependencies> </dependencies>
<build> <build>
<!-- <plugins>--> <plugins>
<!-- <plugin>--> <plugin>
<!-- <groupId>org.springframework.boot</groupId>--> <groupId>org.springframework.boot</groupId>
<!-- <artifactId>spring-boot-maven-plugin</artifactId>--> <artifactId>spring-boot-maven-plugin</artifactId>
<!-- <configuration>--> <configuration>
<!-- <excludes>--> <excludes>
<!-- <exclude>--> <exclude>
<!-- <groupId>org.projectlombok</groupId>--> <groupId>org.projectlombok</groupId>
<!-- <artifactId>lombok</artifactId>--> <artifactId>lombok</artifactId>
<!-- </exclude>--> </exclude>
<!-- </excludes>--> </excludes>
<!-- </configuration>--> </configuration>
<!-- </plugin>--> </plugin>
<!-- </plugins>--> </plugins>
</build> </build>
</project> </project>
package com.tanpu.feo.feojob.constant;
/**
* @description: OrgExt 表常用变量
* @author: zejia zj wu
* @create: 2021-06-02 15:04
**/
public class OrgExtConstant {
public static final String MODEL_ONE = "1"; //从企业微信同步
public static final String MODEL_TWO = "2"; //自定义
}
...@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; ...@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5; import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tanpu.feo.feojob.constant.BaseConstant; import com.tanpu.feo.feojob.constant.BaseConstant;
import com.tanpu.feo.feojob.constant.OrgExtConstant;
import com.tanpu.feo.feojob.dto.WorkDataDto; import com.tanpu.feo.feojob.dto.WorkDataDto;
import com.tanpu.feo.feojob.dto.WxCpDepartDto; import com.tanpu.feo.feojob.dto.WxCpDepartDto;
import com.tanpu.feo.feojob.entity.*; import com.tanpu.feo.feojob.entity.*;
...@@ -75,7 +76,7 @@ public class OrgSyncByWxcpJob { ...@@ -75,7 +76,7 @@ public class OrgSyncByWxcpJob {
*/ */
public void orgSyncByWxcp(String isAuto) { public void orgSyncByWxcp(String isAuto) {
// 1 扫描 org_ext 表 获取需要 执行同步的 机构 // 1 扫描 org_ext 表 获取需要 执行同步的 机构
List<OrgExtEntity> orgExtList = orgExtService.findOrgExtByAyto(); List<OrgExtEntity> orgExtList = orgExtService.findOrgExtByModel(OrgExtConstant.MODEL_ONE);
for (OrgExtEntity orgExtEntity : orgExtList) { for (OrgExtEntity orgExtEntity : orgExtList) {
String orgId = orgExtEntity.getOrgId(); String orgId = orgExtEntity.getOrgId();
log.info("======开始同步机构:{} 的信息======", orgId); log.info("======开始同步机构:{} 的信息======", orgId);
...@@ -93,7 +94,7 @@ public class OrgSyncByWxcpJob { ...@@ -93,7 +94,7 @@ public class OrgSyncByWxcpJob {
wxCpDepartList = getWxCpDepartList(wxCpDefaultConfig); wxCpDepartList = getWxCpDepartList(wxCpDefaultConfig);
wxCpDepartDtoList = getWxCpUserList(wxCpDepartList,wxCpDefaultConfig); wxCpDepartDtoList = getWxCpUserList(wxCpDepartList,wxCpDefaultConfig);
} catch (Exception e) { } catch (Exception e) {
log.info("======从企业微信获取组织信息及员工信息失败->机构:{} -> 错误信息-> {}======", orgId, e.getMessage()); log.error("======从企业微信获取组织信息及员工信息失败->机构:{} -> 错误信息-> {}======", orgId, e.getMessage());
continue; continue;
} }
log.info("======从企业微信获取组织信息及员工信息 结束======"); log.info("======从企业微信获取组织信息及员工信息 结束======");
...@@ -120,7 +121,7 @@ public class OrgSyncByWxcpJob { ...@@ -120,7 +121,7 @@ public class OrgSyncByWxcpJob {
//7 讲最新的md5值 存至 orgExtEntity 表中 //7 讲最新的md5值 存至 orgExtEntity 表中
orgExtEntity.setMd5WxcpData(digestHex); orgExtEntity.setMd5WxcpData(digestHex);
orgExtService.updataById(orgExtEntity); orgExtService.updateById(orgExtEntity);
} }
} }
...@@ -268,7 +269,7 @@ public class OrgSyncByWxcpJob { ...@@ -268,7 +269,7 @@ public class OrgSyncByWxcpJob {
} }
//更新 //更新
Long parentId1 = wxCpDepartDto.getParentId(); Long parentId1 = wxCpDepartDto.getParentId();
String parentId = ObjectUtil.isNull(hashMap2.get(parentId1)) ? null :orgId + "_" + parentId1; // ObjectUtil.isNull(hashMap2.get(parentId1)) String parentId = ObjectUtil.isNull(hashMap2.get(parentId1)) ? null :orgId + "_" + parentId1;
Integer level = getLevel(hashMap2, wxCpDepartDto.getId()); Integer level = getLevel(hashMap2, wxCpDepartDto.getId());
if (!department.getDepartmentName().equals(wxCpDepartDto.getName()) || StrUtil.compareIgnoreCase(department.getParentDepartId(), parentId, false) != 0 if (!department.getDepartmentName().equals(wxCpDepartDto.getName()) || StrUtil.compareIgnoreCase(department.getParentDepartId(), parentId, false) != 0
|| !department.getMembers().equals(wxCpDepartDto.getMembers()) || !level.equals(department.getLevel())) { || !department.getMembers().equals(wxCpDepartDto.getMembers()) || !level.equals(department.getLevel())) {
...@@ -424,7 +425,6 @@ public class OrgSyncByWxcpJob { ...@@ -424,7 +425,6 @@ public class OrgSyncByWxcpJob {
hashMap.remove(id); hashMap.remove(id);
} }
for (String key : hashMap.keySet()) { for (String key : hashMap.keySet()) {
// todo
WxCpUser wxCpUser = hashMap.get(key); WxCpUser wxCpUser = hashMap.get(key);
UserInfoEntity userInfo = new UserInfoEntity(); UserInfoEntity userInfo = new UserInfoEntity();
userInfo.setUiTelphone(wxCpUser.getMobile()); userInfo.setUiTelphone(wxCpUser.getMobile());
......
...@@ -27,14 +27,15 @@ public class OrgExtService extends ServiceImpl<OrgExtMapper, OrgExtEntity> { ...@@ -27,14 +27,15 @@ public class OrgExtService extends ServiceImpl<OrgExtMapper, OrgExtEntity> {
private OrgExtMapper orgExtMapper; private OrgExtMapper orgExtMapper;
public List<OrgExtEntity> findOrgExtByAyto() { public List<OrgExtEntity> findOrgExtByModel(String model) {
return orgExtMapper.selectList(Wrappers.lambdaQuery(OrgExtEntity.class).eq(OrgExtEntity::getModel,"1").eq(OrgExtEntity::getDeleteTag, BaseConstant.DeleteTagStr.NOT_DELETED)); return orgExtMapper.selectList(Wrappers.lambdaQuery(OrgExtEntity.class).eq(OrgExtEntity::getModel, model).eq(OrgExtEntity::getDeleteTag, BaseConstant.DeleteTagStr.NOT_DELETED));
} }
@Transactional @Transactional
public void updataById(OrgExtEntity orgExt) { public boolean updateById(OrgExtEntity orgExt) {
orgExt.setUpdateBy("SYS"); orgExt.setUpdateBy("SYS");
orgExt.setUpdateTime(new Date()); orgExt.setUpdateTime(new Date());
orgExtMapper.updateById(orgExt); orgExtMapper.updateById(orgExt);
return true;
} }
} }
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