27 changed files with 474 additions and 88 deletions
@ -0,0 +1,171 @@ |
|||
package com.zdxt.app.task; |
|||
|
|||
import com.zdxt.auth.common.utils.StringUtils; |
|||
import com.zdxt.auth.project.system.dept.service.IDeptService; |
|||
import com.zdxt.code.domain.SrzDept; |
|||
import com.zdxt.code.service.ISrzDeptService; |
|||
import com.zdxt.domain.auth.Dept; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* @Author: kylin |
|||
* @Date: 2024/5/9 2:58 下午 |
|||
* @Version: 1.0 |
|||
* @Desc: TODO |
|||
*/ |
|||
@Component("synDeptInfoTask") |
|||
public class SynDeptInfoTask { |
|||
|
|||
@Value("${srnwg.secretKey}") |
|||
private String secretKey; |
|||
|
|||
@Autowired private ISrzDeptService iSrzDeptService; |
|||
@Autowired private IDeptService iDeptService; |
|||
|
|||
public static Map<String,String> params = new HashMap<>(); |
|||
|
|||
private static final Logger log = LoggerFactory.getLogger(SynDeptInfoTask.class); |
|||
|
|||
|
|||
public void run(){ |
|||
this.deptInfo(); |
|||
} |
|||
|
|||
/** 同步部门数据 */ |
|||
public void deptInfo(){ |
|||
log.info("====================> 市认证原始表 -> 业务表 同步开始"); |
|||
int insertNum = 0; |
|||
int updateNum = 0; |
|||
int rowNom_srz = 0; |
|||
try { |
|||
// 做个死循环, 一直到查寻不到数据了再break
|
|||
while (true) { |
|||
List<SrzDept> srzDeptList = iSrzDeptService.selectDeptByNeedUpdate(); |
|||
// 如果查出结果为空 或 长度为0 则跳出循环
|
|||
if (srzDeptList == null || srzDeptList.isEmpty() || srzDeptList.size() == 0) break; |
|||
|
|||
// 开始同步更新数据到用户表
|
|||
for(SrzDept srzDept : srzDeptList){ |
|||
log.info("====> 获取数据: {}", srzDept.getName()); |
|||
Dept dept = new Dept(); |
|||
BeanUtils.copyProperties(srzDept,dept); |
|||
/* 机构ID organizationId */ |
|||
dept.setDeptId(srzDept.getOrganizationId()); |
|||
// dept.setOrganizationId(srzDept.getOrganizationId());
|
|||
/* 机构父节点 parentId */ |
|||
dept.setParentId(srzDept.getParentId()); |
|||
dept.setOrganizationParentId(srzDept.getParentId()); |
|||
/* 机构名称 name */ |
|||
dept.setDeptName(srzDept.getName()); |
|||
// /* 机构代码 code */
|
|||
// dept.setCode(srzDept.getCode());
|
|||
// /* 作用点 effectOn */
|
|||
// dept.setEffectOn(srzDept.getEffectOn());
|
|||
// /* 任务ID taskId */
|
|||
// dept.setTaskId(srzDept.getTaskId());
|
|||
// /* 机构全路径 zzDisplayPath */
|
|||
// dept.setZzDisplayPath(srzDept.getZzDisplayPath());
|
|||
// /* 是否叶子节点 zzIsLeaf */
|
|||
// dept.setZzIsLeaf(srzDept.getZzIsLeaf());
|
|||
// /* 机构层级 zzLevel */
|
|||
// dept.setZzLevel(Integer.valueOf(srzDept.getZzLevel()));
|
|||
// /* 是否删除 isDeleted */
|
|||
// dept.setIsDeleted(srzDept.getIsDeleted());
|
|||
// /* 是否禁用 isDisabled */
|
|||
// dept.setIsDisabled(srzDept.getIsDisabled());
|
|||
// /* 系统ID systemId */
|
|||
// dept.setSystemId(srzDept.getSystemId());
|
|||
// /* 排序 sequence */
|
|||
// dept.setSequence(srzDept.getSequence());
|
|||
// /* 创建时间 createAt */
|
|||
// dept.setCreateAt(srzDept.getCreateAt());
|
|||
// /* 更新时间 updateAt */
|
|||
// dept.setUpdateAt(srzDept.getUpdateAt());
|
|||
// /* 下游唯一标识 guid */
|
|||
// dept.setGuid(srzDept.getGuid());
|
|||
// /* 是否驻区机构 isMappingUnit */
|
|||
// dept.setIsMappingUnit(srzDept.getIsMappingUnit());
|
|||
// /* 驻区机构上级机构id mappingUnitParentId */
|
|||
// dept.setMappingUnitParentId(srzDept.getMappingUnitParentId());
|
|||
// /* 省认证机构id srzUnitId */
|
|||
// dept.setSrzUnitId(srzDept.getSrzUnitId());
|
|||
// /* 机构简称 simpleName */
|
|||
// dept.setSimpleName(dept.getSimpleName());
|
|||
// /* 是否法定机构 isStatutoryOrg */
|
|||
// dept.setIsStatutoryOrg(srzDept.getIsStatutoryOrg());
|
|||
// /* 是否生效 isActive */
|
|||
// dept.setIsActive(srzDept.getIsActive());
|
|||
// /* 机构状态代码 unitStatusCode */
|
|||
// dept.setUnitStatusCode(srzDept.getUnitStatusCode());
|
|||
// /* 机构状态 unitStatus */
|
|||
// dept.setUnitStatus(srzDept.getUnitStatus());
|
|||
// /* 机构类型 unitType */
|
|||
// dept.setUnitType(srzDept.getUnitType());
|
|||
// /* 行政区划代码 xzqhCode */
|
|||
// dept.setXzqhCode(srzDept.getXzqhCode());
|
|||
// /* 行政区划 xzqh */
|
|||
// dept.setXzqh(srzDept.getXzqh());
|
|||
// /* 是否参公管理 isCGManager */
|
|||
// dept.setIsCGManager(srzDept.getIsCGManager());
|
|||
// /* 是否局(委)办 isBureauOffice */
|
|||
// dept.setIsBureauOffice(srzDept.getIsBureauOffice());
|
|||
// /* 机构类型代码 unitTypeCode */
|
|||
// dept.setUnitTypeCode(srzDept.getUnitTypeCode());
|
|||
// /* 单位性质代码 dwxzCode */
|
|||
// dept.setDwxzCode(srzDept.getDwxzCode());
|
|||
// /* 单位性质 dwxz */
|
|||
// dept.setDwxz(srzDept.getDwxz());
|
|||
// /* 系统单位类型编码 unitSysTypeCode */
|
|||
// dept.setUnitTypeCode(srzDept.getUnitTypeCode());
|
|||
// /* 系统单位类型 unitSysType */
|
|||
// dept.setUnitSysType(srzDept.getUnitSysType());
|
|||
// /* 单位系统类别描述 dwxtlbms */
|
|||
// dept.setDwxtlbms(srzDept.getDwxtlbms());
|
|||
// /* 机构规格代码 unitLevelCode */
|
|||
// dept.setUnitLevelCode(srzDept.getUnitLevelCode());
|
|||
// /* 机构规格 unitLevel */
|
|||
// dept.setUnitLevel(srzDept.getUnitLevel());
|
|||
// /* 统一社会信用代码 creditcode */
|
|||
// dept.setCreditcode(srzDept.getCreditcode());
|
|||
// /* 描述 description */
|
|||
// dept.setDescription(srzDept.getDescription());
|
|||
|
|||
//限制唯一部门id
|
|||
String organizationId = srzDept.getOrganizationId(); |
|||
if(StringUtils.isNotEmpty(organizationId)){ |
|||
Dept uniqueDept = iDeptService.selectDeptById(organizationId); |
|||
if (null != uniqueDept && uniqueDept.getDeptId() != null) { |
|||
// 更新数据库
|
|||
dept.setDeptId(uniqueDept.getDeptId()); |
|||
log.info("====> 更新数据: {}: {}", uniqueDept.getDeptId(), uniqueDept.getDeptName()); |
|||
int rowNum = iDeptService.updateDept(dept); |
|||
updateNum += rowNum; |
|||
} else { |
|||
// 插入数据库
|
|||
log.info("====> 新增数据: {}: {}", dept.getDeptId(), dept.getDeptName()); |
|||
int rowNum = iDeptService.insertDept(dept); |
|||
insertNum += rowNum; |
|||
} |
|||
srzDept.setNeedUpdate(1); |
|||
int srz_num = iSrzDeptService.updateSrzDept(srzDept); |
|||
rowNom_srz += srz_num; |
|||
} |
|||
} |
|||
} |
|||
log.info("新增部门数量 : {} / 更新用户数量 : {} / 更新原始表数 : {}", insertNum, updateNum, rowNom_srz); |
|||
} catch (Exception e) { |
|||
System.out.println(e); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue