分部接口整理、代码优化
parent
8c5106d06b
commit
aa3d0742ff
@ -1,154 +0,0 @@
|
|||||||
package com.engine.organization.entity.company.bo;
|
|
||||||
|
|
||||||
import com.engine.organization.entity.company.dto.CompListDTO;
|
|
||||||
import com.engine.organization.entity.company.param.CompSearchParam;
|
|
||||||
import com.engine.organization.entity.company.po.CompPO;
|
|
||||||
import com.engine.organization.entity.searchtree.SearchTree;
|
|
||||||
import com.engine.organization.mapper.comp.CompMapper;
|
|
||||||
import com.engine.organization.util.db.MapperProxyFactory;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import weaver.crm.Maint.SectorInfoComInfo;
|
|
||||||
import weaver.general.StringUtil;
|
|
||||||
import weaver.general.Util;
|
|
||||||
import weaver.hrm.resource.ResourceComInfo;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:
|
|
||||||
* @author:dxfeng
|
|
||||||
* @createTime: 2022/05/16
|
|
||||||
* @version: 1.0
|
|
||||||
*/
|
|
||||||
public class CompBO {
|
|
||||||
|
|
||||||
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list) {
|
|
||||||
|
|
||||||
Map<Long, CompPO> poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item));
|
|
||||||
|
|
||||||
List<CompListDTO> dtoList = list.stream().map(e ->
|
|
||||||
CompListDTO
|
|
||||||
.builder()
|
|
||||||
.id(e.getId())
|
|
||||||
.compNo(e.getCompNo())
|
|
||||||
.compName(e.getCompName())
|
|
||||||
.compNameShort(e.getCompNameShort())
|
|
||||||
.parentCompany(e.getParentCompany())
|
|
||||||
.parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName())
|
|
||||||
.orgCode(e.getOrgCode())
|
|
||||||
.industry(new SectorInfoComInfo().getSectorInfoname(Util.null2String(e.getIndustry())))
|
|
||||||
.compPrincipal(getUserNameById( Util.null2String(e.getCompPrincipal())))
|
|
||||||
.showOrder(e.getShowOrder())
|
|
||||||
.forbiddenTag(e.getForbiddenTag())
|
|
||||||
.build()).collect(Collectors.toList());
|
|
||||||
Map<Long, List<CompListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany));
|
|
||||||
// 处理被引用数据
|
|
||||||
List<String> usedIds = MapperProxyFactory.getProxy(CompMapper.class).listUsedId();
|
|
||||||
// 兼容MySQL
|
|
||||||
usedIds.addAll(MapperProxyFactory.getProxy(CompMapper.class).listUsedIds());
|
|
||||||
List<String> collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList());
|
|
||||||
Set<Long> leafs = new HashSet<>();
|
|
||||||
List<CompListDTO> collectTree = dtoList.stream().peek(e -> {
|
|
||||||
List<CompListDTO> childList = collects.get(e.getId());
|
|
||||||
leafs.add(e.getId());
|
|
||||||
if (CollectionUtils.isNotEmpty(childList)) {
|
|
||||||
e.setChildren(childList);
|
|
||||||
e.setIsUsed(1);
|
|
||||||
} else {
|
|
||||||
if (collect.contains(Util.null2String(e.getId()))) {
|
|
||||||
e.setIsUsed(1);
|
|
||||||
} else {
|
|
||||||
e.setIsUsed(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return collectTree.stream().filter(item->!leafs.contains(item.getParentCompany())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list, List<CompPO> filterList) {
|
|
||||||
// 搜索结果为空,直接返回空
|
|
||||||
if (CollectionUtils.isEmpty(filterList)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
// 递归添加父级数据
|
|
||||||
Map<Long, CompPO> poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item));
|
|
||||||
List<CompPO> addedList = new ArrayList<>();
|
|
||||||
for (CompPO po : filterList) {
|
|
||||||
dealParentData(addedList, po, poMaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buildCompDTOList(addedList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CompPO convertParamToPO(CompSearchParam param, Long employeeId) {
|
|
||||||
if (null == param) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return CompPO
|
|
||||||
.builder()
|
|
||||||
.id(param.getId() == null ? 0 : param.getId())
|
|
||||||
.compNo(param.getCompNo())
|
|
||||||
.compName(param.getCompName())
|
|
||||||
.compNameShort(param.getCompNameShort())
|
|
||||||
.parentCompany(param.getParentCompany())
|
|
||||||
.ecCompany(param.getEcCompany())
|
|
||||||
.orgCode(param.getOrgCode())
|
|
||||||
.industry(param.getIndustry())
|
|
||||||
.compPrincipal(param.getCompPrincipal())
|
|
||||||
.description(param.getDescription())
|
|
||||||
.forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)
|
|
||||||
.deleteType(0)
|
|
||||||
.createTime(new Date())
|
|
||||||
.updateTime(new Date())
|
|
||||||
.creator(employeeId)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SearchTree> buildSetToSearchTree(Set<CompPO> comps) {
|
|
||||||
return comps.stream().sorted(Comparator.comparing(CompPO::getShowOrder)).map(item -> {
|
|
||||||
SearchTree tree = new SearchTree();
|
|
||||||
tree.setCanClick(true);
|
|
||||||
tree.setCanceled(item.getForbiddenTag() != 0);
|
|
||||||
tree.setIcon("icon-coms-LargeArea");
|
|
||||||
tree.setId(item.getId().toString());
|
|
||||||
tree.setIsParent(false);
|
|
||||||
tree.setIsVirtual("0");
|
|
||||||
tree.setName(item.getCompName());
|
|
||||||
tree.setPid(null == item.getParentCompany() ? "0" : item.getParentCompany().toString());
|
|
||||||
tree.setSelected(false);
|
|
||||||
tree.setType("1");
|
|
||||||
tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder());
|
|
||||||
return tree;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归获取查询后数据的父级数据
|
|
||||||
*
|
|
||||||
* @param addedList
|
|
||||||
* @param po
|
|
||||||
* @param poMaps
|
|
||||||
*/
|
|
||||||
private static void dealParentData(List<CompPO> addedList, CompPO po, Map<Long, CompPO> poMaps) {
|
|
||||||
if (!addedList.contains(po)) {
|
|
||||||
addedList.add(po);
|
|
||||||
}
|
|
||||||
CompPO parentCompPO = poMaps.get(po.getParentCompany());
|
|
||||||
if (null != parentCompPO) {
|
|
||||||
dealParentData(addedList, parentCompPO, poMaps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getUserNameById(String userId) {
|
|
||||||
try {
|
|
||||||
if (StringUtil.isEmpty(userId)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return new ResourceComInfo().getLastname(userId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
package com.engine.organization.entity.company.dto;
|
|
||||||
|
|
||||||
import com.engine.organization.annotation.OrganizationTable;
|
|
||||||
import com.engine.organization.annotation.TableTitle;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:
|
|
||||||
* @author:dxfeng
|
|
||||||
* @createTime: 2022/05/16
|
|
||||||
* @version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@OrganizationTable(pageId = "2c66b3a4-d4f8-11ec-9774-00ffcbed7508")
|
|
||||||
public class CompListDTO {
|
|
||||||
/**
|
|
||||||
* 主键id
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 是否被引用
|
|
||||||
*/
|
|
||||||
private Integer isUsed;
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "名称", dataIndex = "compName", key = "compName")
|
|
||||||
private String compName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "编号", dataIndex = "compNo", key = "compNo")
|
|
||||||
private String compNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简称
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "简称", dataIndex = "compNameShort", key = "compNameShort")
|
|
||||||
private String compNameShort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级公司
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "上级分部", dataIndex = "parentCompName", key = "parentCompName")
|
|
||||||
private String parentCompName;
|
|
||||||
|
|
||||||
private Long parentCompany;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组织机构代码
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "组织机构代码", dataIndex = "orgCode", key = "orgCode")
|
|
||||||
private String orgCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行业
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "行业", dataIndex = "industry", key = "industry")
|
|
||||||
private String industry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 负责人
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "负责人", dataIndex = "compPrincipal", key = "compPrincipal")
|
|
||||||
private String compPrincipal;
|
|
||||||
|
|
||||||
@TableTitle(title = "显示顺序", dataIndex = "showOrder", key = "showOrder", sorter = true)
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 禁用标记
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "是否启用", dataIndex = "forbiddenTag", key = "forbiddenTag")
|
|
||||||
private int forbiddenTag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作列
|
|
||||||
*/
|
|
||||||
@TableTitle(title = "", dataIndex = "operate", key = "operate")
|
|
||||||
private String operate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 子节点
|
|
||||||
*/
|
|
||||||
private List<CompListDTO> children;
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package com.engine.organization.entity.company.param;
|
|
||||||
|
|
||||||
import com.engine.organization.common.BaseQueryParam;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:
|
|
||||||
* @author:dxfeng
|
|
||||||
* @createTime: 2022/05/16
|
|
||||||
* @version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CompSearchParam extends BaseQueryParam {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private String compNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
private String compName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简称
|
|
||||||
*/
|
|
||||||
private String compNameShort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级公司
|
|
||||||
*/
|
|
||||||
private Long parentCompany;
|
|
||||||
private Long ecCompany;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组织机构代码
|
|
||||||
*/
|
|
||||||
private String orgCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行业
|
|
||||||
*/
|
|
||||||
private Integer industry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 负责人
|
|
||||||
*/
|
|
||||||
private Integer compPrincipal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 说明
|
|
||||||
*/
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 禁用标记
|
|
||||||
*/
|
|
||||||
private Boolean forbiddenTag;
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
package com.engine.organization.entity.company.po;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:
|
|
||||||
* @author:dxfeng
|
|
||||||
* @createTime: 2022/05/16
|
|
||||||
* @version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CompPO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private String compNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
private String compName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简称
|
|
||||||
*/
|
|
||||||
private String compNameShort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级公司
|
|
||||||
*/
|
|
||||||
private Long parentCompany;
|
|
||||||
|
|
||||||
private Long ecCompany;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组织机构代码
|
|
||||||
*/
|
|
||||||
private String orgCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行业
|
|
||||||
*/
|
|
||||||
private Integer industry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 负责人
|
|
||||||
*/
|
|
||||||
private Integer compPrincipal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 说明
|
|
||||||
*/
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 禁用标记
|
|
||||||
*/
|
|
||||||
private Integer forbiddenTag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序
|
|
||||||
*/
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
private Long creator;
|
|
||||||
private int deleteType;
|
|
||||||
private Date createTime;
|
|
||||||
private Date updateTime;
|
|
||||||
}
|
|
@ -1,181 +0,0 @@
|
|||||||
package com.engine.organization.mapper.comp;
|
|
||||||
|
|
||||||
import com.engine.organization.entity.company.po.CompPO;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description:
|
|
||||||
* @author:dxfeng
|
|
||||||
* @createTime: 2022/05/16
|
|
||||||
* @version: 1.0
|
|
||||||
*/
|
|
||||||
public interface CompMapper {
|
|
||||||
/**
|
|
||||||
* 列表查询
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> list(@Param("orderSql") String orderSql);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有被引用的ID
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<String> listUsedId();
|
|
||||||
|
|
||||||
List<String> listUsedIds();
|
|
||||||
|
|
||||||
List<String> hasSubs();
|
|
||||||
|
|
||||||
List<String> hasDetachSubs(@Param("companyIds") Collection<Long> companyIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据搜索条件查询数据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> listByFilter(@Param("compPO") CompPO compPO, @Param("orderSql") String orderSql);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取顶级数据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> listParent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取子层级数据
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> listChild(@Param("ids") Collection ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前ID的子元素
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> listChildByPID(@Param("pid") String pid);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前ID的子元素个数
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int countChildByPID(@Param("pid") long pid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID查询数据
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
CompPO listById(@Param("id") Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据UUID查询数据
|
|
||||||
*
|
|
||||||
* @param uuid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
CompPO getCompanyByUUID(@Param("uuid") String uuid);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据No查询数据
|
|
||||||
*
|
|
||||||
* @param compNo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> listByNo(@Param("compNo") String compNo);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 浏览按钮展示数据查询
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> listCompsByIds(@Param("ids") Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID批量查询数据
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CompPO> getCompsByIds(@Param("ids") Collection<Long> ids);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存公司/分部基础信息
|
|
||||||
*
|
|
||||||
* @param compPO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int insertIgnoreNull(CompPO compPO);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新主表内容
|
|
||||||
*
|
|
||||||
* @param compPO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int updateBaseComp(CompPO compPO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新禁用标记
|
|
||||||
*
|
|
||||||
* @param compPO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int updateForbiddenTagById(CompPO compPO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
int deleteByIds(@Param("ids") Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取最大排序
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getMaxShowOrder();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据名称和上级查找ID
|
|
||||||
*
|
|
||||||
* @param companyName
|
|
||||||
* @param parentCompany
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Long getIdByNameAndPid(@Param("companyName") String companyName, @Param("parentCompany") Long parentCompany);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计顶层分部个数
|
|
||||||
*
|
|
||||||
* @param parentCompany
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer countTopCompany(@Param("parentCompany") Long parentCompany);
|
|
||||||
|
|
||||||
int checkRepeatNo(@Param("companyNo") String companyNo, @Param("id") Long id);
|
|
||||||
|
|
||||||
CompPO getCompanyByNo(@Param("companyNo") String companyNo);
|
|
||||||
|
|
||||||
List<Long> getCompanyIdsByUuid(@Param("uuids") List<String> uuids);
|
|
||||||
|
|
||||||
}
|
|
@ -1,550 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
||||||
<mapper namespace="com.engine.organization.mapper.comp.CompMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.engine.organization.entity.company.po.CompPO">
|
|
||||||
<result column="id" property="id"/>
|
|
||||||
<result column="comp_no" property="compNo"/>
|
|
||||||
<result column="comp_name" property="compName"/>
|
|
||||||
<result column="comp_name_short" property="compNameShort"/>
|
|
||||||
<result column="parent_company" property="parentCompany"/>
|
|
||||||
<result column="ec_company" property="ecCompany"/>
|
|
||||||
<result column="org_code" property="orgCode"/>
|
|
||||||
<result column="industry" property="industry"/>
|
|
||||||
<result column="comp_principal" property="compPrincipal"/>
|
|
||||||
<result column="description" property="description"/>
|
|
||||||
<result column="forbidden_tag" property="forbiddenTag"/>
|
|
||||||
<result column="show_order" property="showOrder"/>
|
|
||||||
<result column="creator" property="creator"/>
|
|
||||||
<result column="delete_type" property="deleteType"/>
|
|
||||||
<result column="create_time" property="createTime"/>
|
|
||||||
<result column="update_time" property="updateTime"/>
|
|
||||||
|
|
||||||
<result column="uuid" property="uuid"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<!-- 表字段 -->
|
|
||||||
<sql id="baseColumns">
|
|
||||||
t
|
|
||||||
.
|
|
||||||
id
|
|
||||||
, t.comp_no
|
|
||||||
, t.comp_name
|
|
||||||
, t.comp_name_short
|
|
||||||
, t.parent_company
|
|
||||||
, t.ec_company
|
|
||||||
, t.org_code
|
|
||||||
, t.industry
|
|
||||||
, t.comp_principal
|
|
||||||
, t.description
|
|
||||||
, t.forbidden_tag
|
|
||||||
, t.show_order
|
|
||||||
, t.creator
|
|
||||||
, t.delete_type
|
|
||||||
, t.create_time
|
|
||||||
, t.update_time
|
|
||||||
, t.uuid
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullSql">
|
|
||||||
and ifnull(parent_company,'0')='0'
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullSql" databaseId="sqlserver">
|
|
||||||
and isnull(parent_company,'0')='0'
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullSql" databaseId="oracle">
|
|
||||||
and NVL(parent_company,'0')='0'
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullParentCompany">
|
|
||||||
and ifnull(parent_company,0) =
|
|
||||||
#{parentCompany}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullParentCompany" databaseId="sqlserver">
|
|
||||||
and isnull(parent_company,0) =
|
|
||||||
#{parentCompany}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="nullParentCompany" databaseId="oracle">
|
|
||||||
and NVL(parent_company,0) =
|
|
||||||
#{parentCompany}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.company.po.CompPO" keyProperty="id"
|
|
||||||
keyColumn="id" useGeneratedKeys="true">
|
|
||||||
INSERT INTO jcl_org_comp
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="creator != null">
|
|
||||||
creator,
|
|
||||||
</if>
|
|
||||||
<if test="deleteType != null">
|
|
||||||
delete_type,
|
|
||||||
</if>
|
|
||||||
<if test="createTime != null">
|
|
||||||
create_time,
|
|
||||||
</if>
|
|
||||||
<if test="updateTime != null">
|
|
||||||
update_time,
|
|
||||||
</if>
|
|
||||||
<if test="compNo != null ">
|
|
||||||
comp_no,
|
|
||||||
</if>
|
|
||||||
<if test="compName != null ">
|
|
||||||
comp_name,
|
|
||||||
</if>
|
|
||||||
<if test="compNameShort != null ">
|
|
||||||
comp_name_short,
|
|
||||||
</if>
|
|
||||||
<if test="parentCompany != null ">
|
|
||||||
parent_company,
|
|
||||||
</if>
|
|
||||||
<if test="ecCompany != null ">
|
|
||||||
ec_company,
|
|
||||||
</if>
|
|
||||||
<if test="orgCode != null ">
|
|
||||||
org_code,
|
|
||||||
</if>
|
|
||||||
<if test="industry != null ">
|
|
||||||
industry,
|
|
||||||
</if>
|
|
||||||
<if test="compPrincipal != null ">
|
|
||||||
comp_principal,
|
|
||||||
</if>
|
|
||||||
<if test="description != null ">
|
|
||||||
description,
|
|
||||||
</if>
|
|
||||||
forbidden_tag,
|
|
||||||
<if test="showOrder != null ">
|
|
||||||
show_order,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="creator != null">
|
|
||||||
#{creator},
|
|
||||||
</if>
|
|
||||||
<if test="deleteType != null">
|
|
||||||
#{deleteType},
|
|
||||||
</if>
|
|
||||||
<if test="createTime != null">
|
|
||||||
#{createTime},
|
|
||||||
</if>
|
|
||||||
<if test="updateTime != null">
|
|
||||||
#{updateTime},
|
|
||||||
</if>
|
|
||||||
<if test="compNo != null ">
|
|
||||||
#{compNo},
|
|
||||||
</if>
|
|
||||||
<if test="compName != null ">
|
|
||||||
#{compName},
|
|
||||||
</if>
|
|
||||||
<if test="compNameShort != null ">
|
|
||||||
#{compNameShort},
|
|
||||||
</if>
|
|
||||||
<if test="parentCompany != null ">
|
|
||||||
#{parentCompany},
|
|
||||||
</if>
|
|
||||||
<if test="ecCompany != null ">
|
|
||||||
#{ecCompany},
|
|
||||||
</if>
|
|
||||||
<if test="orgCode != null ">
|
|
||||||
#{orgCode},
|
|
||||||
</if>
|
|
||||||
<if test="industry != null ">
|
|
||||||
#{industry},
|
|
||||||
</if>
|
|
||||||
<if test="compPrincipal != null ">
|
|
||||||
#{compPrincipal},
|
|
||||||
</if>
|
|
||||||
<if test="description != null ">
|
|
||||||
#{description},
|
|
||||||
</if>
|
|
||||||
0,
|
|
||||||
<if test="showOrder != null ">
|
|
||||||
#{showOrder},
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.company.po.CompPO" databaseId="oracle">
|
|
||||||
<selectKey keyProperty="id" resultType="long" order="AFTER">
|
|
||||||
select JCL_ORG_COMP_ID.currval from dual
|
|
||||||
</selectKey>
|
|
||||||
INSERT INTO jcl_org_comp
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="creator != null">
|
|
||||||
creator,
|
|
||||||
</if>
|
|
||||||
<if test="deleteType != null">
|
|
||||||
delete_type,
|
|
||||||
</if>
|
|
||||||
<if test="createTime != null">
|
|
||||||
create_time,
|
|
||||||
</if>
|
|
||||||
<if test="updateTime != null">
|
|
||||||
update_time,
|
|
||||||
</if>
|
|
||||||
<if test="compNo != null ">
|
|
||||||
comp_no,
|
|
||||||
</if>
|
|
||||||
<if test="compName != null ">
|
|
||||||
comp_name,
|
|
||||||
</if>
|
|
||||||
<if test="compNameShort != null ">
|
|
||||||
comp_name_short,
|
|
||||||
</if>
|
|
||||||
<if test="parentCompany != null ">
|
|
||||||
parent_company,
|
|
||||||
</if>
|
|
||||||
<if test="ecCompany != null ">
|
|
||||||
ec_company,
|
|
||||||
</if>
|
|
||||||
<if test="orgCode != null ">
|
|
||||||
org_code,
|
|
||||||
</if>
|
|
||||||
<if test="industry != null ">
|
|
||||||
industry,
|
|
||||||
</if>
|
|
||||||
<if test="compPrincipal != null ">
|
|
||||||
comp_principal,
|
|
||||||
</if>
|
|
||||||
<if test="description != null ">
|
|
||||||
description,
|
|
||||||
</if>
|
|
||||||
forbidden_tag,
|
|
||||||
<if test="showOrder != null ">
|
|
||||||
show_order,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="creator != null">
|
|
||||||
#{creator},
|
|
||||||
</if>
|
|
||||||
<if test="deleteType != null">
|
|
||||||
#{deleteType},
|
|
||||||
</if>
|
|
||||||
<if test="createTime != null">
|
|
||||||
#{createTime},
|
|
||||||
</if>
|
|
||||||
<if test="updateTime != null">
|
|
||||||
#{updateTime},
|
|
||||||
</if>
|
|
||||||
<if test="compNo != null ">
|
|
||||||
#{compNo},
|
|
||||||
</if>
|
|
||||||
<if test="compName != null ">
|
|
||||||
#{compName},
|
|
||||||
</if>
|
|
||||||
<if test="compNameShort != null ">
|
|
||||||
#{compNameShort},
|
|
||||||
</if>
|
|
||||||
<if test="parentCompany != null ">
|
|
||||||
#{parentCompany},
|
|
||||||
</if>
|
|
||||||
<if test="ec_company != null ">
|
|
||||||
#{ecCompany},
|
|
||||||
</if>
|
|
||||||
<if test="orgCode != null ">
|
|
||||||
#{orgCode},
|
|
||||||
</if>
|
|
||||||
<if test="industry != null ">
|
|
||||||
#{industry},
|
|
||||||
</if>
|
|
||||||
<if test="compPrincipal != null ">
|
|
||||||
#{compPrincipal},
|
|
||||||
</if>
|
|
||||||
<if test="description != null ">
|
|
||||||
#{description},
|
|
||||||
</if>
|
|
||||||
0,
|
|
||||||
<if test="showOrder != null ">
|
|
||||||
#{showOrder},
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<select id="list" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0 order by ${orderSql}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listParent" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
<include refid="nullSql"/>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listChild" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
AND parent_company IN
|
|
||||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listById" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
and id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listByNo" parameterType="com.engine.organization.entity.company.po.CompPO" resultMap="BaseResultMap">
|
|
||||||
select
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
from jcl_org_comp t where comp_no = #{compNo} AND delete_type = 0
|
|
||||||
</select>
|
|
||||||
<select id="listByFilter" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
<include refid="likeSQL"/>
|
|
||||||
<if test=" compPO.parentCompany != null ">
|
|
||||||
and t.parent_company = #{compPO.parentCompany}
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.ecCompany != null ">
|
|
||||||
and t.ec_company = #{compPO.ecCompany}
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.industry != null ">
|
|
||||||
and t.industry = #{compPO.industry}
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compPrincipal != null ">
|
|
||||||
and t.comp_principal = #{compPO.compPrincipal}
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.forbiddenTag != null ">
|
|
||||||
and t.forbidden_tag = #{compPO.forbiddenTag}
|
|
||||||
</if>
|
|
||||||
order by ${orderSql}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listCompsByIds" resultType="java.util.Map">
|
|
||||||
select
|
|
||||||
id as "id",
|
|
||||||
comp_name as "name"
|
|
||||||
from jcl_org_comp t
|
|
||||||
WHERE delete_type = 0
|
|
||||||
AND id IN
|
|
||||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listChildByPID" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
and parent_company = #{pid}
|
|
||||||
</select>
|
|
||||||
<select id="countChildByPID" resultType="java.lang.Integer">
|
|
||||||
SELECT count(1)
|
|
||||||
FROM jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
and parent_company = #{pid}
|
|
||||||
</select>
|
|
||||||
<select id="getCompsByIds" resultMap="BaseResultMap">
|
|
||||||
select
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
from jcl_org_comp t
|
|
||||||
WHERE delete_type = 0
|
|
||||||
AND id IN
|
|
||||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
<select id="listUsedId" resultType="java.lang.String">
|
|
||||||
select parent_comp
|
|
||||||
from JCL_ORG_DEPT
|
|
||||||
where delete_type = 0
|
|
||||||
union
|
|
||||||
select parent_comp
|
|
||||||
from JCL_ORG_JOB
|
|
||||||
where delete_type = 0
|
|
||||||
union
|
|
||||||
select comp_id
|
|
||||||
from JCL_ORG_STAFF
|
|
||||||
where delete_type = 0
|
|
||||||
</select>
|
|
||||||
<select id="getMaxShowOrder" resultType="java.lang.Integer">
|
|
||||||
select max(show_order)
|
|
||||||
from jcl_org_comp
|
|
||||||
</select>
|
|
||||||
<select id="getIdByNameAndPid" resultType="java.lang.Long">
|
|
||||||
select id
|
|
||||||
from jcl_org_comp
|
|
||||||
where delete_type = 0 and comp_name = #{companyName}
|
|
||||||
<include refid="nullParentCompany"/>
|
|
||||||
</select>
|
|
||||||
<select id="countTopCompany" resultType="java.lang.Integer">
|
|
||||||
select COUNT(id) from jcl_org_comp where 1=1
|
|
||||||
<include refid="nullParentCompany"/>
|
|
||||||
</select>
|
|
||||||
<select id="listUsedIds" resultType="java.lang.String">
|
|
||||||
select company_id
|
|
||||||
from JCL_ORG_STAFFPLAN
|
|
||||||
where delete_type = 0
|
|
||||||
union
|
|
||||||
select jcl_rolelevel
|
|
||||||
from jcl_org_detach
|
|
||||||
where delete_type = 0
|
|
||||||
</select>
|
|
||||||
<select id="getCompanyByUUID" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
FROM
|
|
||||||
jcl_org_comp t
|
|
||||||
WHERE t.delete_type = 0
|
|
||||||
and uuid = #{uuid}
|
|
||||||
</select>
|
|
||||||
<select id="checkRepeatNo" resultType="java.lang.Integer">
|
|
||||||
select count(1)
|
|
||||||
from jcl_org_comp t
|
|
||||||
where t.delete_type = 0
|
|
||||||
AND comp_no = #{companyNo}
|
|
||||||
<if test=" id != null ">
|
|
||||||
and t.id != #{id}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
<select id="getCompanyByNo" resultMap="BaseResultMap">
|
|
||||||
select
|
|
||||||
<include refid="baseColumns"/>
|
|
||||||
from from jcl_org_comp t
|
|
||||||
where t.delete_type = 0
|
|
||||||
AND comp_no = #{companyNo}
|
|
||||||
</select>
|
|
||||||
<select id="hasSubs" resultType="java.lang.String">
|
|
||||||
select parent_company
|
|
||||||
from jcl_org_comp
|
|
||||||
where forbidden_tag = 0
|
|
||||||
and delete_type = 0
|
|
||||||
union
|
|
||||||
select parent_comp
|
|
||||||
from jcl_org_dept
|
|
||||||
where forbidden_tag = 0
|
|
||||||
and delete_type = 0
|
|
||||||
</select>
|
|
||||||
<select id="getCompanyIdsByUuid" resultType="java.lang.Long">
|
|
||||||
select id from jcl_org_comp
|
|
||||||
where delete_type = 0 and uuid in
|
|
||||||
<foreach collection="uuids" open="(" item="uuid" separator="," close=")">
|
|
||||||
#{uuid}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
<select id="hasDetachSubs" resultType="java.lang.String">
|
|
||||||
select parent_company
|
|
||||||
from jcl_org_comp
|
|
||||||
where forbidden_tag = 0
|
|
||||||
and delete_type = 0
|
|
||||||
and id in
|
|
||||||
<foreach collection="companyIds" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
union
|
|
||||||
select parent_comp
|
|
||||||
from jcl_org_dept
|
|
||||||
where forbidden_tag = 0
|
|
||||||
and delete_type = 0
|
|
||||||
and parent_comp in
|
|
||||||
<foreach collection="companyIds" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
|
|
||||||
update jcl_org_comp
|
|
||||||
<set>
|
|
||||||
forbidden_tag=#{forbiddenTag},
|
|
||||||
</set>
|
|
||||||
WHERE id = #{id} AND delete_type = 0
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="deleteByIds">
|
|
||||||
UPDATE jcl_org_comp
|
|
||||||
SET delete_type = 1
|
|
||||||
WHERE delete_type = 0
|
|
||||||
AND id IN
|
|
||||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="updateBaseComp" parameterType="com.engine.organization.entity.company.po.CompPO">
|
|
||||||
update jcl_org_comp
|
|
||||||
<set>
|
|
||||||
creator=#{creator},
|
|
||||||
update_time=#{updateTime},
|
|
||||||
comp_name=#{compName},
|
|
||||||
comp_name_short=#{compNameShort},
|
|
||||||
parent_company=#{parentCompany},
|
|
||||||
ec_company=#{ecCompany},
|
|
||||||
org_code=#{orgCode},
|
|
||||||
industry=#{industry},
|
|
||||||
comp_principal=#{compPrincipal},
|
|
||||||
description=#{description},
|
|
||||||
show_order=#{showOrder},
|
|
||||||
</set>
|
|
||||||
WHERE id = #{id} AND delete_type = 0
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<sql id="likeSQL">
|
|
||||||
<if test=" compPO.compNo != null and compPO.compNo != '' ">
|
|
||||||
and t.comp_no like CONCAT('%',#{compPO.compNo},'%')
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compName != null and compPO.compName != '' ">
|
|
||||||
and t.comp_name like CONCAT('%',#{compPO.compName},'%')
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compNameShort != null and compPO.compNameShort != '' ">
|
|
||||||
and t.comp_name_short like CONCAT('%',#{compPO.compNameShort},'%')
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.orgCode != null and compPO.orgCode != '' ">
|
|
||||||
and t.org_code like CONCAT('%',#{compPO.orgCode},'%')
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="likeSQL" databaseId="oracle">
|
|
||||||
<if test=" compPO.compNo != null and compPO.compNo != '' ">
|
|
||||||
and t.comp_no like '%'||#{compPO.compNo}||'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compName != null and compPO.compName != '' ">
|
|
||||||
and t.comp_name like '%'||#{compPO.compName}||'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compNameShort != null and compPO.compNameShort != '' ">
|
|
||||||
and t.comp_name_short like '%'||#{compPO.compNameShort}||'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.orgCode != null and compPO.orgCode != '' ">
|
|
||||||
and t.org_code like '%'||#{compPO.orgCode}||'%'
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<sql id="likeSQL" databaseId="sqlserver">
|
|
||||||
<if test=" compPO.compNo != null and compPO.compNo != '' ">
|
|
||||||
and t.comp_no like '%'+#{compPO.compNo}+'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compName != null and compPO.compName != '' ">
|
|
||||||
and t.comp_name like '%'+#{compPO.compName}+'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.compNameShort != null and compPO.compNameShort != '' ">
|
|
||||||
and t.comp_name_short like '%'+#{compPO.compNameShort}+'%'
|
|
||||||
</if>
|
|
||||||
<if test=" compPO.orgCode != null and compPO.orgCode != '' ">
|
|
||||||
and t.org_code like '%'+#{compPO.orgCode}+'%'
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
</mapper>
|
|
@ -1,159 +1,140 @@
|
|||||||
package com.engine.organization.thread;
|
package com.engine.organization.thread;
|
||||||
|
|
||||||
import com.engine.organization.entity.company.po.CompPO;
|
|
||||||
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
|
|
||||||
import com.engine.organization.entity.job.po.JobPO;
|
|
||||||
import com.engine.organization.entity.map.JclOrgMap;
|
|
||||||
import com.engine.organization.entity.personnelcard.UserCard;
|
|
||||||
import com.engine.organization.entity.staff.po.StaffPO;
|
|
||||||
import com.engine.organization.enums.ModuleTypeEnum;
|
|
||||||
import com.engine.organization.mapper.comp.CompMapper;
|
|
||||||
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
|
||||||
import com.engine.organization.mapper.job.JobMapper;
|
|
||||||
import com.engine.organization.mapper.staff.StaffMapper;
|
|
||||||
import com.engine.organization.mapper.trigger.CompTriggerMapper;
|
|
||||||
import com.engine.organization.util.OrganizationDateUtil;
|
|
||||||
import com.engine.organization.util.db.MapperProxyFactory;
|
|
||||||
import weaver.common.DateUtil;
|
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author:dxfeng
|
* @author:dxfeng
|
||||||
* @createTime: 2022/08/30
|
* @createTime: 2022/08/30
|
||||||
* @version: 1.0
|
* @version: 1.0
|
||||||
*/
|
*/
|
||||||
public class CompanyTriggerRunnable implements Runnable {
|
//public class CompanyTriggerRunnable implements Runnable {
|
||||||
|
//
|
||||||
private final CompPO oldCompany;
|
// private final CompPO oldCompany;
|
||||||
private final CompPO newCompany;
|
// private final CompPO newCompany;
|
||||||
|
//
|
||||||
private CompTriggerMapper getCompTriggerMapper() {
|
// private CompTriggerMapper getCompTriggerMapper() {
|
||||||
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
|
// return MapperProxyFactory.getProxy(CompTriggerMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public CompanyTriggerRunnable(CompPO oldCompany, CompPO newCompany) {
|
// public CompanyTriggerRunnable(CompPO oldCompany, CompPO newCompany) {
|
||||||
this.oldCompany = oldCompany;
|
// this.oldCompany = oldCompany;
|
||||||
this.newCompany = newCompany;
|
// this.newCompany = newCompany;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public CompanyTriggerRunnable(Long companyId) {
|
// public CompanyTriggerRunnable(Long companyId) {
|
||||||
this.oldCompany = new CompPO();
|
// this.oldCompany = new CompPO();
|
||||||
this.newCompany = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId);
|
// this.newCompany = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public CompanyTriggerRunnable(CompPO newCompany) {
|
// public CompanyTriggerRunnable(CompPO newCompany) {
|
||||||
this.oldCompany = new CompPO();
|
// this.oldCompany = new CompPO();
|
||||||
this.newCompany = newCompany;
|
// this.newCompany = newCompany;
|
||||||
this.newCompany.setDeleteType(1);
|
// this.newCompany.setDeleteType(1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
// 判断
|
// // 判断
|
||||||
JclOrgMap jclMap = new JclOrgMap();
|
// JclOrgMap jclMap = new JclOrgMap();
|
||||||
|
//
|
||||||
jclMap.setFType(1);
|
// jclMap.setFType(1);
|
||||||
// 更新逻辑
|
// // 更新逻辑
|
||||||
jclMap.setFObjId(newCompany.getId().intValue());
|
// jclMap.setFObjId(newCompany.getId().intValue());
|
||||||
jclMap.setId(newCompany.getId().intValue());
|
// jclMap.setId(newCompany.getId().intValue());
|
||||||
jclMap.setUuid(newCompany.getUuid());
|
// jclMap.setUuid(newCompany.getUuid());
|
||||||
jclMap.setFNumber(newCompany.getCompNo());
|
// jclMap.setFNumber(newCompany.getCompNo());
|
||||||
jclMap.setFName(newCompany.getCompName());
|
// jclMap.setFName(newCompany.getCompName());
|
||||||
jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
// jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
||||||
jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
// jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
||||||
jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid()));
|
// jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid()));
|
||||||
|
//
|
||||||
|
//
|
||||||
jclMap.setFClass(0);
|
// jclMap.setFClass(0);
|
||||||
jclMap.setFClassName("行政维度");
|
// jclMap.setFClassName("行政维度");
|
||||||
|
//
|
||||||
Integer ecResourceId = newCompany.getCompPrincipal();
|
// Integer ecResourceId = newCompany.getCompPrincipal();
|
||||||
HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId);
|
// HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId);
|
||||||
if (null != hrmResourcePO) {
|
// if (null != hrmResourcePO) {
|
||||||
jclMap.setFLeader(hrmResourcePO.getId().intValue());
|
// jclMap.setFLeader(hrmResourcePO.getId().intValue());
|
||||||
jclMap.setFLeaderName(hrmResourcePO.getLastName());
|
// jclMap.setFLeaderName(hrmResourcePO.getLastName());
|
||||||
jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue());
|
// jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue());
|
||||||
jclMap.setFLeaderSt(hrmResourcePO.getJobGrade());
|
// jclMap.setFLeaderSt(hrmResourcePO.getJobGrade());
|
||||||
jclMap.setFLeaderLv(hrmResourcePO.getJobLevel());
|
// jclMap.setFLeaderLv(hrmResourcePO.getJobLevel());
|
||||||
String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage();
|
// String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage();
|
||||||
jclMap.setFLeaderImg(image);
|
// jclMap.setFLeaderImg(image);
|
||||||
if (null != hrmResourcePO.getJobTitle()) {
|
// if (null != hrmResourcePO.getJobTitle()) {
|
||||||
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle());
|
// JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle());
|
||||||
if (null != jobById) {
|
// if (null != jobById) {
|
||||||
jclMap.setFLeaderJob(jobById.getJobName());
|
// jclMap.setFLeaderJob(jobById.getJobName());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
||||||
jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
// jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
||||||
jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
// jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
||||||
|
//
|
||||||
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(jclMap.getFType(), jclMap.getFObjId().toString(), null, null);
|
// StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(jclMap.getFType(), jclMap.getFObjId().toString(), null, null);
|
||||||
JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString());
|
// JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString());
|
||||||
if (null != jclOrgMapByObjID) {
|
// if (null != jclOrgMapByObjID) {
|
||||||
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
// jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
||||||
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
// jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
||||||
} else {
|
// } else {
|
||||||
jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
||||||
jclMap.setFOnJob(0);
|
// jclMap.setFOnJob(0);
|
||||||
}
|
// }
|
||||||
jclMap.setFIsVitual(0);
|
// jclMap.setFIsVitual(0);
|
||||||
|
//
|
||||||
Calendar cal = Calendar.getInstance();
|
// Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(jclMap.getFDateBegin());
|
// cal.setTime(jclMap.getFDateBegin());
|
||||||
Calendar calendar = DateUtil.addDay(cal, -1);
|
// Calendar calendar = DateUtil.addDay(cal, -1);
|
||||||
Date time = new Date(calendar.getTime().getTime());
|
// Date time = new Date(calendar.getTime().getTime());
|
||||||
getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin());
|
// getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin());
|
||||||
getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time);
|
// getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time);
|
||||||
|
//
|
||||||
if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
|
// if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
|
||||||
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
||||||
}
|
// }
|
||||||
if (null != jclOrgMapByObjID) {
|
// if (null != jclOrgMapByObjID) {
|
||||||
if (null != jclOrgMapByObjID.getFParentId()) {
|
// if (null != jclOrgMapByObjID.getFParentId()) {
|
||||||
updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString());
|
// updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (null != oldCompany) {
|
// if (null != oldCompany) {
|
||||||
if (null != oldCompany.getId()) {
|
// if (null != oldCompany.getId()) {
|
||||||
updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString());
|
// updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 更新上级部门在编、在岗数
|
// * 更新上级部门在编、在岗数
|
||||||
*/
|
// */
|
||||||
void updateParentPlanAndJob(Date currentDate, String parentId) {
|
// void updateParentPlanAndJob(Date currentDate, String parentId) {
|
||||||
JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId);
|
// JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId);
|
||||||
if (null != parentJclOrgMap) {
|
// if (null != parentJclOrgMap) {
|
||||||
// 上级部门当前在编、在岗数
|
// // 上级部门当前在编、在岗数
|
||||||
JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString());
|
// JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString());
|
||||||
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(), parentId, null, null);
|
// StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(), parentId, null, null);
|
||||||
if (null != jclOrgMapSum) {
|
// if (null != jclOrgMapSum) {
|
||||||
parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan());
|
// parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan());
|
||||||
parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
// parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
||||||
} else {
|
// } else {
|
||||||
parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
// parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
||||||
parentJclOrgMap.setFOnJob(0);
|
// parentJclOrgMap.setFOnJob(0);
|
||||||
}
|
// }
|
||||||
parentJclOrgMap.setFDateBegin(currentDate);
|
// parentJclOrgMap.setFDateBegin(currentDate);
|
||||||
parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
// parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
||||||
|
//
|
||||||
Calendar cal = Calendar.getInstance();
|
// Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(parentJclOrgMap.getFDateBegin());
|
// cal.setTime(parentJclOrgMap.getFDateBegin());
|
||||||
Calendar calendar = DateUtil.addDay(cal, -1);
|
// Calendar calendar = DateUtil.addDay(cal, -1);
|
||||||
Date time = new Date(calendar.getTime().getTime());
|
// Date time = new Date(calendar.getTime().getTime());
|
||||||
getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin());
|
// getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin());
|
||||||
getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time);
|
// getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time);
|
||||||
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap);
|
// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap);
|
||||||
if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) {
|
// if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) {
|
||||||
updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString());
|
// updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
Loading…
Reference in New Issue