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

代码优化

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