优化机构
This commit is contained in:
@@ -66,5 +66,11 @@ public class DataSyncController {
|
|||||||
return iDataSyncService.orgDataSync();
|
return iDataSyncService.orgDataSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("同步组织机构,添加参数")
|
||||||
|
@PostMapping("/updateByOrgs")
|
||||||
|
public String updateByOrgs() throws Exception {
|
||||||
|
return iDataSyncService.updateByOrgs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ public interface IDataSyncService {
|
|||||||
public String dataSync();
|
public String dataSync();
|
||||||
|
|
||||||
public String orgDataSync();
|
public String orgDataSync();
|
||||||
|
|
||||||
|
public String updateByOrgs();
|
||||||
}
|
}
|
||||||
|
|||||||
+48
@@ -6,6 +6,7 @@ import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
|
|||||||
import com.adc.da.slrs.sarBussStandAttrInfo.service.ISarBussStandAttrInfoService;
|
import com.adc.da.slrs.sarBussStandAttrInfo.service.ISarBussStandAttrInfoService;
|
||||||
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||||
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
|
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
|
||||||
|
import com.adc.da.slrs.sarInstitution.dao.TsInstitutionDao;
|
||||||
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
|
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
|
||||||
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
|
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
|
||||||
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
||||||
@@ -51,6 +52,8 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
ITsInstitutionService tsInstitutionService;
|
ITsInstitutionService tsInstitutionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
TsInstitutionDao tsInstitutionDao;
|
||||||
|
@Autowired
|
||||||
private ISarStandardsInfoService iSarStandardsInfoService;
|
private ISarStandardsInfoService iSarStandardsInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISarBussionessStandService iSarBussionessStandService;
|
private ISarBussionessStandService iSarBussionessStandService;
|
||||||
@@ -354,6 +357,7 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
|
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
|
||||||
public String orgDataSync(){
|
public String orgDataSync(){
|
||||||
try{
|
try{
|
||||||
@@ -423,6 +427,15 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
}
|
}
|
||||||
tsInstitutionService.removeByIds(delIdList);
|
tsInstitutionService.removeByIds(delIdList);
|
||||||
}
|
}
|
||||||
|
//全部部门
|
||||||
|
List<TsInstitution> allTsInstitutionListForPids = new ArrayList<>(addTsInstitutionList);
|
||||||
|
allTsInstitutionListForPids.addAll(updateTsInstitutionList);
|
||||||
|
for (TsInstitution tsInstitution : allTsInstitutionListForPids){
|
||||||
|
List<String> parentIds = new ArrayList<>();
|
||||||
|
getParentTaxCompanyIds(allTsInstitutionListForPids, tsInstitution.getId(), parentIds);
|
||||||
|
tsInstitution.setParentIds(String.join(",",parentIds));
|
||||||
|
}
|
||||||
|
tsInstitutionService.updateBatchById(allTsInstitutionListForPids);
|
||||||
}else{
|
}else{
|
||||||
logger.info("本次获取组织机构的数据为空,原因有2种:1、没有同步数据 2、请求接口报错");
|
logger.info("本次获取组织机构的数据为空,原因有2种:1、没有同步数据 2、请求接口报错");
|
||||||
}
|
}
|
||||||
@@ -432,4 +445,39 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
}
|
}
|
||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String updateByOrgs(){
|
||||||
|
QueryWrapper<TsInstitution> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.ne("id","");
|
||||||
|
List<TsInstitution> tsInstitutions = tsInstitutionDao.selectList(queryWrapper);
|
||||||
|
//全部部门
|
||||||
|
List<TsInstitution> allTsInstitutionListForPids = new ArrayList<>(tsInstitutions);
|
||||||
|
// allTsInstitutionListForPids.addAll(updateTsInstitutionList);
|
||||||
|
for (TsInstitution tsInstitution : allTsInstitutionListForPids){
|
||||||
|
List<String> parentIds = new ArrayList<>();
|
||||||
|
getParentTaxCompanyIds(allTsInstitutionListForPids, tsInstitution.getId(), parentIds);
|
||||||
|
tsInstitution.setParentIds(String.join(",",parentIds));
|
||||||
|
logger.info(String.valueOf(tsInstitution));
|
||||||
|
}
|
||||||
|
tsInstitutionService.updateBatchById(allTsInstitutionListForPids);
|
||||||
|
return allTsInstitutionListForPids.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归获取父级ids
|
||||||
|
* @param taxCompanyList
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
private void getParentTaxCompanyIds(List<TsInstitution> taxCompanyList, String id, List<String> parentIds) {
|
||||||
|
for (TsInstitution taxCompany : taxCompanyList) {
|
||||||
|
if (StringUtils.isEmpty(taxCompany.getParentId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//判断是否有父节点
|
||||||
|
if (id.equals(taxCompany.getId())) {
|
||||||
|
parentIds.add(taxCompany.getParentId());
|
||||||
|
getParentTaxCompanyIds(taxCompanyList, taxCompany.getParentId(), parentIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public class TsInstitution extends BaseEntity {
|
|||||||
@ApiModelProperty(value = "上级机构")
|
@ApiModelProperty(value = "上级机构")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
|
private String parentIds;
|
||||||
|
|
||||||
@ApiModelProperty(value = "机构层级")
|
@ApiModelProperty(value = "机构层级")
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
|||||||
+23
-23
@@ -460,29 +460,29 @@ public class TsUserServiceImpl extends ServiceImpl<TsUserDao, TsUser> implements
|
|||||||
public IPage<TsUser> getAllUsers(TsUser tsUser) {
|
public IPage<TsUser> getAllUsers(TsUser tsUser) {
|
||||||
List<String> ids=new ArrayList<>();
|
List<String> ids=new ArrayList<>();
|
||||||
ids.add(tsUser.getInstitutionId());
|
ids.add(tsUser.getInstitutionId());
|
||||||
List<String> middle=new ArrayList<>();
|
// List<String> middle=new ArrayList<>();
|
||||||
middle.addAll(ids);
|
// middle.addAll(ids);
|
||||||
boolean flag=true;
|
// boolean flag=true;
|
||||||
while (flag){
|
// while (flag){
|
||||||
QueryWrapper<TsInstitution> queryWrapper=new QueryWrapper<>();
|
// QueryWrapper<TsInstitution> queryWrapper=new QueryWrapper<>();
|
||||||
queryWrapper.in("parent_id",middle);
|
// queryWrapper.in("parent_id",middle);
|
||||||
List<TsInstitution> tsmiddle=tsInstitutionService.list(queryWrapper);
|
// List<TsInstitution> tsmiddle=tsInstitutionService.list(queryWrapper);
|
||||||
if (tsmiddle.size()>0){
|
// if (tsmiddle.size()>0){
|
||||||
tsmiddle.forEach(tsInstitution -> {
|
// tsmiddle.forEach(tsInstitution -> {
|
||||||
middle.add(tsInstitution.getId());
|
// middle.add(tsInstitution.getId());
|
||||||
});
|
// });
|
||||||
middle.removeAll(ids);
|
// middle.removeAll(ids);
|
||||||
ids.addAll(middle);
|
// ids.addAll(middle);
|
||||||
}else {
|
// }else {
|
||||||
tsmiddle.forEach(tsInstitution -> {
|
// tsmiddle.forEach(tsInstitution -> {
|
||||||
middle.add(tsInstitution.getId());
|
// middle.add(tsInstitution.getId());
|
||||||
});
|
// });
|
||||||
middle.removeAll(ids);
|
// middle.removeAll(ids);
|
||||||
ids.addAll(middle);
|
// ids.addAll(middle);
|
||||||
flag=false;
|
// flag=false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
ids.removeIf(s -> null==s);
|
// ids.removeIf(s -> null==s);
|
||||||
Page<TsUser> tsUserPage = new Page<>();
|
Page<TsUser> tsUserPage = new Page<>();
|
||||||
tsUserPage.setCurrent(tsUser.getCurrent());
|
tsUserPage.setCurrent(tsUser.getCurrent());
|
||||||
tsUserPage.setSize(tsUser.getSize());
|
tsUserPage.setSize(tsUser.getSize());
|
||||||
|
|||||||
@@ -82,6 +82,8 @@
|
|||||||
on u.usid=up.user_id
|
on u.usid=up.user_id
|
||||||
left join ts_position p
|
left join ts_position p
|
||||||
on up.position_id=p.id
|
on up.position_id=p.id
|
||||||
|
left join ts_institution ti
|
||||||
|
on ti.id = u.INSTITUTION_ID
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
||||||
and (u.uname like concat('%',#{TsUser.uname},'%') or u.ACCOUNT like concat(#{TsUser.uname},'%'))
|
and (u.uname like concat('%',#{TsUser.uname},'%') or u.ACCOUNT like concat(#{TsUser.uname},'%'))
|
||||||
@@ -90,9 +92,9 @@
|
|||||||
and u.email like concat('%',#{TsUser.email},'%')
|
and u.email like concat('%',#{TsUser.email},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test=" null != ids and ids.size()> 0">
|
<if test=" null != ids and ids.size()> 0">
|
||||||
and INSTITUTION_ID in
|
and
|
||||||
<foreach item="id" collection="ids" open="(" separator="," close=")" index="index">
|
<foreach item="id" collection="ids" open="(" separator="or" close=")" index="index">
|
||||||
#{id}
|
ti.parent_ids like concat('%',#{id},'%')
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
ORDER BY p.id is null,p.create_time
|
ORDER BY p.id is null,p.create_time
|
||||||
@@ -105,6 +107,8 @@
|
|||||||
on u.usid=up.user_id
|
on u.usid=up.user_id
|
||||||
left join ts_position p
|
left join ts_position p
|
||||||
on up.position_id=p.id
|
on up.position_id=p.id
|
||||||
|
left join ts_institution ti
|
||||||
|
on ti.id = u.INSTITUTION_ID
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
||||||
and u.uname like concat('%',#{TsUser.uname},'%')
|
and u.uname like concat('%',#{TsUser.uname},'%')
|
||||||
@@ -113,9 +117,9 @@
|
|||||||
and u.email like concat('%',#{TsUser.email},'%')
|
and u.email like concat('%',#{TsUser.email},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test=" null != ids and ids.size()> 0">
|
<if test=" null != ids and ids.size()> 0">
|
||||||
and INSTITUTION_ID in
|
and
|
||||||
<foreach item="id" collection="ids" open="(" separator="," close=")" index="index">
|
<foreach item="id" collection="ids" open="(" separator="or" close=")" index="index">
|
||||||
#{id}
|
ti.parent_ids like concat('%',#{id},'%')
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user