diff --git a/README.md b/README.md index b50051f8..2ae76c1a 100644 --- a/README.md +++ b/README.md @@ -3,35 +3,16 @@ #### 介绍 聚才林组织模块代码 -#### 软件架构 -软件架构说明 +#### 版本1.0 已封版 +该版本组织分为2套数据 采用单向同步的方式 -#### 安装教程 +#### 功能介绍 -1. xxxx -2. xxxx -3. xxxx +组织架构图 +组织分权 +人员卡片等自定义功能 -#### 使用说明 -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +#### 迭代计划 +由于当前版本两套数据不好管理 下版计划将数据源统一换成ecology数据源 \ No newline at end of file diff --git a/docs/表结构SQL/MySQL.sql b/docs/表结构SQL/MySQL.sql index 0895cbd4..a205b5e3 100644 --- a/docs/表结构SQL/MySQL.sql +++ b/docs/表结构SQL/MySQL.sql @@ -593,4 +593,17 @@ create table JCL_ORG_CARDBUTTON ( create_time date null, update_time date null, constraint JCL_ORG_CARDBUTTON_PK primary key (id) +); + + +--v2.0新增表 + +-- JCl_ORG_RESOURCEEXTEND //id是人员ID 非自增 +create table JCl_ORG_RESOURCEEXTEND ( + id int not null, + scheme int null, + level_id int null, + grade int null, + sequence int null, + constraint JCl_ORG_RESOURCEEXTEND_PK primary key (id) ); \ No newline at end of file diff --git a/interface/InitStaffPermanentNum.jsp b/interface/InitStaffPermanentNum.jsp new file mode 100644 index 00000000..fcd3240d --- /dev/null +++ b/interface/InitStaffPermanentNum.jsp @@ -0,0 +1,61 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="com.engine.organization.entity.staff.po.StaffPO" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="com.engine.organization.entity.job.po.JobPO" %> +<%@ page import="com.engine.organization.util.db.MapperProxyFactory" %> +<%@ page import="com.engine.organization.mapper.job.JobMapper" %> +<%@ page import="com.engine.organization.entity.staff.bo.StaffBO" %> +<%@ page import="com.engine.organization.mapper.staff.StaffMapper" %> +<%@ page contentType="text/html; charset=UTF-8" %> +<% + + RecordSet rs = new RecordSet(); + List staffPOList = new ArrayList<>(); + String sql = "select * from jcl_org_staff where permanent_num = 0 and is_used = 0 and delete_type = 0"; + rs.executeQuery(sql); + while (rs.next()) { + StaffPO staffPO = new StaffPO(); + staffPO.setId(-1 == rs.getInt("id") ? 0L : (long) rs.getInt("id")); + staffPO.setPlanId(-1 == rs.getInt("plan_id") ? 0L : (long) rs.getInt("plan_id")); + staffPO.setCompId(-1 == rs.getInt("comp_id") ? 0 : rs.getInt("comp_id")); + staffPO.setEcCompany(-1 == rs.getInt("ec_company") ? 0 : rs.getInt("ec_company")); + staffPO.setDeptId(-1 == rs.getInt("dept_id") ? 0 : rs.getInt("dept_id")); + staffPO.setEcDepartment(-1 == rs.getInt("ec_department") ? 0 : rs.getInt("ec_department")); + staffPO.setJobId(-1 == rs.getInt("job_id") ? 0L : (long) rs.getInt("job_id")); + staffPO.setStaffNum(-1 == rs.getInt("staff_num") ? 0 : rs.getInt("staff_num")); + staffPO.setControlPolicy(-1 == rs.getInt("control_policy") ? 0 : rs.getInt("control_policy")); + staffPO.setPermanentNum(-1 == rs.getInt("permanent_num") ? 0 : rs.getInt("permanent_num")); + staffPO.setFreezeNum(-1 == rs.getInt("freeze_num") ? 0 : rs.getInt("freeze_num")); + staffPO.setDescription(rs.getString("description")); + staffPO.setCreator((long) rs.getInt("creator")); staffPO.setCreator((long) rs.getInt("creator")); + staffPOList.add(staffPO); + } + + for (StaffPO staffPO : staffPOList) { + sql = "select count(1) as num from hrmresource where STATUS < 4"; + if (null != staffPO.getEcCompany() && 0 != staffPO.getEcCompany()) { + sql += " and subcompanyid1 = " + staffPO.getEcCompany(); + } + if (null != staffPO.getEcDepartment() && 0 != staffPO.getEcDepartment()) { + sql += " and departmentid = " + staffPO.getEcDepartment(); + } + if (null != staffPO.getJobId() && 0 != staffPO.getJobId()) { + JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(staffPO.getJobId()); + if (null == jobById) { + continue; + } + Integer ecJobTitle = jobById.getEcJobTitle(); + sql += " and jobtitle = " + ecJobTitle; + } + rs.executeQuery(sql); + if (rs.next()) { + staffPO.setPermanentNum(-1 == rs.getInt("num") ? 0 : rs.getInt("num")); + StaffBO.buildStaffDesc(staffPO); + MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO); + } + } + + + out.println("在编数初始化完成"); +%> \ No newline at end of file diff --git a/src/com/api/browser/service/impl/JobBrowserService.java b/src/com/api/browser/service/impl/JobBrowserService.java index 0eea6cbd..a5f7e59a 100644 --- a/src/com/api/browser/service/impl/JobBrowserService.java +++ b/src/com/api/browser/service/impl/JobBrowserService.java @@ -26,6 +26,8 @@ import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; import weaver.general.Util; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.*; import java.util.stream.Collectors; @@ -70,6 +72,45 @@ public class JobBrowserService extends BrowserService { return resultMap; } + @Override + public Map browserAutoComplete(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { + Map apidatas = new HashMap<>(); + String q = Util.null2String(httpServletRequest.getParameter("q")); + List sqlParams = new ArrayList<>(); + String keyword = ""; + if (q.length() > 0) keyword = "%" + q + "%"; + RecordSet rs = new RecordSet(); + String sqlwhere = " where t.delete_type = 0 "; + String backfields = "t.id, t.job_no, h.jobtitlename as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id "; + String fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.id "; + String orderby = " order by t.id "; + sqlwhere += " "; + DetachUtil detachUtil = new DetachUtil(user); + if (detachUtil.isDETACH()) { + sqlwhere += " AND t.ec_company in (" + detachUtil.getJclRoleLevels() + ")"; + } + if (!"".equals(keyword)) { + sqlwhere += " and (h.jobtitlemark like ? or h.jobtitlename like ? or h.ecology_pinyin_search like ? )"; + sqlParams.add(keyword); + sqlParams.add(keyword); + sqlParams.add(keyword); + } + String sql = "select " + backfields + fromSql + sqlwhere + orderby; + rs.executeQuery(sql, sqlParams); + List> datas = new ArrayList<>(); + while (rs.next()) { + Map item = new HashMap<>(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("name")); + item.put("name", name); + item.put("title", name); + datas.add(item); + } + apidatas.put("datas", datas); + return apidatas; + } + + @Override public Map getBrowserConditionInfo(Map map) { Map> apiDatas = new HashMap<>(); @@ -99,14 +140,14 @@ public class JobBrowserService extends BrowserService { */ private String buildSqlWhere(Map params) { DBType dbType = DBType.get(new RecordSet().getDBType()); - String sqlWhere = " where t.delete_type ='0' and forbidden_tag ='0' "; + String sqlWhere = " where t.delete_type = 0 "; String jobNo = Util.null2String(params.get("jobNo")); if (StringUtils.isNotBlank(jobNo)) { sqlWhere += " AND t.job_no " + dbType.like(jobNo); } String jobName = Util.null2String(params.get("jobName")); if (StringUtils.isNotBlank(jobName)) { - sqlWhere += " AND t.job_name " + dbType.like(jobName); + sqlWhere += " AND h.jobtitlename " + dbType.like(jobName); } String ecCompany = Util.null2String(params.get("ecCompany")); if (StringUtils.isNotBlank(ecCompany)) { @@ -121,16 +162,16 @@ public class JobBrowserService extends BrowserService { String[] keyArray = treeKey.split("_"); if (keyArray.length == 2) { if (TreeNodeTypeEnum.TYPE_COMP.getName().equals(keyArray[0])) { - sqlWhere += " AND t.parent_comp = '" + Long.parseLong(keyArray[1]) + "'"; + sqlWhere += " AND t.ec_company = '" + Long.parseLong(keyArray[1]) + "'"; } else if (TreeNodeTypeEnum.TYPE_DEPT.getName().equals(keyArray[0])) { - sqlWhere += " AND t.parent_dept = '" + Long.parseLong(keyArray[1]) + "'"; + sqlWhere += " AND t.ec_department = '" + Long.parseLong(keyArray[1]) + "'"; } } } // 分权 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { - sqlWhere += " AND t.parent_comp in (" + detachUtil.getJclRoleLevels() + ")"; + sqlWhere += " AND t.ec_company in (" + detachUtil.getJclRoleLevels() + ")"; } return sqlWhere; } @@ -143,7 +184,7 @@ public class JobBrowserService extends BrowserService { */ private List getCurrentTreeNode(SearchTreeParams params) { // 分权 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); List jclRoleLevelList; if (StringUtils.isNotBlank(detachUtil.getJclRoleLevels())) { jclRoleLevelList = Arrays.stream(detachUtil.getJclRoleLevels().split(",")).map(Long::parseLong).collect(Collectors.toList()); @@ -181,8 +222,8 @@ public class JobBrowserService extends BrowserService { if (CollectionUtils.isNotEmpty(jclRoleLevelList)) { compList = MapperProxyFactory.getProxy(CompMapper.class).getCompsByIds(jclRoleLevelList); // 处理上下级关系 - Set collectIds = compList.stream().map(CompPO::getId).collect(Collectors.toSet()); - compList.removeIf(item->collectIds.contains(item.getParentCompany())); + Set collectIds = compList.stream().map(CompPO::getId).collect(Collectors.toSet()); + compList.removeIf(item -> collectIds.contains(item.getSupSubComId())); } else { compList = new ArrayList<>(); @@ -191,22 +232,22 @@ public class JobBrowserService extends BrowserService { compList = MapperProxyFactory.getProxy(CompMapper.class).listParent(); } // 获取顶层分部 - compList.stream().sorted(Comparator.comparing(CompPO::getShowOrder)).forEach(item -> buildCompNodes(treeNodes, compHasSubs, item)); + compList.stream().sorted(Comparator.comparing(item -> null == item.getShowOrder() ? 0 : item.getShowOrder())).forEach(item -> buildCompNodes(treeNodes, compHasSubs, item)); } else if ("1".equals(params.getType())) { // 当前节点下的元素 - CompPO compBuild = CompPO.builder().parentCompany(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build(); - List compList = MapperProxyFactory.getProxy(CompMapper.class).listByFilter(compBuild, "show_order"); + CompPO compBuild = CompPO.builder().supSubComId(Integer.parseInt(params.getId())).canceled(0).build(); + List compList = MapperProxyFactory.getProxy(CompMapper.class).listByFilter(compBuild, "showorder"); if (detachUtil.isDETACH()) { detachUtil.filterCompanyList(compList); } - DepartmentPO departmentBuild = DepartmentPO.builder().parentComp(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build(); - List departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order"); + DepartmentPO departmentBuild = DepartmentPO.builder().subCompanyId1(Integer.parseInt(params.getId())).canceled(0).build(); + List departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "showorder"); compList.forEach(item -> buildCompNodes(treeNodes, compHasSubs, item)); - departmentList.stream().filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item)); + departmentList.stream().filter(item -> null == item.getSupDepId() || 0 == item.getSupDepId()).forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item)); } else if ("2".equals(params.getType())) { - DepartmentPO departmentBuild = DepartmentPO.builder().parentDept(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build(); - List departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order"); + DepartmentPO departmentBuild = DepartmentPO.builder().supDepId(Integer.parseInt(params.getId())).canceled(0).build(); + List departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "showorder"); departmentList.forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item)); } @@ -226,7 +267,7 @@ public class JobBrowserService extends BrowserService { SearchTree searchTree = new SearchTree(); searchTree.setId(company.getId().toString()); searchTree.setType(TreeNodeTypeEnum.TYPE_COMP.getValue()); - searchTree.setName(company.getCompName()); + searchTree.setName(company.getSubCompanyName()); searchTree.setIsParent(compHasSubs.contains(company.getId().toString())); treeNodes.add(searchTree); } @@ -241,7 +282,7 @@ public class JobBrowserService extends BrowserService { private void buildDeptNodes(List treeNodes, List hasSubDepartment, DepartmentPO department) { SearchTree searchTree = new SearchTree(); searchTree.setId(department.getId().toString()); - searchTree.setName(department.getDeptName()); + searchTree.setName(department.getDepartmentName()); searchTree.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue()); searchTree.setIsParent(hasSubDepartment.contains(department.getId().toString())); treeNodes.add(searchTree); diff --git a/src/com/api/organization/web/OrgChartController.java b/src/com/api/organization/web/OrgChartController.java index eb1742da..6ff5877e 100644 --- a/src/com/api/organization/web/OrgChartController.java +++ b/src/com/api/organization/web/OrgChartController.java @@ -2,12 +2,7 @@ package com.api.organization.web; import javax.ws.rs.Path; -/** - * @className: OrgChartController - * @author: dengjp - * @date: 2022/7/7 - * @description: 组织架构图 - **/ + @Path("/bs/hrmorganization/orgchart") public class OrgChartController extends com.engine.organization.web.OrgChartController { } diff --git a/src/com/api/organization/web/OrgVirtualController.java b/src/com/api/organization/web/OrgVirtualController.java new file mode 100644 index 00000000..1af5c00e --- /dev/null +++ b/src/com/api/organization/web/OrgVirtualController.java @@ -0,0 +1,14 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * @Author liang.cheng + * @Date 2023/6/27 3:38 PM + * @Description: TODO + * @Version 1.0 + */ + +@Path("/bs/hrmorganization/virtual") +public class OrgVirtualController extends com.engine.organization.web.OrgVirtualController { +} diff --git a/src/com/api/organization/web/PersonnelResumeController.java b/src/com/api/organization/web/PersonnelResumeController.java new file mode 100644 index 00000000..0f1a1415 --- /dev/null +++ b/src/com/api/organization/web/PersonnelResumeController.java @@ -0,0 +1,12 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +@Path("/bs/hrmorganization/personnelresume") +public class PersonnelResumeController extends com.engine.organization.web.PersonnelResumeController { +} diff --git a/src/com/api/organization/web/VersionManageController.java b/src/com/api/organization/web/VersionManageController.java new file mode 100644 index 00000000..1529afe9 --- /dev/null +++ b/src/com/api/organization/web/VersionManageController.java @@ -0,0 +1,13 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/8 + * @Version V1.0 + **/ +@Path("/bs/hrmorganization/version") +public class VersionManageController extends com.engine.organization.web.VersionManageController { +} diff --git a/src/com/engine/organization/entity/DeleteParam.java b/src/com/engine/organization/entity/DeleteParam.java index 724745d0..6583844b 100644 --- a/src/com/engine/organization/entity/DeleteParam.java +++ b/src/com/engine/organization/entity/DeleteParam.java @@ -8,7 +8,7 @@ import weaver.general.StringUtil; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; +import java.util.List; import java.util.stream.Collectors; /** @@ -24,7 +24,7 @@ import java.util.stream.Collectors; public class DeleteParam { private String ids; - public Collection getIds() { + public List getIds() { if(StringUtil.isEmpty(ids)){ return new ArrayList<>(); } diff --git a/src/com/engine/organization/entity/browser/po/CustomBrowserBean.java b/src/com/engine/organization/entity/browser/po/CustomBrowserBean.java index 7885d1de..b34ac32d 100644 --- a/src/com/engine/organization/entity/browser/po/CustomBrowserBean.java +++ b/src/com/engine/organization/entity/browser/po/CustomBrowserBean.java @@ -1,10 +1,7 @@ package com.engine.organization.entity.browser.po; import com.api.browser.bean.BrowserBean; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.Map; @@ -17,6 +14,7 @@ import java.util.Map; @Builder @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode(callSuper=false) public class CustomBrowserBean extends BrowserBean { diff --git a/src/com/engine/organization/entity/chart/CompanyTreePO.java b/src/com/engine/organization/entity/chart/CompanyTreePO.java new file mode 100644 index 00000000..6e959f9e --- /dev/null +++ b/src/com/engine/organization/entity/chart/CompanyTreePO.java @@ -0,0 +1,39 @@ +package com.engine.organization.entity.chart; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.conn.RecordSet; + +/** + * @author:dxfeng + * @createTime: 2023/06/26 + * @version: 1.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class CompanyTreePO { + private String id; + private String pId; + private String value; + private String title; + private boolean isLeaf; + private String key; + + public boolean getIsLeaf() { + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?",id); + return !rs.next(); + } + + public String getpId() { + return pId; + } + + public String getKey() { + return id; + } +} diff --git a/src/com/engine/organization/entity/codesetting/bo/CodeSettingBO.java b/src/com/engine/organization/entity/codesetting/bo/CodeSettingBO.java index eb170cb8..26c5eb66 100644 --- a/src/com/engine/organization/entity/codesetting/bo/CodeSettingBO.java +++ b/src/com/engine/organization/entity/codesetting/bo/CodeSettingBO.java @@ -73,7 +73,7 @@ public class CodeSettingBO { if(Objects.nonNull(param)) { String enable = Util.null2String(param.getEnable(),"0"); String key = param.getKey(); - if (enable.equals("1") && StringUtils.isNotEmpty(key)) { + if ("1".equals(enable) && StringUtils.isNotEmpty(key)) { sb.append(key); sb.append(","); } diff --git a/src/com/engine/organization/entity/commom/FieldInfo.java b/src/com/engine/organization/entity/commom/FieldInfo.java index 481e4cd6..99c76d41 100644 --- a/src/com/engine/organization/entity/commom/FieldInfo.java +++ b/src/com/engine/organization/entity/commom/FieldInfo.java @@ -96,8 +96,12 @@ public class FieldInfo { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } FieldInfo fieldInfo = (FieldInfo) o; return Objects.equals(fieldName, fieldInfo.fieldName) && Objects.equals(firstFieldType, fieldInfo.firstFieldType) && diff --git a/src/com/engine/organization/entity/company/bo/CompBO.java b/src/com/engine/organization/entity/company/bo/CompBO.java index d26b8bd9..9281b193 100644 --- a/src/com/engine/organization/entity/company/bo/CompBO.java +++ b/src/com/engine/organization/entity/company/bo/CompBO.java @@ -1,54 +1,121 @@ 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.param.CompParam; 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 + * @createTime: 2022/11/24 * @version: 1.0 */ public class CompBO { - public static List buildCompDTOList(Collection list) { + private static CompMapper getCompMapper() { + return MapperProxyFactory.getProxy(CompMapper.class); + } - Map poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item)); + public static List buildSetToSearchTree(Set comps) { + return comps.stream().sorted(Comparator.comparing(item -> null == item.getShowOrder() ? 0 : item.getShowOrder())).map(item -> { + SearchTree tree = new SearchTree(); + tree.setCanClick(true); + tree.setCanceled(item.getCanceled() != null && item.getCanceled() != 0); + tree.setIcon("icon-coms-LargeArea"); + tree.setId(item.getId().toString()); + tree.setIsParent(false); + tree.setIsVirtual("0"); + tree.setName(item.getSubCompanyName()); + tree.setPid(item.getSupSubComId().toString()); + tree.setSelected(false); + tree.setType("1"); + tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder()); + return tree; + }).collect(Collectors.toList()); + } + + /** + * 搜索条件转换实体对象 + * + * @param param + * @param userId + * @return + */ + public static CompPO convertParamToPO(CompParam param, Integer userId) { + if (null == param) { + return null; + } + return CompPO + .builder() + .id(param.getId() == null ? 0 : param.getId()) + .subCompanyName(param.getSubCompanyName()) + .subCompanyDesc(param.getSubCompanyDesc()) + // 所属集团默认为1 + .companyId(null == param.getCompanyId() ? 1 : param.getCompanyId()) + .supSubComId(param.getSupSubComId()) + .url(param.getUrl()) + .canceled(param.getCanceled() == null ? null : param.getCanceled() ? 0 : 1) + .subCompanyCode(param.getSubCompanyCode()) + .outKey(param.getOutKey()) + .limitUsers(null == param.getLimitUsers() ? 0 : param.getLimitUsers()) + .uuid(param.getUuid()) + .showOrder(param.getShowOrder()) + .showOrderOfTree(param.getShowOrderOfTree()) + .created(new Date()) + .creater(userId) + .modified(new Date()) + .modifier(userId) + .build(); + } + + public static List buildCompDTOList(Collection list, List filterList) { + // 搜索结果为空,直接返回空 + if (CollectionUtils.isEmpty(filterList)) { + return Collections.emptyList(); + } + // 递归添加父级数据 + Map poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item)); + List addedList = new ArrayList<>(); + for (CompPO po : filterList) { + dealParentData(addedList, po, poMaps); + } + + return buildCompDTOList(addedList); + } + + public static List buildCompDTOList(List list) { + + Map poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item)); List 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()))) + .subCompanyCode(e.getSubCompanyCode()) + .subCompanyDesc(e.getSubCompanyDesc()) + .subCompanyName(e.getSubCompanyName()) + .supSubComId(e.getSupSubComId()) + .supSubComName(null == poMaps.get(e.getSupSubComId()) ? "" : poMaps.get(e.getSupSubComId()).getSubCompanyName()) .showOrder(e.getShowOrder()) - .forbiddenTag(e.getForbiddenTag()) + .canceled(null == e.getCanceled() ? 0 : e.getCanceled()) .build()).collect(Collectors.toList()); - Map> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany)); + Map> collects = dtoList.stream().filter(item -> 0 != item.getSupSubComId()).collect(Collectors.groupingBy(CompListDTO::getSupSubComId)); // 处理被引用数据 - List usedIds = MapperProxyFactory.getProxy(CompMapper.class).listUsedId(); + List usedIds = getCompMapper().listUsedId(); // 兼容MySQL - usedIds.addAll(MapperProxyFactory.getProxy(CompMapper.class).listUsedIds()); + List strings = getCompMapper().listUsedIds(); + if (CollectionUtils.isNotEmpty(strings)) { + usedIds.addAll(strings); + } List collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList()); - Set leafs = new HashSet<>(); + Set leafs = new HashSet<>(); List collectTree = dtoList.stream().peek(e -> { List childList = collects.get(e.getId()); leafs.add(e.getId()); @@ -63,65 +130,7 @@ public class CompBO { } } }).collect(Collectors.toList()); - return collectTree.stream().filter(item->!leafs.contains(item.getParentCompany())).collect(Collectors.toList()); - } - - public static List buildCompDTOList(Collection list, List filterList) { - // 搜索结果为空,直接返回空 - if (CollectionUtils.isEmpty(filterList)) { - return Collections.emptyList(); - } - // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(CompPO::getId, item -> item)); - List 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 buildSetToSearchTree(Set 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()); + return collectTree.stream().filter(item -> !leafs.contains(item.getSupSubComId())).collect(Collectors.toList()); } /** @@ -131,24 +140,13 @@ public class CompBO { * @param po * @param poMaps */ - private static void dealParentData(List addedList, CompPO po, Map poMaps) { + private static void dealParentData(List addedList, CompPO po, Map poMaps) { if (!addedList.contains(po)) { addedList.add(po); } - CompPO parentCompPO = poMaps.get(po.getParentCompany()); + CompPO parentCompPO = poMaps.get(po.getSupSubComId()); 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); - } - } } diff --git a/src/com/engine/organization/entity/company/dto/CompListDTO.java b/src/com/engine/organization/entity/company/dto/CompListDTO.java index b533ce18..6b017273 100644 --- a/src/com/engine/organization/entity/company/dto/CompListDTO.java +++ b/src/com/engine/organization/entity/company/dto/CompListDTO.java @@ -10,21 +10,20 @@ import lombok.NoArgsConstructor; import java.util.List; /** - * @description: * @author:dxfeng - * @createTime: 2022/05/16 + * @createTime: 2022/11/24 * @version: 1.0 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor -@OrganizationTable(pageId = "2c66b3a4-d4f8-11ec-9774-00ffcbed7508") +@OrganizationTable(pageId = "dcfd9d27-6ba2-11ed-996a-00ffcbed7508") public class CompListDTO { /** * 主键id */ - private Long id; + private Integer id; /** * 是否被引用 */ @@ -32,46 +31,29 @@ public class CompListDTO { /** * 名称 */ - @TableTitle(title = "名称", dataIndex = "compName", key = "compName") - private String compName; + @TableTitle(title = "名称", dataIndex = "subCompanyDesc", key = "subCompanyDesc") + private String subCompanyDesc; /** * 编号 */ - @TableTitle(title = "编号", dataIndex = "compNo", key = "compNo") - private String compNo; + @TableTitle(title = "编号", dataIndex = "subCompanyCode", key = "subCompanyCode") + private String subCompanyCode; /** * 简称 */ - @TableTitle(title = "简称", dataIndex = "compNameShort", key = "compNameShort") - private String compNameShort; + @TableTitle(title = "简称", dataIndex = "subCompanyName", key = "subCompanyName") + private String subCompanyName; /** * 上级公司 */ - @TableTitle(title = "上级分部", dataIndex = "parentCompName", key = "parentCompName") - private String parentCompName; + @TableTitle(title = "上级分部", dataIndex = "supSubComName", key = "supSubComName") + private String supSubComName; - private Long parentCompany; + private Integer supSubComId; - /** - * 组织机构代码 - */ - @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; @@ -79,8 +61,8 @@ public class CompListDTO { /** * 禁用标记 */ - @TableTitle(title = "是否启用", dataIndex = "forbiddenTag", key = "forbiddenTag") - private int forbiddenTag; + @TableTitle(title = "启用", dataIndex = "canceled", key = "canceled") + private Integer canceled; /** * 操作列 diff --git a/src/com/engine/organization/entity/company/param/CompParam.java b/src/com/engine/organization/entity/company/param/CompParam.java new file mode 100644 index 00000000..37f40917 --- /dev/null +++ b/src/com/engine/organization/entity/company/param/CompParam.java @@ -0,0 +1,30 @@ +package com.engine.organization.entity.company.param; + +import com.engine.organization.common.BaseQueryParam; +import lombok.*; + +/** + * @author:dxfeng + * @createTime: 2022/11/24 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper=false) +public class CompParam extends BaseQueryParam { + private Integer Id; + private String subCompanyName; + private String subCompanyDesc; + private Integer companyId; + private Integer supSubComId; + private String url; + private Boolean canceled; + private String subCompanyCode; + private String outKey; + private Integer limitUsers; + private String uuid; + private Integer showOrder; + private Integer showOrderOfTree; +} diff --git a/src/com/engine/organization/entity/company/param/CompSearchParam.java b/src/com/engine/organization/entity/company/param/CompSearchParam.java deleted file mode 100644 index 425bb5a5..00000000 --- a/src/com/engine/organization/entity/company/param/CompSearchParam.java +++ /dev/null @@ -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; -} diff --git a/src/com/engine/organization/entity/company/po/CompPO.java b/src/com/engine/organization/entity/company/po/CompPO.java index 98bfc5c5..ae80432d 100644 --- a/src/com/engine/organization/entity/company/po/CompPO.java +++ b/src/com/engine/organization/entity/company/po/CompPO.java @@ -8,9 +8,8 @@ import lombok.NoArgsConstructor; import java.util.Date; /** - * @description: * @author:dxfeng - * @createTime: 2022/05/16 + * @createTime: 2022/11/24 * @version: 1.0 */ @Data @@ -18,68 +17,21 @@ import java.util.Date; @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 Integer id; + private String subCompanyName; + private String subCompanyDesc; + private Integer companyId; + private Integer supSubComId; + private String url; + private Integer canceled; + private String subCompanyCode; + private String outKey; + private Integer limitUsers; + private Date created; + private Integer creater; + private Date modified; + private Integer modifier; private String uuid; - - private Long creator; - private int deleteType; - private Date createTime; - private Date updateTime; + private Integer showOrder; + private Integer showOrderOfTree; } diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index 40024d09..6841a0d7 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -10,6 +10,7 @@ import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; import weaver.general.Util; import java.util.*; @@ -26,22 +27,23 @@ public class DepartmentBO { public static List buildDeptDTOList(Collection list) { // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); + Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); List dtoList = list.stream().map(e -> DepartmentListDTO .builder() .id(e.getId()) - .deptNo(e.getDeptNo()) - .deptName(e.getDeptName()) - .deptNameShort(e.getDeptNameShort()) - .parentComp(null == e.getParentComp() ? "" : MapperProxyFactory.getProxy(CompMapper.class).listById(e.getParentComp()).getCompName()) - .parentDept(e.getParentDept()) - .parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName()) - .deptPrincipal(getEmployeeNameById(e.getDeptPrincipal())) + .departmentMark(e.getDepartmentMark()) + .departmentName(e.getDepartmentName()) + .departmentCode(e.getDepartmentCode()) + .subCompanyId1(e.getSubCompanyId1()) + .subCompanyName(0 == e.getSubCompanyId1() ? "" : MapperProxyFactory.getProxy(CompMapper.class).listById(e.getSubCompanyId1()).getSubCompanyName()) + .supDepId(e.getSupDepId()) + .supDepName(null == poMaps.get(e.getSupDepId()) ? "" : poMaps.get(e.getSupDepId()).getDepartmentName()) + .bmfzr(getEmployeeNameById(e.getId())) .showOrder(null == e.getShowOrder() ? 0 : e.getShowOrder()) - .forbiddenTag(e.getForbiddenTag()) + .canceled(null == e.getCanceled() ? 0 : e.getCanceled()) .build()).collect(Collectors.toList()); - Map> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept)); + Map> collects = dtoList.stream().filter(item -> null != item.getSupDepId() && 0 != item.getSupDepId()).collect(Collectors.groupingBy(DepartmentListDTO::getSupDepId)); // 处理被引用数据 List usedIds = MapperProxyFactory.getProxy(DepartmentMapper.class).listUsedId(); List collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList()); @@ -57,7 +59,7 @@ public class DepartmentBO { e.setIsUsed(0); } } - }).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList()); + }).filter(item -> null == item.getSupDepId() || 0 == item.getSupDepId()).collect(Collectors.toList()); } public static List buildDeptDTOList(Collection list, List filterList) { @@ -66,7 +68,7 @@ public class DepartmentBO { return Collections.emptyList(); } // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); + Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); List addedList = new ArrayList<>(); for (DepartmentPO po : filterList) { dealParentData(addedList, po, poMaps); @@ -74,32 +76,33 @@ public class DepartmentBO { return buildDeptDTOList(addedList); } - public static DepartmentPO convertParamsToPO(DeptSearchParam param, long employeeId) { + public static DepartmentPO convertParamsToPO(DeptSearchParam param, Integer employeeId) { if (null == param) { return null; } return DepartmentPO .builder() .id(param.getId() == null ? 0 : param.getId()) - .deptNo(param.getDeptNo()) - .deptName(param.getDepartmentName()) - .deptNameShort(param.getDeptNameShort()) - .parentComp(null == param.getParentComp() ? param.getSubcompanyid1() : param.getParentComp()) - .ecCompany(param.getEcCompany()) - .parentDept(null == param.getParentDept() ? param.getDepartmentid() : param.getParentDept()) - .ecDepartment(param.getEcDepartment()) - .deptPrincipal(param.getDeptPrincipal()) + .departmentId(param.getDepartmentId()) + .departmentMark(param.getDepartmentMark()) + .departmentName(param.getDepartmentName()) + .subCompanyId1(param.getSubCompanyId1()) + .supDepId(param.getSupDepId()) + .allSupDepId(param.getAllSupDepId()) + .canceled(param.getCanceled() == null ? null : param.getCanceled() ? 0 : 1) + .departmentCode(param.getDepartmentCode()) + .coadjutant(param.getCoadjutant()) + .uuid(param.getUuid()) .showOrder(param.getShowOrder()) - .forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1) - .description(param.getDescription()) - .deleteType(0) - .createTime(new Date()) - .updateTime(new Date()) - .creator(employeeId) + .showOrderOfTree(param.getShowOrderOfTree()) + .created(new Date()) + .modified(new Date()) + .creater(employeeId) + .modifier(employeeId) .build(); } - public static List buildSingleDeptTreeVOS(List departmentPOs, Long parentComp) { + public static List buildSingleDeptTreeVOS(List departmentPOs, Integer parentComp) { if (CollectionUtils.isEmpty(departmentPOs)) { return Collections.emptyList(); @@ -109,17 +112,17 @@ public class DepartmentBO { SingleDeptTreeVO .builder() .id(e.getId()) - .deptNo(e.getDeptNo()) - .deptName(e.getDeptName()) - .parentComp(e.getParentComp()) - .parentDept(e.getParentDept()) - .parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept())) - .deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal())) + .departmentCode(e.getDepartmentCode()) + .departmentMark(e.getDepartmentMark()) + .subCompanyId1(e.getSubCompanyId1()) + .supDepId(e.getSupDepId()) + .supDepName(null == e.getSupDepId() || e.getSupDepId() == 0 ? "" : getDeptNameById(e.getSupDepId())) + //.deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal())) .build()).collect(Collectors.toList()); //获取非一级部门 - Map> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getParentComp()) && null != item.getParentDept()).collect(Collectors.groupingBy(SingleDeptTreeVO::getParentDept)); + Map> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getSubCompanyId1()) && null != item.getSupDepId() && 0 != item.getSupDepId()).collect(Collectors.groupingBy(SingleDeptTreeVO::getSupDepId)); - return singleDeptTreeVOS.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList()); + return singleDeptTreeVOS.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> parentComp.equals(item.getSubCompanyId1())).collect(Collectors.toList()); } public static List buildSetToSearchTree(Set departmentPOS) { @@ -131,28 +134,40 @@ public class DepartmentBO { return departmentPOS.stream().map(item -> { SearchTree tree = new SearchTree(); tree.setCanClick(true); - tree.setCanceled(item.getForbiddenTag() != 0); + tree.setCanceled(item.getCanceled() != null && item.getCanceled() != 0); tree.setIcon(isLeaf ? "icon-coms-Branch" : "icon-coms-LargeArea"); tree.setId(item.getId().toString()); tree.setIsParent(false); tree.setIsVirtual("0"); - tree.setName(item.getDeptName()); - tree.setPid(null == item.getParentDept() ? "0" : item.getParentDept().toString()); + tree.setName(item.getDepartmentName()); + tree.setPid(null == item.getSupDepId() ? "0" : item.getSupDepId().toString()); tree.setSelected(false); tree.setType("2"); - tree.setParentComp(null == item.getParentComp() ? "0" : item.getParentComp().toString()); - tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder()); + tree.setParentComp(item.getSubCompanyId1().toString()); + tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder().intValue()); return tree; }).collect(Collectors.toList()); } - public static String getDeptNameById(Long id) { + public static String getDeptNameById(Integer id) { return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); } - public static String getEmployeeNameById(Long id) { - return MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(id); + public static String getEmployeeNameById(Integer id) { + if (null == id) { + return ""; + } + String departmentPrincipal = MapperProxyFactory.getProxy(DepartmentMapper.class).getDepartmentPrincipal(id); + if (StringUtils.isBlank(departmentPrincipal) || "$NULL$".equalsIgnoreCase(departmentPrincipal)) { + return ""; + } + List collect = Arrays.stream(departmentPrincipal.split(",")).map(Long::parseLong).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + return ""; + } + List employeeNameById = MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(collect); + return StringUtils.join(employeeNameById, ","); } @@ -163,11 +178,11 @@ public class DepartmentBO { * @param po * @param poMaps */ - private static void dealParentData(List addedList, DepartmentPO po, Map poMaps) { + private static void dealParentData(List addedList, DepartmentPO po, Map poMaps) { if (!addedList.contains(po)) { addedList.add(po); } - DepartmentPO parentPO = poMaps.get(po.getParentDept()); + DepartmentPO parentPO = poMaps.get(po.getSupDepId()); if (null != parentPO) { dealParentData(addedList, parentPO, poMaps); } diff --git a/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java index 4da3d4ea..ea3da8b4 100644 --- a/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java +++ b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java @@ -24,7 +24,7 @@ import java.util.List; tableType = WeaTableType.NONE) public class DepartmentListDTO { - private Long id; + private Integer id; /** * 是否被引用 */ @@ -33,58 +33,54 @@ public class DepartmentListDTO { /** * 名称 */ - @TableTitle(title = "名称", dataIndex = "deptName", key = "deptName",width = "200") - private String deptName; + @TableTitle(title = "名称", dataIndex = "departmentMark", key = "departmentMark", width = "200") + private String departmentMark; /** * 编号 */ - @TableTitle(title = "编号", dataIndex = "deptNo", key = "deptNo") - private String deptNo; + @TableTitle(title = "编号", dataIndex = "departmentCode", key = "departmentCode") + private String departmentCode; /** * 简称 */ - @TableTitle(title = "简称", dataIndex = "deptNameShort", key = "deptNameShort") - private String deptNameShort; + @TableTitle(title = "简称", dataIndex = "departmentName", key = "departmentName") + private String departmentName; /** * 所属分部 */ - @TableTitle(title = "所属分部", dataIndex = "parentComp", key = "parentComp") - private String parentComp; + @TableTitle(title = "所属分部", dataIndex = "subCompanyName", key = "subCompanyName") + private String subCompanyName; + private Integer subCompanyId1; /** * 上级部门 */ - @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") - private String parentDeptName; + @TableTitle(title = "上级部门", dataIndex = "supDepName", key = "supDepName") + private String supDepName; - private Long parentDept; + private Integer supDepId; /** * 部门负责人 */ - @TableTitle(title = "部门负责人", dataIndex = "deptPrincipal", key = "deptPrincipal") - private String deptPrincipal; + @TableTitle(title = "部门负责人", dataIndex = "bmfzr", key = "bmfzr") + private String bmfzr; /** * 显示顺序 */ - @TableTitle(title = "显示顺序", dataIndex = "showOrder", key = "showOrder",sorter = true) - private int showOrder; + @TableTitle(title = "显示顺序", dataIndex = "showOrder", key = "showOrder", sorter = true) + private Double showOrder; - ///** - // * 说明 - // */ - //@TableTitle(title = "说明", dataIndex = "description", key = "description") - //private String description; /** * 禁用标记 */ - @TableTitle(title = "是否启用", dataIndex = "forbiddenTag", key = "forbiddenTag") - private int forbiddenTag; + @TableTitle(title = "启用", dataIndex = "canceled", key = "canceled") + private int canceled; /** * 操作列 */ diff --git a/src/com/engine/organization/entity/department/param/DepartmentMergeParam.java b/src/com/engine/organization/entity/department/param/DepartmentMergeParam.java index e4468c7b..b6976c5f 100644 --- a/src/com/engine/organization/entity/department/param/DepartmentMergeParam.java +++ b/src/com/engine/organization/entity/department/param/DepartmentMergeParam.java @@ -19,11 +19,11 @@ public class DepartmentMergeParam { /** * 所选部门 */ - private Long id; + private Integer id; /** * 合并部门 */ - private Long department; + private Integer department; /** * 合并后名称 */ diff --git a/src/com/engine/organization/entity/department/param/DepartmentMoveParam.java b/src/com/engine/organization/entity/department/param/DepartmentMoveParam.java index a3aee686..40f101f8 100644 --- a/src/com/engine/organization/entity/department/param/DepartmentMoveParam.java +++ b/src/com/engine/organization/entity/department/param/DepartmentMoveParam.java @@ -16,8 +16,8 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class DepartmentMoveParam { - private Long id; + private Integer id; private String moveType; - private Long company; - private Long department; + private Integer company; + private Integer department; } diff --git a/src/com/engine/organization/entity/department/param/DeptSearchParam.java b/src/com/engine/organization/entity/department/param/DeptSearchParam.java index ed70fcfe..099edd5a 100644 --- a/src/com/engine/organization/entity/department/param/DeptSearchParam.java +++ b/src/com/engine/organization/entity/department/param/DeptSearchParam.java @@ -1,10 +1,7 @@ package com.engine.organization.entity.department.param; import com.engine.organization.common.BaseQueryParam; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @description: @@ -16,30 +13,21 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode(callSuper=false) public class DeptSearchParam extends BaseQueryParam { - private Long id; - - private String deptNo; - + private Integer id; + private String departmentMark; private String departmentName; - - private String deptNameShort; - - private Long parentComp; - private Long ecCompany; - - private Long parentDept; - private Long ecDepartment; - - private Long deptPrincipal; - - private Integer showOrder; - - private String description; - + private Integer subCompanyId1; + private Integer supDepId; + private String allSupDepId; + private Boolean canceled; + private String departmentCode; + private Integer coadjutant; + private String departmentId; + + private String uuid; + private Double showOrder; + private Integer showOrderOfTree; private Boolean forbiddenTag; - - private Long subcompanyid1; - - private Long departmentid; } diff --git a/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java index 2845d015..b0b25607 100644 --- a/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java +++ b/src/com/engine/organization/entity/department/param/QuerySingleDeptListParam.java @@ -1,10 +1,7 @@ package com.engine.organization.entity.department.param; import com.engine.organization.common.BaseQueryParam; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @Author weaver_cl @@ -16,10 +13,11 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode(callSuper=false) public class QuerySingleDeptListParam extends BaseQueryParam { - private Long parentComp; + private Integer parentComp; - private Long parentDept; + private Integer parentDept; } diff --git a/src/com/engine/organization/entity/department/po/DepartmentPO.java b/src/com/engine/organization/entity/department/po/DepartmentPO.java index ab4fcbf2..ba80e5e7 100644 --- a/src/com/engine/organization/entity/department/po/DepartmentPO.java +++ b/src/com/engine/organization/entity/department/po/DepartmentPO.java @@ -18,36 +18,23 @@ import java.util.Date; @AllArgsConstructor @NoArgsConstructor public class DepartmentPO { - - private Long id; - - private String deptNo; - - private String deptName; - - private String deptNameShort; - - private Long parentComp; - private Long ecCompany; - - private Long parentDept; - private Long ecDepartment; - - private Long deptPrincipal; //部门负责人 - - private Integer showOrder; - - private String description; - - private Integer forbiddenTag; - + private Integer id; + private String departmentMark; + private String departmentName; + private Integer subCompanyId1; + private Integer supDepId; + private String allSupDepId; + private Integer canceled; + private String departmentCode; + private Integer coadjutant; + private String departmentId; + + private Date created; + private Integer creater; + private Date modified; + private Integer modifier; private String uuid; + private Double showOrder; + private Integer showOrderOfTree; - private Long creator; - - private int deleteType; - - private Date createTime; - - private Date updateTime; } diff --git a/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java index 5ba4493d..d6fbed46 100644 --- a/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java +++ b/src/com/engine/organization/entity/department/vo/SingleDeptTreeVO.java @@ -24,23 +24,23 @@ import java.util.List; tableType = WeaTableType.NONE) public class SingleDeptTreeVO { - private Long id; + private Integer id; - @TableTitle(title = "编号", dataIndex = "deptNo", key = "deptNo") - private String deptNo; + @TableTitle(title = "编号", dataIndex = "departmentCode", key = "departmentCode") + private String departmentCode; - @TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName") - private String deptName; + @TableTitle(title = "部门名称", dataIndex = "departmentMark", key = "departmentMark") + private String departmentMark; - private Long parentComp; //上级分部 + private Integer subCompanyId1; //上级分部 - private Long parentDept; //上级部门id + private Integer supDepId; //上级部门id - @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") - private String parentDeptName; //上级部门 + @TableTitle(title = "上级部门", dataIndex = "supDepName", key = "supDepName") + private String supDepName; //上级部门 - @TableTitle(title = "部门负责人", dataIndex = "deptPrincipalName", key = "deptPrincipalName") - private String deptPrincipalName; //部门负责人 + //@TableTitle(title = "部门负责人", dataIndex = "deptPrincipalName", key = "deptPrincipalName") + //private String deptPrincipalName; //部门负责人 //子节点 private List children; diff --git a/src/com/engine/organization/entity/employee/vo/EmployeeTableVO.java b/src/com/engine/organization/entity/employee/vo/EmployeeTableVO.java index dbe1d060..96895d8d 100644 --- a/src/com/engine/organization/entity/employee/vo/EmployeeTableVO.java +++ b/src/com/engine/organization/entity/employee/vo/EmployeeTableVO.java @@ -21,11 +21,11 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @OrganizationTable(pageId = "80e7830c-18e8-4e14-8241-18821195ef31", fields = "t.id," + - "t.last_name," + + "t.lastname," + "t.mobile," + - "t.company_start_date," + + "t.companystartdate," + "t.sex", - fromSql = "FROM jcl_org_hrmresource t ", + fromSql = "FROM hrmresource t ", orderby = "id", primarykey = "id", tableType = WeaTableType.NONE @@ -35,7 +35,7 @@ public class EmployeeTableVO { @OrganizationTableColumn(column = "id", display = false) private Long id; - @OrganizationTableColumn(text = "姓名", width = "25%", column = "last_name") + @OrganizationTableColumn(text = "姓名", width = "25%", column = "lastname") private String lastname; @OrganizationTableColumn(text = "性别", width = "25%", column = "sex",transmethod = "com.engine.organization.transmethod.JobTransMethod.getSexName") @@ -44,7 +44,7 @@ public class EmployeeTableVO { @OrganizationTableColumn(text = "手机", width = "25%", column = "mobile") private String mobile; - @OrganizationTableColumn(text = "入职日期", width = "25%", column = "company_start_date") + @OrganizationTableColumn(text = "入职日期", width = "25%", column = "companystartdate") private String companystartdate; diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index e850b3d3..c033a73a 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -11,25 +11,37 @@ import com.api.browser.util.BrowserInitUtil; import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; import com.api.hrm.bean.FieldItem; -import com.api.hrm.util.FieldType; -import com.api.hrm.util.ServiceUtil; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.*; +import com.cloudstore.dev.api.util.TextUtil; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.organization.entity.SelectOptionParam; +import com.engine.organization.entity.browser.po.CustomBrowserBean; import com.engine.organization.entity.extend.param.ExtendInfoFieldParam; import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.mapper.extend.ExtendInfoMapper; -import com.engine.organization.entity.browser.po.CustomBrowserBean; import com.engine.organization.util.OrganizationFormItemUtil; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.sensitive.biz.SensitiveWordTypeComInfo; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.docs.docs.CustomFieldManager; +import weaver.encrypt.EncryptUtil; import weaver.file.ImageFileManager; +import weaver.general.BaseBean; import weaver.general.Util; +import weaver.hrm.HrmUserVarify; import weaver.hrm.User; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; import weaver.hrm.definedfield.HrmFieldManager; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.resource.CustomFieldTreeManager; +import weaver.hrm.resource.HrmListValidate; import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; import java.util.*; @@ -47,7 +59,7 @@ public class ExtendInfoBO { public static String DATE_Time_TO = "_end"; // 封装对象为table组件 - public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel, boolean checkBox) { List> lsCol = new ArrayList<>(); Map col; @@ -56,19 +68,53 @@ public class ExtendInfoBO { String tmpkey = extendInfoPO.getFieldName(); col = new HashMap<>(); col.put("title", extendInfoPO.getFieldNameDesc()); - col.put("key", tmpkey); col.put("dataIndex", tmpkey); col.put("com", getFieldDetailInfo(user, extendInfoPO, viewAttr, showLabel, width)); - col.put("width", width + "%"); + if (checkBox && Integer.valueOf(7).equals(extendInfoPO.getControlType())) { + col.put("checkType", "checkbox"); + } + lsCol.add(col); + } + return lsCol; + + } + /** + * 渲染列表时,根据每一列的viewAttr渲染 + * @param user + * @param infoPOList + * @param showLabel + * @param checkBox + * @return + */ + public static List> convertInfoListToTable(User user, List infoPOList, boolean showLabel, boolean checkBox) { + List> lsCol = new ArrayList<>(); + Map col; + + int width = 100 / infoPOList.size(); + for (ExtendInfoPO extendInfoPO : infoPOList) { + String tmpkey = extendInfoPO.getFieldName(); + col = new HashMap<>(); + col.put("title", extendInfoPO.getFieldNameDesc()); + col.put("key", tmpkey); + col.put("dataIndex", tmpkey); + col.put("com", getFieldDetailInfo(user, extendInfoPO, extendInfoPO.getViewAttr(), showLabel, width)); + col.put("width", width + "%"); + if (checkBox && Integer.valueOf(7).equals(extendInfoPO.getControlType())) { + col.put("checkType", "checkbox"); + } lsCol.add(col); } return lsCol; } + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { + return convertInfoListToTable(user, infoPOList, viewAttr, showLabel, false); + } + /** * 新增自定义字段时,对象转换 * @@ -160,9 +206,9 @@ public class ExtendInfoBO { /** * 明细表字段 * - * @param user 当前用户 + * @param user 当前用户 * @param extendInfoPO 名字表字段实体 - * @param viewAttr 操作类型 + * @param viewAttr 操作类型 */ private static List getFieldDetailInfo(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { List ls = new ArrayList<>(); @@ -174,11 +220,11 @@ public class ExtendInfoBO { /** * 创建列表字段信息 * - * @param user 当前用户 + * @param user 当前用户 * @param extendInfoPO 字段信息 - * @param viewAttr 操作类型 - * @param showLabel 展示名字 - * @param width 宽度 + * @param viewAttr 操作类型 + * @param showLabel 展示名字 + * @param width 宽度 */ private static FieldItem createField(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { FieldItem fieldItem = new FieldItem(); @@ -202,12 +248,36 @@ public class ExtendInfoBO { fieldItem.setViewAttr(2); } } - - // 浏览按钮特殊处理 - if (FieldType.BROWSER.equals(fieldItem.getType())) { - String browserId = SelectOptionParam.getCustomBrowserId(extendInfoPO.getCustomValue()); - BrowserBean browserConditionParam = OrganizationFormItemUtil.browserItem(user, 2, 16, fieldItem.getViewAttr(), false, extendInfoPO.getFieldNameDesc(), extendInfoPO.getBrowserType(), extendInfoPO.getFieldName(), browserId).getBrowserConditionParam(); - fieldItem.setBrowserConditionParam(browserConditionParam); + switch (fieldItem.getType()) { + case BROWSER: + String browserId = SelectOptionParam.getCustomBrowserId(extendInfoPO.getCustomValue()); + BrowserBean browserConditionParam = OrganizationFormItemUtil.browserItem(user, 2, 16, fieldItem.getViewAttr(), false, extendInfoPO.getFieldNameDesc(), extendInfoPO.getBrowserType(), extendInfoPO.getFieldName(), browserId).getBrowserConditionParam(); + fieldItem.setBrowserConditionParam(browserConditionParam); + break; + case SELECT: + String customValue = Util.null2String(extendInfoPO.getCustomValue()); + List searchConditionOptions = SelectOptionParam.convertJsonToListOption(customValue); + fieldItem.setOptions(searchConditionOptions); + break; + case FILEUPLOAD: + fieldItem.setUploadUrl("/api/doc/upload/uploadFile"); + fieldItem.setCategory("category"); + fieldItem.setMaxFilesNumber(10); + fieldItem.setMultiSelection(true); + Map otherParamsMap = new HashMap<>(); + otherParamsMap.put("showClearAll", false); + otherParamsMap.put("showOrder", true); + fieldItem.setOtherParams(otherParamsMap); + break; + case DATEPICKER: + if ("402".equals(extendInfoPO.getBrowserType())) { + fieldItem.setFormat("YYYY"); + } else if ("403".equals(extendInfoPO.getBrowserType())) { + fieldItem.setFormat("YYYY-MM"); + } + break; + default: + break; } fieldItem.setWidth(width + "%"); @@ -260,7 +330,7 @@ public class ExtendInfoBO { String fieldid = Util.null2String(extendInfoPO.getId());//字段id String fieldname = Util.null2String(extendInfoPO.getFieldName());//字段名 // String fieldlabel = Util.null2String(extendInfoPO.getFieldNameDesc());//字段显示名 - String fieldlabel = "502327";//字段显示名 + String fieldlabel = "502327";//字段显示名 String fieldhtmltype = Util.null2String(extendInfoPO.getControlType());//字段类型 String detailtype = Util.null2String(extendInfoPO.getBrowserType());//字段二级类型(浏览框--单人力) String customValue = Util.null2String(extendInfoPO.getCustomValue()); @@ -268,7 +338,7 @@ public class ExtendInfoBO { switch (fieldhtmltype) { case "1": //单行文本框 - if (detailtype.equals("2")) {//数字 + if ("2".equals(detailtype)) {//数字 searchConditionItem = conditionFactory.createCondition(ConditionType.INPUTNUMBER, fieldlabel, fieldname, isQuickSearch); } else { searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, "25034", fieldname, isQuickSearch); @@ -319,14 +389,14 @@ public class ExtendInfoBO { break; } default: - if (detailtype.equals("161") || detailtype.equals("162") || detailtype.equals("256") || detailtype.equals("257")) { - BrowserBean browserbean = new BrowserBean( Util.null2String(detailtype)); + if ("161".equals(detailtype) || "162".equals(detailtype) || "256".equals(detailtype) || "257".equals(detailtype)) { + BrowserBean browserbean = new BrowserBean(Util.null2String(detailtype)); BrowserInitUtil browserInitUtil = new BrowserInitUtil(); String fielddbtype = customValue; if (!customValue.startsWith("browser.")) { fielddbtype = "browser." + customValue; } - if (detailtype.equals("161") || detailtype.equals("162")) { + if ("161".equals(detailtype) || "162".equals(detailtype)) { browserInitUtil.initCustomizeBrow(browserbean, fielddbtype, Util.getIntValue(detailtype), user.getUID()); } else { browserbean.getDataParams().put("cube_treeid", customValue); @@ -354,7 +424,9 @@ public class ExtendInfoBO { String[] fieldvalues = Util.splitString(tmpFieldValue, ","); for (int i = 0; fieldvalues != null && i < fieldvalues.length; i++) { String fieldshowname = Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(fieldvalues[i], user.getLanguage())); - if (fieldshowname.length() == 0) continue; + if (fieldshowname.length() == 0) { + continue; + } Map replaceData = new HashMap<>(); replaceData.put("id", fieldvalues[i]); replaceData.put("name", fieldshowname); @@ -367,7 +439,9 @@ public class ExtendInfoBO { String[] fieldvalues = Util.splitString(tmpFieldValue, ","); for (int i = 0; fieldvalues != null && i < fieldvalues.length; i++) { String fieldshowname = Util.null2String(sensitiveWordTypeComInfo.getName(fieldvalues[i])); - if (fieldshowname.length() == 0) continue; + if (fieldshowname.length() == 0) { + continue; + } Map replaceData = new HashMap<>(); replaceData.put("id", fieldvalues[i]); replaceData.put("name", fieldshowname); @@ -395,7 +469,7 @@ public class ExtendInfoBO { String fieldshowname = hrmFieldManager.getFieldvalue(user, customValue, Util.getIntValue(fieldid), Util.getIntValue(fieldhtmltype), Util.getIntValue(detailtype), tmpFieldValue, 0); String[] fieldvalues = Util.splitString(tmpFieldValue, ","); String[] fieldshownames = Util.splitString(fieldshowname, ","); - if (detailtype.equals("257")) { + if ("257".equals(detailtype)) { if (fieldshowname.endsWith(" ")) { fieldshowname = fieldshowname.substring(0, fieldshowname.length() - 5); } @@ -422,7 +496,7 @@ public class ExtendInfoBO { break; case "4": //Check框 searchConditionItem = conditionFactory.createCondition(ConditionType.CHECKBOX, fieldlabel, fieldname); - if (detailtype.equals("2")) { + if ("2".equals(detailtype)) { searchConditionItem.setConditionType(ConditionType.SWITCH); } @@ -431,7 +505,7 @@ public class ExtendInfoBO { List searchConditionOptions = SelectOptionParam.convertJsonToListOption(customValue); searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, fieldlabel, fieldname, searchConditionOptions); - if (detailtype.equals("") || detailtype.equals("0")) { + if ("".equals(detailtype) || "0".equals(detailtype)) { detailtype = "1"; } searchConditionItem.setKey(Util.null2String(fieldvalue)); @@ -439,7 +513,7 @@ public class ExtendInfoBO { searchConditionItem.setDetailtype(Util.getIntValue(detailtype, 3)); break; case "6": //附件 - if (fieldname.equals("resourceimageid")) { + if ("resourceimageid".equals(fieldname)) { searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, fieldlabel, fieldname, isQuickSearch); } else { searchConditionItem = conditionFactory.createCondition(ConditionType.UPLOAD, fieldlabel, fieldname, isQuickSearch); @@ -514,4 +588,334 @@ public class ExtendInfoBO { return searchConditionItem; } + + + // 基本信息明细表 + + // 个人信息明细表 + + // 工作信息明细表 + public Map getFormFields(User user, String id, Integer viewAttr, boolean isAdd) { + Map result = new HashMap(); + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + if (isAdd) { + viewAttr = 2; + } + if (id.length() == 0) { + id = "" + user.getUID(); + } + boolean isSelf = false; + if (id.equals("" + user.getUID())) { + isSelf = true; + } + String subcompanyid = "", departmentId = ""; + RecordSet recordSet = new RecordSet(); + //不能直接判断是否有人力资源维护权限,也需要根据分权进行判断 + boolean canEdit = false; + recordSet.executeSql("select subcompanyid1, status, departmentId from hrmresource where id = " + id); + if (recordSet.next()) { + subcompanyid = Util.toScreen(recordSet.getString("subcompanyid1"), user.getLanguage()); + departmentId = StringUtil.vString(recordSet.getString("departmentId")); + if (subcompanyid == null || "".equals(subcompanyid) || "null".equalsIgnoreCase(subcompanyid)) { + subcompanyid = "-1"; + } + } + int operatelevel = -1; + //人力资源模块是否开启了管理分权,如不是,则不显示框架,直接转向到列表页面(新的分权管理) + int hrmdetachable = 0; + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + boolean isUseHrmManageDetach = ManageDetachComInfo.isUseHrmManageDetach(); + if (isUseHrmManageDetach) { + hrmdetachable = 1; + } else { + hrmdetachable = 0; + } + if (hrmdetachable == 1) { + CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight(); + operatelevel = CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmResourceEdit:Edit", Util.getIntValue(subcompanyid)); + } else { + if (HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user, departmentId)) { + operatelevel = 2; + } + } + if (operatelevel > 0) { + canEdit = true; + } + int scopeId = 1; + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + com.engine.hrm.biz.HrmFieldManager hfm = new com.engine.hrm.biz.HrmFieldManager("HrmCustomFieldByInfoType", scopeId); + CustomFieldManager cfm = new CustomFieldManager("HrmCustomFieldByInfoType", scopeId); + if (viewAttr != 1) { + hfm.isReturnDecryptData(true); + } + hfm.getHrmData(Util.getIntValue(id)); + cfm.getCustomData(Util.getIntValue(id)); + HrmListValidate hrmListValidate = new HrmListValidate(); + + while (HrmFieldGroupComInfo.next()) { + int grouptype = Util.getIntValue(HrmFieldGroupComInfo.getType()); + if (grouptype != scopeId) { + continue; + } + int grouplabel = Util.getIntValue(HrmFieldGroupComInfo.getLabel()); + int groupid = Util.getIntValue(HrmFieldGroupComInfo.getid()); + hfm.getCustomFields(groupid); + + groupitem = new HashMap(); + itemlist = new ArrayList(); + groupitem.put("title", SystemEnv.getHtmlLabelName(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + if (groupid == 4) { + groupitem.put("hide", (!isAdd && !canEdit && isSelf && viewAttr == 2 && hfm.getContactEditCount() == 0) || !hrmListValidate.isValidate(42)); + } else { + groupitem.put("hide", (!isAdd && !canEdit && isSelf && viewAttr == 2 && hfm.getContactEditCount() == 0) || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow()))); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + while (hfm.next()) { + int tmpviewattr = viewAttr; + String fieldName = hfm.getFieldname(); + String cusFieldname = ""; + String fieldValue = ""; + if (hfm.isBaseField(fieldName)) { + fieldValue = hfm.getHrmData(fieldName); + } else { + fieldValue = Util.null2String(new EncryptUtil().decrypt("cus_fielddata", "field" + hfm.getFieldid(), "HrmCustomFieldByInfoType", "" + scopeId, cfm.getData("field" + hfm.getFieldid()), viewAttr == 2, true)); + cusFieldname = "customfield" + hfm.getFieldid(); + if (isAdd) { + cusFieldname = "customfield_1_" + hfm.getFieldid(); + } + } + + if (!hfm.isUse() || (!isAdd && viewAttr == 2 && !canEdit && isSelf && !hfm.isModify())) { + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(cusFieldname.length() > 0 ? cusFieldname : fieldName); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + if (!isAdd) { + hrmFieldBean.setFieldvalue(fieldValue); + } + hrmFieldBean.setIsFormField(true); + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParams = new HashMap(); + otherParams.put("hide", true); + searchConditionItem.setOtherParams(otherParams); + itemlist.add(searchConditionItem); + continue; + } + org.json.JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName); + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid((String) hrmFieldConf.get("id")); + hrmFieldBean.setFieldname(cusFieldname.length() > 0 ? cusFieldname : fieldName); + hrmFieldBean.setFieldlabel(hfm.getLable()); + hrmFieldBean.setFieldhtmltype((String) hrmFieldConf.get("fieldhtmltype")); + hrmFieldBean.setType((String) hrmFieldConf.get("type")); + hrmFieldBean.setDmlurl((String) hrmFieldConf.get("dmlurl")); + hrmFieldBean.setIssystem("" + (Integer) hrmFieldConf.get("issystem")); + if (!isAdd) { + hrmFieldBean.setFieldvalue(fieldValue); + } + hrmFieldBean.setIsFormField(true); + if (viewAttr == 2 && "1".equals((String) hrmFieldConf.get("ismand"))) { + tmpviewattr = 3; + if ("3".equals(hrmFieldBean.getFieldhtmltype())) { + hrmFieldBean.setRules("required|string"); +// if (hrmFieldBean.getType().equals("2")||hrmFieldBean.getType().equals("161")||hrmFieldBean.getType().equals("162")) { +// hrmFieldBean.setRules("required|string"); +// }else{ +// hrmFieldBean.setRules("required|integer"); +// } + } else if ("4".equals(hrmFieldBean.getFieldhtmltype()) || + "5".equals(hrmFieldBean.getFieldhtmltype())) { + hrmFieldBean.setRules("required|integer"); + } else if ("1".equals(hrmFieldBean.getFieldhtmltype()) && "2".equals(hrmFieldBean.getType())) { + hrmFieldBean.setRules("required|integer"); + } else { + hrmFieldBean.setRules("required|string"); + } + } + + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (searchConditionItem == null) { + continue; + } + if (searchConditionItem.getBrowserConditionParam() != null) { + searchConditionItem.getBrowserConditionParam().setViewAttr(tmpviewattr); + } + searchConditionItem.setViewAttr(tmpviewattr); + itemlist.add(searchConditionItem); + } + if (itemlist.size() == 0) { + lsGroup.remove(groupitem); + } + } + result.put("conditions", lsGroup); + + //明细信息 + List lsTable = new ArrayList(); + List titles = null; + Map table = null; + Map maptab = null; + HrmFieldBean hrmFieldBean = null; + List> columns = null; + List> datas = null; + Map data = null; + result.put("tables", lsTable); + + //标头信息--家庭信息 + HrmFieldDetailComInfo HrmFieldDetailComInfo = new HrmFieldDetailComInfo(); + LinkedHashMap> detialTable = HrmFieldDetailComInfo.getDetialTable("" + scopeId, viewAttr, "80%"); + Iterator>> entries = detialTable.entrySet().iterator(); + while (entries.hasNext()) { + Map.Entry> entry = entries.next(); + String tablename = entry.getKey(); + titles = entry.getValue(); + table = new HashMap(); + columns = HrmFieldUtil.getHrmDetailTable(titles, null, user); + table.put("columns", columns); + + datas = new ArrayList>(); + RecordSet rs = new RecordSet(); + String sql = "select * from " + tablename + " where resourceid = " + id; + rs.executeSql(sql); + while (rs.next()) { + data = new HashMap(); + for (HrmFieldBean fieldInfo : titles) { + if (!isAdd) { + data.put(fieldInfo.getFieldname(), TextUtil.toBase64ForMultilang(Util.null2String(rs.getString(fieldInfo.getFieldname())))); + } + } + datas.add(data); + } + table.put("datas", datas); + table.put("rownum", "rownum"); + maptab = new Hashtable(); + String tablabel = HrmResourceDetailTab.HrmResourceDetailTabInfo.get(tablename.toUpperCase()); + maptab.put("tabname", SystemEnv.getHtmlLabelNames(tablabel, user.getLanguage())); + maptab.put("hide", (!hrmListValidate.isValidate(45) || (!isAdd && !canEdit && isSelf && viewAttr == 2))); + maptab.put("tabinfo", table); + lsTable.add(maptab); + } + + //自定义信息 + RecordSet RecordSet = new RecordSet(); + CustomFieldTreeManager CustomFieldTreeManager = new CustomFieldTreeManager(); + LinkedHashMap ht = new LinkedHashMap(); + RecordSet.executeSql("select id, formlabel,viewtype from cus_treeform where parentid=" + scopeId + " order by scopeorder"); + while (RecordSet.next()) { + if (RecordSet.getInt("viewtype") != 1) { + continue; + } + titles = new ArrayList(); + int subId = RecordSet.getInt("id"); + CustomFieldManager cfm2 = new CustomFieldManager("HrmCustomFieldByInfoType", subId); + cfm2.getCustomFields(); + CustomFieldTreeManager.getMutiCustomData("HrmCustomFieldByInfoType", subId, Util.getIntValue(id, 0)); + int colcount1 = 0; + int rowcount = 0; + int col = 0; + while (cfm2.next()) { + rowcount++; + if (!cfm2.isUse() || (!isAdd && viewAttr == 2 && !canEdit && isSelf && !cfm2.isModify())) { + continue; + } + col++; + } + if (rowcount == 0) { + continue; + } + cfm2.beforeFirst(); + ht.put("cus_list_" + subId, RecordSet.getString("formlabel")); + cfm2.beforeFirst(); + while (cfm2.next()) { + if (!cfm2.isUse() || (!isAdd && viewAttr == 2 && !canEdit && isSelf && !cfm2.isModify())) { + continue; + } + int tmpviewattr = viewAttr; + //创建表头 + String fieldname = "customfield" + cfm2.getId() + "_" + subId; + if (isAdd) { + fieldname = "customfield_1_" + cfm2.getId() + "_" + subId; + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid("" + cfm2.getId()); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(cfm2.getLable()); + hrmFieldBean.setFieldhtmltype(cfm2.getHtmlType()); + hrmFieldBean.setType("" + cfm2.getType()); + hrmFieldBean.setDmlurl(cfm2.getDmrUrl()); + if (viewAttr == 2 && cfm2.isMand()) { + tmpviewattr = 3; + hrmFieldBean.setRules("required|string"); + } + hrmFieldBean.setViewAttr(tmpviewattr); + hrmFieldBean.setWidth("80%"); + titles.add(hrmFieldBean); + } + table = new HashMap(); + if (col > 0) { + columns = HrmFieldUtil.getHrmDetailTable(titles, null, user); + table.put("columns", columns); + } + datas = new ArrayList>(); + cfm2.beforeFirst(); + while (CustomFieldTreeManager.nextMutiData()) { + data = new HashMap(); + while (cfm2.next()) { +// if(!cfm2.isUse()||(!isAdd&&viewAttr==2&&!canEdit&&isSelf&&!cfm2.isModify()))continue; + int fieldid = cfm2.getId(); //字段id + int type = cfm2.getType(); + String dmlurl = cfm2.getDmrUrl(); + int fieldhtmltype = Util.getIntValue(cfm2.getHtmlType()); + + String fieldname = "customfield" + cfm2.getId() + "_" + subId; + if (isAdd) { + fieldname = "customfield_1_" + cfm2.getId() + "_" + subId; + } + String fieldvalue = ""; + if (!isAdd) { + fieldvalue = Util.null2String(CustomFieldTreeManager.getMutiData("field" + fieldid)); + } + data.put(fieldname, fieldvalue); + if ("1".equals(cfm2.getHtmlType()) && cfm2.getType() == 1) { + data.put(fieldname, TextUtil.toBase64ForMultilang(Util.null2String(fieldvalue))); + } else if ("3".equals(cfm2.getHtmlType())) { + String fieldshowname = hfm.getFieldvalue(user, dmlurl, fieldid, fieldhtmltype, type, fieldvalue, 0); + data.put(fieldname, fieldvalue); + data.put(fieldname + "span", fieldshowname); + } else if ("4".equals(cfm2.getHtmlType())) { + data.put(fieldname, "1".equals(fieldvalue)); + } + //只允许有权限的人删除明细行,没有权限的人只能修改不能删除 + if (canEdit) { + data.put("viewAttr", 2); + } else { + data.put("viewAttr", 1); + } + } + cfm2.beforeFirst(); + datas.add(data); + } + table.put("datas", datas); + table.put("rownum", "nodesnum_" + subId); + maptab = new Hashtable(); + RecordSet rs = new RecordSet(); + rs.executeSql("select id, formlabel from cus_treeform where parentid=" + scopeId + " and id=" + subId + " order by scopeorder"); + if (rs.next()) { + maptab.put("tabname", rs.getString("id")); + maptab.put("tabname", rs.getString("formlabel")); + } + maptab.put("hide", col == 0); + maptab.put("tabinfo", table); + lsTable.add(maptab); + } + } catch (Exception e) { + new BaseBean().writeLog(e); + } + return result; + } } diff --git a/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java b/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java index f55992af..8cc8e12c 100644 --- a/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java +++ b/src/com/engine/organization/entity/extend/param/ExtendInfoFieldParam.java @@ -38,17 +38,17 @@ public class ExtendInfoFieldParam { public String getControlType() { JSONArray fieldType = (JSONArray) this.getFieldType(); String fieldHtmlType = Util.null2String(fieldType.get(0)); - if (fieldHtmlType.equals("input")) { + if ("input".equals(fieldHtmlType)) { fieldHtmlType = "1"; - } else if (fieldHtmlType.equals("textarea")) { + } else if ("textarea".equals(fieldHtmlType)) { fieldHtmlType = "2"; - } else if (fieldHtmlType.equals("browser")) { + } else if ("browser".equals(fieldHtmlType)) { fieldHtmlType = "3"; - } else if (fieldHtmlType.equals("check")) { + } else if ("check".equals(fieldHtmlType)) { fieldHtmlType = "4"; - } else if (fieldHtmlType.equals("select")) { + } else if ("select".equals(fieldHtmlType)) { fieldHtmlType = "5"; - } else if (fieldHtmlType.equals("upload")) { + } else if ("upload".equals(fieldHtmlType)) { fieldHtmlType = "6"; } return fieldHtmlType; @@ -60,27 +60,27 @@ public class ExtendInfoFieldParam { if (fieldType.size() > 1) { browserType = Util.null2String(fieldType.get(1)); } - if (controlType.equals("1")) { - if (browserType.equals("text")) { + if ("1".equals(controlType)) { + if ("text".equals(browserType)) { browserType = "1"; - } else if (browserType.equals("int")) { + } else if ("int".equals(browserType)) { browserType = "2"; - } else if (browserType.equals("float")) { + } else if ("float".equals(browserType)) { browserType = "3"; - } else if (browserType.equals("file")) { + } else if ("file".equals(browserType)) { browserType = "1"; } } - if (controlType.equals("2")) { + if ("2".equals(controlType)) { browserType = "1"; - } else if (controlType.equals("3")) { + } else if ("3".equals(controlType)) { browserType = Util.null2String(((JSONObject) fieldType.get(1)).get("value")); - } else if (controlType.equals("4")) { + } else if ("4".equals(controlType)) { browserType = "1"; - } else if (controlType.equals("5")) { + } else if ("5".equals(controlType)) { browserType = "1"; - } else if (controlType.equals("6")) { - if (browserType.equals("file")) { + } else if ("6".equals(controlType)) { + if ("file".equals(browserType)) { browserType = "1"; } } @@ -89,7 +89,7 @@ public class ExtendInfoFieldParam { public String getDbType(String controlType, String browserType) { FieldParam fp = new FieldParam(); - if (controlType.equals("1")) { + if ("1".equals(controlType)) { JSONArray fieldType = (JSONArray) this.getFieldType(); String dbLength = "100"; if (fieldType.size() > 2) { @@ -101,15 +101,15 @@ public class ExtendInfoFieldParam { } fp.setSimpleText(Util.getIntValue(browserType, -1), dbLength); - } else if (controlType.equals("2")) { + } else if ("2".equals(controlType)) { fp.setText(); - } else if (controlType.equals("3")) { + } else if ("3".equals(controlType)) { fp.setBrowser(Util.getIntValue(browserType, -1)); - } else if (controlType.equals("4")) { + } else if ("4".equals(controlType)) { fp.setCheck(); - } else if (controlType.equals("5")) { + } else if ("5".equals(controlType)) { fp.setSelect(); - } else if (controlType.equals("6")) { + } else if ("6".equals(controlType)) { fp.setAttach(); } return fp.getFielddbtype(); diff --git a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java index da0033b1..57f48249 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendInfoPO.java @@ -131,4 +131,6 @@ public class ExtendInfoPO { private int deleteType; private Date createTime; private Date updateTime; + + private Integer viewAttr; } diff --git a/src/com/engine/organization/entity/fieldset/param/FieldTransferParam.java b/src/com/engine/organization/entity/fieldset/param/FieldTransferParam.java index f6419cfc..37f54882 100644 --- a/src/com/engine/organization/entity/fieldset/param/FieldTransferParam.java +++ b/src/com/engine/organization/entity/fieldset/param/FieldTransferParam.java @@ -17,4 +17,5 @@ import lombok.NoArgsConstructor; public class FieldTransferParam { private String id; private String name; + private boolean check; } diff --git a/src/com/engine/organization/entity/hrmresource/bo/ResourceBO.java b/src/com/engine/organization/entity/hrmresource/bo/ResourceBO.java new file mode 100644 index 00000000..2c0cefca --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/bo/ResourceBO.java @@ -0,0 +1,36 @@ +package com.engine.organization.entity.hrmresource.bo; + +import com.engine.organization.entity.hrmresource.po.ResourcePO; +import com.engine.organization.entity.searchtree.SearchTree; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +public class ResourceBO { + + public static List buildSetToSearchTree(Collection builderJobs) { + return builderJobs.stream().map(item -> { + SearchTree tree = new SearchTree(); + tree.setCanClick(true); + tree.setCanceled(false); + tree.setIcon("icon-coms-currency-Customer"); + tree.setId(item.getId().toString()); + tree.setIsParent(false); + tree.setIsVirtual("0"); + tree.setName(item.getLastName()); + tree.setPid("0"); + tree.setSelected(false); + tree.setType("4"); + tree.setParentComp(null == item.getJobId() ? "0" : item.getJobId().toString()); + tree.setOrderNum(null == item.getDspOrder() ? 0 : item.getDspOrder()); + return tree; + }).collect(Collectors.toList()); + + } +} diff --git a/src/com/engine/organization/entity/hrmresource/param/HrmResourceSearchParam.java b/src/com/engine/organization/entity/hrmresource/param/HrmResourceSearchParam.java index b3cb3006..8a549ea9 100644 --- a/src/com/engine/organization/entity/hrmresource/param/HrmResourceSearchParam.java +++ b/src/com/engine/organization/entity/hrmresource/param/HrmResourceSearchParam.java @@ -1,10 +1,7 @@ package com.engine.organization.entity.hrmresource.param; import com.engine.organization.common.BaseQueryParam; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @author:dxfeng @@ -15,6 +12,7 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode(callSuper=false) public class HrmResourceSearchParam extends BaseQueryParam { /** * 姓名 diff --git a/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java b/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java new file mode 100644 index 00000000..cd05eeff --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/param/SearchTemplateParam.java @@ -0,0 +1,22 @@ +package com.engine.organization.entity.hrmresource.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2023/01/05 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SearchTemplateParam { + private String key; + //private boolean selected; + private String showname; + private String fields; +} diff --git a/src/com/engine/organization/entity/hrmresource/po/JclOrgCustomTemplatePO.java b/src/com/engine/organization/entity/hrmresource/po/JclOrgCustomTemplatePO.java new file mode 100644 index 00000000..03ccf830 --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/po/JclOrgCustomTemplatePO.java @@ -0,0 +1,67 @@ +package com.engine.organization.entity.hrmresource.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +/** + * + * @TableName jcl_org_custom_template + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class JclOrgCustomTemplatePO implements Serializable { + /** + * + */ + private Integer id; + + /** + * + */ + private String name; + + /** + * + */ + private String basicFields; + + /** + * + */ + private String personalFields; + + /** + * + */ + private String workFields; + + /** + * + */ + private Integer isused; + + /** + * + */ + private Integer creator; + + /** + * + */ + private Date createTime; + + /** + * + */ + private Date updateTime; + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/src/com/engine/organization/entity/hrmresource/po/ResourcePO.java b/src/com/engine/organization/entity/hrmresource/po/ResourcePO.java new file mode 100644 index 00000000..c7faae1b --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/po/ResourcePO.java @@ -0,0 +1,37 @@ +package com.engine.organization.entity.hrmresource.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/15 + * @Version V1.0 + **/ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ResourcePO { + + private Long id; + + private Integer subcompanyid1; + + private Integer departmentid; + + private Integer jobtitle; + + private String lastName; + private Integer dspOrder; + + /** + * 临时关联聚才林岗位ID + */ + private Long jobId; + +} diff --git a/src/com/engine/organization/entity/hrmresource/po/SearchTemplatePO.java b/src/com/engine/organization/entity/hrmresource/po/SearchTemplatePO.java new file mode 100644 index 00000000..4393a206 --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/po/SearchTemplatePO.java @@ -0,0 +1,29 @@ +package com.engine.organization.entity.hrmresource.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @author:dxfeng + * @createTime: 2023/01/06 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SearchTemplatePO { + private Integer id; + private String name; + private String basicFields; + private String personalFields; + private String workFields; + private String isused; + private Integer creator; + private Date createTime; + private Date updateTime; +} diff --git a/src/com/engine/organization/entity/hrmresource/po/TransferDataPO.java b/src/com/engine/organization/entity/hrmresource/po/TransferDataPO.java new file mode 100644 index 00000000..c0de5cba --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/po/TransferDataPO.java @@ -0,0 +1,22 @@ +package com.engine.organization.entity.hrmresource.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2023/01/11 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TransferDataPO { + private String id; + private String label; + private String title; + private String idx; +} diff --git a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceJclVO.java b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceJclVO.java new file mode 100644 index 00000000..916ee84b --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceJclVO.java @@ -0,0 +1,47 @@ +package com.engine.organization.entity.hrmresource.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.organization.annotation.OrganizationTable; +import com.engine.organization.annotation.OrganizationTableColumn; +import com.engine.organization.annotation.OrganizationTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:ml + * @createTime: 2023/01/06 + * @version: 1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@OrganizationTable(pageId = "c0583f20-f10c-11ec-9947-00e04c680716", + fields = "t.id," + + "t.lastname," + + "t.departmentid," + + "t.subcompanyid1," + + "t.jobtitle," + + "t.mobile," + + "t.telephone," + + "t.managerid, " + + "t.dsporder ", + fromSql = "FROM hrmresource t ", + orderby = " dsporder ", + sortway = " asc", + primarykey = "id", + operates = { + @OrganizationTableOperate(text = "查看"), + @OrganizationTableOperate(index = "1", text = "另存为版本") + }, + tableType = WeaTableType.CHECKBOX +) +public class HrmResourceJclVO { + /** + * 主键 + */ + @OrganizationTableColumn(column = "id", display = false) + private Long id; +} diff --git a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java index 0f973bbf..aa6869e7 100644 --- a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java +++ b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java @@ -18,20 +18,21 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @OrganizationTable(pageId = "c0583f20-f10c-11ec-9947-00e04c680716", fields = "t.id," + - "t.last_name," + - "t.department_id," + - "t.company_id," + - "t.job_title," + + "t.lastname," + + "t.departmentid," + + "t.subcompanyid1," + + "t.jobtitle," + "t.mobile," + "t.telephone," + - "t.manager_id, " + - "t.show_order ", - fromSql = "FROM jcl_org_hrmresource t ", - orderby = " show_order ", + "t.managerid, " + + "t.dsporder ", + fromSql = "FROM hrmresource t left join cus_fielddata t0 on t.id = t0.id and t0.scopeid ='-1' left join cus_fielddata t1 on t.id = t1.id and t1.scopeid ='1' left join cus_fielddata t2 on t.id = t2.id and t2.scopeid ='3' left join HRMJOBTITLES t3 on t.JOBTITLE=t3.id left join HRMJOBACTIVITIES t4 on t3.JOBACTIVITYID=t4.ID left join HRMJOBGROUPS t5 on t4.JOBGROUPID=t5.ID ", + orderby = " t.dsporder ", sortway = " asc", primarykey = "id", operates = { - @OrganizationTableOperate(text = "查看") + @OrganizationTableOperate(text = "查看"), + @OrganizationTableOperate(index = "1", text = "另存为版本") }, tableType = WeaTableType.CHECKBOX ) @@ -45,21 +46,21 @@ public class HrmResourceVO { /** * 姓名 */ - @OrganizationTableColumn(text = "姓名", width = "25%", column = "last_name") + @OrganizationTableColumn(text = "姓名", width = "25%", column = "lastname") private String lastName; /** * 部门 */ - @OrganizationTableColumn(text = "部门", width = "25%", column = "department_id", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getDepartmentName") + @OrganizationTableColumn(text = "部门", width = "25%", column = "departmentid", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getDepartmentName") private String departmentName; /** * 分部 */ - @OrganizationTableColumn(text = "分部", width = "25%", column = "company_id", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getCompanyName") + @OrganizationTableColumn(text = "分部", width = "25%", column = "subcompanyid1", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getCompanyName") private String companyName; - @OrganizationTableColumn(text = "岗位", width = "25%", column = "job_title", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getJobName") + @OrganizationTableColumn(text = "岗位", width = "25%", column = "jobtitle", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getJobName") private String jobName; /** @@ -75,9 +76,9 @@ public class HrmResourceVO { /** * 直接上级 */ - @OrganizationTableColumn(text = "直接上级", width = "25%", column = "manager_id", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getManagerName") + @OrganizationTableColumn(text = "直接上级", width = "25%", column = "managerid", transmethod = "com.engine.organization.transmethod.HrmResourceTransMethod.getManagerName") private String managerName; - @OrganizationTableColumn(text = "显示顺序", width = "25%", column = "show_order", orderkey = "show_order") + @OrganizationTableColumn(text = "显示顺序", width = "25%", column = "dsporder", orderkey = "dsporder") private Integer showOrder; } diff --git a/src/com/engine/organization/entity/hrmresource/vo/JclOrgCustomTemplateVO.java b/src/com/engine/organization/entity/hrmresource/vo/JclOrgCustomTemplateVO.java new file mode 100644 index 00000000..f5bbbd1c --- /dev/null +++ b/src/com/engine/organization/entity/hrmresource/vo/JclOrgCustomTemplateVO.java @@ -0,0 +1,67 @@ +package com.engine.organization.entity.hrmresource.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.organization.annotation.OrganizationTable; +import com.engine.organization.annotation.OrganizationTableColumn; +import com.engine.organization.annotation.OrganizationTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@OrganizationTable(pageId = "8df45b09-0cda-4f57-a93a-ca9f96a4c111", + fields = "t.id," + + "t.name," + + "t.basic_fields," + + "t.personal_fields," + + "t.work_fields," + + "t.isused," + + "t.creator," + + "t.create_time," + + "t.update_time", + fromSql = "FROM jcl_org_custom_template t ", + orderby = "id", + sortway = "asc", + primarykey = "id", + operates = { + @OrganizationTableOperate(index = "0", text = "编辑"), + @OrganizationTableOperate(index = "1", text = "另存为"), + @OrganizationTableOperate(index = "2", text = "删除") + }, + tableType = WeaTableType.CHECKBOX +) +public class JclOrgCustomTemplateVO { + + @OrganizationTableColumn(column = "id", display = false) + private Integer id; + + @OrganizationTableColumn(text = "模板名称", width = "30%", column = "name") + private String name; + + @OrganizationTableColumn(column = "basic_fields", display = false) + private String basicFields; + + @OrganizationTableColumn(column = "personal_fields", display = false) + private String personalFields; + + @OrganizationTableColumn(column = "work_fields", display = false) + private String workFields; + + @OrganizationTableColumn(column = "isused", display = false) + private Integer isUsed; + + @OrganizationTableColumn(column = "creator", display = false) + private Integer creator; + + @OrganizationTableColumn(text = "创建时间",column = "create_time", width = "30%") + private Date createTime; + + @OrganizationTableColumn(text = "更新时间",column = "update_time", display = false) + private Date updateTime; +} diff --git a/src/com/engine/organization/entity/jclimport/po/HrmFormFieldPO.java b/src/com/engine/organization/entity/jclimport/po/HrmFormFieldPO.java new file mode 100644 index 00000000..83cc0390 --- /dev/null +++ b/src/com/engine/organization/entity/jclimport/po/HrmFormFieldPO.java @@ -0,0 +1,42 @@ +package com.engine.organization.entity.jclimport.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.json.JSONException; +import org.json.JSONObject; +import weaver.general.Util; + +/** + * @author:dxfeng + * @createTime: 2022/12/06 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class HrmFormFieldPO { + private Integer fieldId; + private String fieldName; + private String labelName; + private Integer isSystem; + private Integer isMand; + private String fieldDbType; + private String fieldHtmlType; + private String type; + private String dmlUrl; + + public JSONObject getJsonObject(String fieldValue) throws JSONException { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("fieldid", Util.null2String(this.fieldId)); + jsonObject.put("fieldhtmltype", Util.null2String(this.fieldHtmlType)); + jsonObject.put("type", Util.null2String(this.type)); + jsonObject.put("dmlurl", Util.null2String(this.dmlUrl)); + jsonObject.put("fieldvalue", fieldValue); + return jsonObject; + } + + +} diff --git a/src/com/engine/organization/entity/job/bo/JobBO.java b/src/com/engine/organization/entity/job/bo/JobBO.java index c1fb690b..9b31a888 100644 --- a/src/com/engine/organization/entity/job/bo/JobBO.java +++ b/src/com/engine/organization/entity/job/bo/JobBO.java @@ -10,6 +10,7 @@ import com.engine.organization.transmethod.JobTransMethod; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import weaver.general.Util; +import weaver.hrm.job.JobTitlesComInfo; import java.util.*; import java.util.stream.Collectors; @@ -30,11 +31,10 @@ public class JobBO { .builder() .id(param.getId() == null ? 0 : param.getId()) .jobNo(param.getJobNo()) - .jobName(param.getJobName()) - .ecCompany(param.getEcCompany()) - .ecDepartment(param.getEcDepartment()) - .parentComp(param.getSubcompanyid1()) - .parentDept( param.getDepartmentid()) + .jobTitleName(param.getJobTitleName()) + .ecJobTitle(param.getEcJobTitle()) + .ecCompany(param.getSubcompanyid1()) + .ecDepartment(param.getDepartmentid()) .sequenceId(param.getSequenceId()) .schemeId(param.getSchemeId()) .parentJob(param.getParentJob()) @@ -53,7 +53,7 @@ public class JobBO { } - public static List buildSingleJobTreeVOS(List jobPOS, Long parentDept) { + public static List buildSingleJobTreeVOS(List jobPOS, Integer parentDept) { if (CollectionUtils.isEmpty(jobPOS)) { return Collections.emptyList(); } @@ -64,10 +64,10 @@ public class JobBO { .builder() .id(e.getId()) .jobNo(e.getJobNo()) - .jobName(e.getJobName()) - .parentJobName(null == poMaps.get(e.getParentJob()) ? "" : poMaps.get(e.getParentJob()).getJobName()) + .jobName(e.getJobTitleName()) + //.parentJobName(null == poMaps.get(e.getParentJob()) ? "" : poMaps.get(e.getParentJob()).getJobTitleName()) .parentJob(e.getParentJob()) - .parentDept(e.getParentDept()) + .parentDept(e.getEcDepartment()) .build()).collect(Collectors.toList()); //获取非一级部门 Map> collects = singleJobTreeVOS.stream().filter(item -> null != item.getParentJob()).collect(Collectors.groupingBy(SingleJobTreeVO::getParentJob)); @@ -78,32 +78,30 @@ public class JobBO { public static List buildDTOList(Collection list) { // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(JobListDTO::getId, item -> item)); - List dtoList = list.stream().map(e -> JobListDTO.builder() .id(e.getId()) .jobNo(e.getJobNo()) - .jobName(e.getJobName()) - .compName(e.getCompName()) - .deptName(e.getDeptName()) - .sequenceName(e.getSequenceName()) - .schemeName(e.getSchemeName()) + .jobTitleName(e.getJobTitleName()) + .subCompanyName(e.getSubCompanyName()) + .departmentName(e.getDepartmentName()) + //.sequenceName(e.getSequenceName()) + //.schemeName(e.getSchemeName()) //.parentJob(e.getParentJob()) //.parentJobName(null == poMaps.get(e.getParentJob()) ? "" : poMaps.get(e.getParentJob()).getJobName()) .isKey(JobTransMethod.getIsKeySpan(e.getIsKey())) .showOrder(e.getShowOrder()) - .forbiddenTag(e.getForbiddenTag()) + //.forbiddenTag(e.getForbiddenTag()) + .isUsed(0) .build()).collect(Collectors.toList()); - Map> collects = dtoList.stream().filter(item -> null != item.getParentJob() && 0 != item.getParentJob()).collect(Collectors.groupingBy(JobListDTO::getParentJob)); - // 处理被引用数据 List usedIds = MapperProxyFactory.getProxy(JobMapper.class).listUsedId(); + Map> collects = dtoList.stream().filter(item -> null != item.getParentJob() && 0 != item.getParentJob()).collect(Collectors.groupingBy(JobListDTO::getParentJob)); return dtoList.stream().peek(e -> { List childList = collects.get(e.getId()); if (CollectionUtils.isNotEmpty(childList)) { e.setChildren(childList); e.setIsUsed(1); - } else { + }else{ if (usedIds.contains(Util.null2String(e.getId()))) { e.setIsUsed(1); } else { @@ -151,19 +149,30 @@ public class JobBO { return builderJobs.stream().map(item -> { SearchTree tree = new SearchTree(); tree.setCanClick(true); - tree.setCanceled(false); + tree.setCanceled(item.getForbiddenTag() != 0); tree.setIcon("icon-coms-content-o"); tree.setId(item.getId().toString()); tree.setIsParent(false); tree.setIsVirtual("0"); - tree.setName(item.getJobName()); + tree.setName(item.getJobTitleName()); tree.setPid(null == item.getParentJob() ? "0" : item.getParentJob().toString()); tree.setSelected(false); tree.setType("3"); - tree.setParentComp(null == item.getParentDept() ? "0" : item.getParentDept().toString()); + tree.setParentComp(null == item.getEcDepartment() ? "0" : item.getEcDepartment().toString()); tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder()); return tree; }).collect(Collectors.toList()); } + + public static String getJobTitleNameByEcJobTitle(String ecJobTitle) { + return new JobTitlesComInfo().getJobTitlesname(ecJobTitle); + } + + public static JobPO getEcJobTitleByJobId(Long jobId) { + if (null == jobId) { + return null; + } + return MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId); + } } diff --git a/src/com/engine/organization/entity/job/dto/JobListDTO.java b/src/com/engine/organization/entity/job/dto/JobListDTO.java index be769e5f..0404210b 100644 --- a/src/com/engine/organization/entity/job/dto/JobListDTO.java +++ b/src/com/engine/organization/entity/job/dto/JobListDTO.java @@ -34,8 +34,8 @@ public class JobListDTO { /** * 名称 */ - @TableTitle(title = "名称", dataIndex = "jobName", key = "jobName",width = "150") - private String jobName; + @TableTitle(title = "名称", dataIndex = "jobTitleName", key = "jobTitleName", width = "150") + private String jobTitleName; /** * 编号 */ @@ -44,23 +44,23 @@ public class JobListDTO { /** * 所属分部 */ - @TableTitle(title = "所属分部", dataIndex = "compName", key = "compName") - private String compName; + @TableTitle(title = "所属分部", dataIndex = "subCompanyName", key = "subCompanyName") + private String subCompanyName; /** * 所属部门 */ - @TableTitle(title = "所属部门", dataIndex = "deptName", key = "deptName") - private String deptName; + @TableTitle(title = "所属部门", dataIndex = "departmentName", key = "departmentName") + private String departmentName; /** * 岗位序列 */ - @TableTitle(title = "岗位序列", dataIndex = "sequenceName", key = "sequenceName") - private String sequenceName; + //@TableTitle(title = "岗位序列", dataIndex = "sequenceName", key = "sequenceName") + //private String sequenceName; /** * 等级方案 */ - @TableTitle(title = "等级方案", dataIndex = "schemeName", key = "schemeName") - private String schemeName; + //@TableTitle(title = "等级方案", dataIndex = "schemeName", key = "schemeName") + //private String schemeName; /** * 上级岗位 */ @@ -68,7 +68,7 @@ public class JobListDTO { //@TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName") private String parentJobName; private Long parentJob; - private Long parentComp; + private Integer ecCompany; /** * 是否关键岗 */ @@ -84,8 +84,8 @@ public class JobListDTO { /** * 禁用标记 */ - @TableTitle(title = "是否启用", dataIndex = "forbiddenTag", key = "forbiddenTag") - private Integer forbiddenTag; + //@TableTitle(title = "是否启用", dataIndex = "forbiddenTag", key = "forbiddenTag") + //private Integer forbiddenTag; /** * 操作列 diff --git a/src/com/engine/organization/entity/job/param/JobSearchParam.java b/src/com/engine/organization/entity/job/param/JobSearchParam.java index 9989867d..fd1871f4 100644 --- a/src/com/engine/organization/entity/job/param/JobSearchParam.java +++ b/src/com/engine/organization/entity/job/param/JobSearchParam.java @@ -1,10 +1,7 @@ package com.engine.organization.entity.job.param; import com.engine.organization.common.BaseQueryParam; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @description: @@ -16,6 +13,7 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode(callSuper=false) public class JobSearchParam extends BaseQueryParam { /** * 主键 @@ -28,15 +26,15 @@ public class JobSearchParam extends BaseQueryParam { /** * 名称 */ - private String jobName; + private String jobTitleName; /** * ec分部 */ - private Long ecCompany; + private Integer ecCompany; /** * ec部门 */ - private Long ecDepartment; + private Integer ecDepartment; /** * 岗位序列 */ @@ -79,7 +77,9 @@ public class JobSearchParam extends BaseQueryParam { */ private Integer showOrder; - private Long subcompanyid1; + private Integer subcompanyid1; - private Long departmentid; + private Integer departmentid; + + private Integer ecJobTitle; } diff --git a/src/com/engine/organization/entity/job/po/JobPO.java b/src/com/engine/organization/entity/job/po/JobPO.java index 3de9c18a..c7cb358a 100644 --- a/src/com/engine/organization/entity/job/po/JobPO.java +++ b/src/com/engine/organization/entity/job/po/JobPO.java @@ -29,24 +29,24 @@ public class JobPO { /** * 名称 */ - private String jobName; - /** - * 所属分部 - */ - private Long parentComp; + private String jobTitleName; + ///** + // * 所属分部 + // */ + //private Integer parentComp; /** * ec分部 */ - private Long ecCompany; - /** - * 所属部门 - */ - private Long parentDept; + private Integer ecCompany; + ///** + // * 所属部门 + // */ + //private Integer parentDept; /** * ec部门 */ - private Long ecDepartment; + private Integer ecDepartment; /** * 岗位序列 @@ -93,6 +93,8 @@ public class JobPO { private String levelId; + private Integer ecJobTitle; + private Long creator; private int deleteType; diff --git a/src/com/engine/organization/entity/job/vo/JobBrowserVO.java b/src/com/engine/organization/entity/job/vo/JobBrowserVO.java index c33dd16d..097850f3 100644 --- a/src/com/engine/organization/entity/job/vo/JobBrowserVO.java +++ b/src/com/engine/organization/entity/job/vo/JobBrowserVO.java @@ -19,8 +19,8 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @OrganizationTable(pageId = "98e9c62f-cd12-11ec-a15f-00ffcbed7123", - fields = "t.id, t.job_no, t.job_name as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id", - fromSql = "FROM jcl_org_job t ", + fields = "t.id, t.job_no, h.jobtitlename as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id", + fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.id ", orderby = "id", sortway = "asc", primarykey = "id", @@ -41,12 +41,12 @@ public class JobBrowserVO { @OrganizationTableColumn(text = "岗位名称", width = "25%", column = "name") private String jobName; - @OrganizationTableColumn(text = "等级方案", width = "25%", column = "scheme_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSchemeName") - private String schemeName; - @OrganizationTableColumn(text = "职等", width = "25%", column = "level_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getLevelName") - private String levelName; - @OrganizationTableColumn(text = "职级", width = "25%", column = "grade_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getGradeName") - private String gradeName; - @OrganizationTableColumn(text = "岗位序列", width = "25%", column = "sequence_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSequenceName") - private String sequenceName; + //@OrganizationTableColumn(text = "等级方案", width = "25%", column = "scheme_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSchemeName") + //private String schemeName; + //@OrganizationTableColumn(text = "职等", width = "25%", column = "level_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getLevelName") + //private String levelName; + //@OrganizationTableColumn(text = "职级", width = "25%", column = "grade_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getGradeName") + //private String gradeName; + //@OrganizationTableColumn(text = "岗位序列", width = "25%", column = "sequence_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSequenceName") + //private String sequenceName; } diff --git a/src/com/engine/organization/entity/job/vo/SingleJobTreeVO.java b/src/com/engine/organization/entity/job/vo/SingleJobTreeVO.java index 00ac4781..fc15471b 100644 --- a/src/com/engine/organization/entity/job/vo/SingleJobTreeVO.java +++ b/src/com/engine/organization/entity/job/vo/SingleJobTreeVO.java @@ -32,12 +32,12 @@ public class SingleJobTreeVO { @TableTitle(title = "岗位名称", dataIndex = "jobName", key = "jobName") private String jobName; - @TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName") - private String parentJobName; + //@TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName") + //private String parentJobName; private Long parentJob; - private Long parentDept; + private Integer parentDept; private List children; diff --git a/src/com/engine/organization/entity/logview/bo/FieldInfo.java b/src/com/engine/organization/entity/logview/bo/FieldInfo.java index 11a9f68b..dfb36f74 100644 --- a/src/com/engine/organization/entity/logview/bo/FieldInfo.java +++ b/src/com/engine/organization/entity/logview/bo/FieldInfo.java @@ -98,8 +98,12 @@ public class FieldInfo { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } FieldInfo fieldInfo = (FieldInfo) o; return Objects.equals(fieldName, fieldInfo.fieldName) && Objects.equals(firstFieldType, fieldInfo.firstFieldType) && diff --git a/src/com/engine/organization/entity/personnelcard/FormItem.java b/src/com/engine/organization/entity/personnelcard/FormItem.java index 4d7e1867..293f05eb 100644 --- a/src/com/engine/organization/entity/personnelcard/FormItem.java +++ b/src/com/engine/organization/entity/personnelcard/FormItem.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.List; +import java.util.Map; /** * @author:dxfeng @@ -20,4 +21,6 @@ public class FormItem { private String id; private String title; private List items; + + private List> tables; } diff --git a/src/com/engine/organization/entity/personnelcard/UserCard.java b/src/com/engine/organization/entity/personnelcard/UserCard.java index c286cd50..da2773b6 100644 --- a/src/com/engine/organization/entity/personnelcard/UserCard.java +++ b/src/com/engine/organization/entity/personnelcard/UserCard.java @@ -27,10 +27,14 @@ public class UserCard { private String email; private String phone; private String belongTo; + private String accountType; private String status; - public String getBelongTo() { - return StringUtils.isBlank(belongTo) ? "主账号" : "次账号"; + public String getAccountType() { + if ("1".equals(accountType)) { + return "次账号"; + } + return "主账号"; } public String getStatus() { @@ -43,7 +47,7 @@ public class UserCard { public String getImage() { weaver.hrm.User user = new weaver.hrm.User(); user.setLanguage(LanguageService.getDefaultLang()); - if(StringUtils.isNotBlank(image)&& image.contains("/")){ + if (StringUtils.isNotBlank(image) && image.contains("/")) { return image; } return FieldDefinedValueUtil.getFieldValue(user, ExtendInfoPO.builder().controlType(6).browserType("1").build(), image); diff --git a/src/com/engine/organization/entity/personnelcard/po/CardButtonPO.java b/src/com/engine/organization/entity/personnelcard/po/CardButtonPO.java index 74482d8e..27fc72af 100644 --- a/src/com/engine/organization/entity/personnelcard/po/CardButtonPO.java +++ b/src/com/engine/organization/entity/personnelcard/po/CardButtonPO.java @@ -29,6 +29,10 @@ public class CardButtonPO { private String sysDefault; + private Integer showOrder; + + private Integer openType; + private Long creator; private int deleteType; diff --git a/src/com/engine/organization/entity/personnelcard/po/CusTreeFormPO.java b/src/com/engine/organization/entity/personnelcard/po/CusTreeFormPO.java new file mode 100644 index 00000000..edf4d639 --- /dev/null +++ b/src/com/engine/organization/entity/personnelcard/po/CusTreeFormPO.java @@ -0,0 +1,24 @@ +package com.engine.organization.entity.personnelcard.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2022/12/05 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CusTreeFormPO { + private String scope; + private String formLabel; + private Integer id; + private Integer parentId; + private String viewType; + private Integer scopeOrder; +} diff --git a/src/com/engine/organization/entity/personnelcard/po/HrmFieldGroupPO.java b/src/com/engine/organization/entity/personnelcard/po/HrmFieldGroupPO.java new file mode 100644 index 00000000..802ab4ce --- /dev/null +++ b/src/com/engine/organization/entity/personnelcard/po/HrmFieldGroupPO.java @@ -0,0 +1,24 @@ +package com.engine.organization.entity.personnelcard.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2022/12/05 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class HrmFieldGroupPO { + private Integer id; + private Integer groupLabel; + private Integer groupOrder; + private Integer groupType; + private Integer isShow; + private String labelName; +} diff --git a/src/com/engine/organization/entity/personnelcard/vo/CardAccessVO.java b/src/com/engine/organization/entity/personnelcard/vo/CardAccessVO.java index fd2b043a..cdefeff7 100644 --- a/src/com/engine/organization/entity/personnelcard/vo/CardAccessVO.java +++ b/src/com/engine/organization/entity/personnelcard/vo/CardAccessVO.java @@ -33,7 +33,7 @@ import lombok.NoArgsConstructor; orderby = "id", sortway = "asc", primarykey = "id", - tableType = WeaTableType.CHECKBOX + tableType = WeaTableType.NONE ) public class CardAccessVO { @@ -55,7 +55,7 @@ public class CardAccessVO { @OrganizationTableColumn(text = "所有上级可见", width = "15%", column = "all_superior") private Integer allSuperior; - @OrganizationTableColumn(text = "查看自定义", width = "15%", column = "custom",transmethod = "com.engine.organization.transmethod.SystemTransMethod.getRoleName") + @OrganizationTableColumn(text = "查看自定义", width = "30%", column = "custom",transmethod = "com.engine.organization.transmethod.SystemTransMethod.getRoleName") private String custom; } diff --git a/src/com/engine/organization/entity/resume/po/HrmFamilyInfoPO.java b/src/com/engine/organization/entity/resume/po/HrmFamilyInfoPO.java new file mode 100644 index 00000000..f70a854a --- /dev/null +++ b/src/com/engine/organization/entity/resume/po/HrmFamilyInfoPO.java @@ -0,0 +1,21 @@ +package com.engine.organization.entity.resume.po; + +import lombok.Data; + +/** + * @author:dxfeng + * @createTime: 2022/12/30 + * @version: 1.0 + */ +@Data +public class HrmFamilyInfoPO { + private Integer resourceId; + private String member; + private String title; + private String company; + private String jobTitle; + private String address; + private String uuid; + private String birthday; + private Integer whetherChildren; +} diff --git a/src/com/engine/organization/entity/resume/po/PersonnelResumeColumn.java b/src/com/engine/organization/entity/resume/po/PersonnelResumeColumn.java new file mode 100644 index 00000000..0f6cc06e --- /dev/null +++ b/src/com/engine/organization/entity/resume/po/PersonnelResumeColumn.java @@ -0,0 +1,22 @@ +package com.engine.organization.entity.resume.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2022/12/29 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PersonnelResumeColumn { + private String name; + private String value; + private Integer colspans; + private Integer rowspans; +} diff --git a/src/com/engine/organization/entity/resume/po/PersonnelResumePO.java b/src/com/engine/organization/entity/resume/po/PersonnelResumePO.java new file mode 100644 index 00000000..392a4e7b --- /dev/null +++ b/src/com/engine/organization/entity/resume/po/PersonnelResumePO.java @@ -0,0 +1,102 @@ +package com.engine.organization.entity.resume.po; + +import lombok.Data; +import net.coobird.thumbnailator.Thumbnails; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.IOUtils; +import weaver.file.ImageFileManager; +import weaver.general.GCONST; +import weaver.general.Util; + +import java.io.*; +import java.nio.file.Files; +import java.util.Base64; + +/** + * @author:dxfeng + * @createTime: 2022/12/29 + * @version: 1.0 + */ +@Data +public class PersonnelResumePO { + private Integer id; + private String lastName; + private String sex; + private String birthday; + // resourceImageId; + private String image; + private String imageId; + private String nativePlace; + // policy; + private String politics; + // departmentid; + private String department; + // maritalStatus; + private String marriage; + private String jobTitle; + private String companyStartDate; + private String workStartDate; + // certificatenum + private String idCard; + // homeaddress + private String address; + private String telephone; + private String email; + private String selfStatement; + + public String getSex() { + if ("1".equals(sex)) { + return "女"; + } + return "男"; + } + + public String getImage() { + if (StringUtils.isBlank(image)) { + return ""; + } + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(image)); + InputStream inputStream = manager.getInputStream(); + String imageStr = ""; + try { + String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + + manager.getImageFileName(); + File f = new File(outPutPath); + if (!f.exists()) { + String substring = outPutPath.substring(0, outPutPath.lastIndexOf(File.separator)); + File file = new File(substring); + if (file.mkdirs()) { + boolean newFile = f.createNewFile(); + if (!newFile) { + throw new IOException(outPutPath + "文件创建失败"); + } + } + } + Thumbnails.of(inputStream).forceSize(100, 120).toFile(f); + InputStream fileInputStream = Files.newInputStream(f.toPath()); + imageStr = "data:image/" + manager.getImageFileType() + ";base64," + Base64.getEncoder().encodeToString(IOUtils.toByteArray(fileInputStream)); + // 删除文件 + f.delete(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return imageStr; + } + + + public String getMarriage() { + if (StringUtils.isBlank(marriage)) { + return "未婚"; + } + switch (marriage) { + case "1": + return "已婚"; + case "2": + return "离异"; + case "0": + default: + return "未婚"; + } + } +} diff --git a/src/com/engine/organization/entity/resume/po/PersonnelResumeTable.java b/src/com/engine/organization/entity/resume/po/PersonnelResumeTable.java new file mode 100644 index 00000000..012e656f --- /dev/null +++ b/src/com/engine/organization/entity/resume/po/PersonnelResumeTable.java @@ -0,0 +1,23 @@ +package com.engine.organization.entity.resume.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author:dxfeng + * @createTime: 2022/12/29 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PersonnelResumeTable { + private String title; + private List columns; + private List> datas; +} diff --git a/src/com/engine/organization/entity/searchtree/SearchTree.java b/src/com/engine/organization/entity/searchtree/SearchTree.java index 1c05c440..849670cf 100644 --- a/src/com/engine/organization/entity/searchtree/SearchTree.java +++ b/src/com/engine/organization/entity/searchtree/SearchTree.java @@ -1,7 +1,6 @@ package com.engine.organization.entity.searchtree; import com.api.hrm.bean.TreeNode; -import lombok.Data; import java.util.Objects; @@ -11,7 +10,6 @@ import java.util.Objects; * @createTime: 2022/05/26 * @version: 1.0 */ -@Data public class SearchTree extends TreeNode { private String companyid; private String isVirtual; @@ -22,10 +20,78 @@ public class SearchTree extends TreeNode { private String parentComp; private Integer orderNum; + public String getCompanyid() { + return companyid; + } + + public void setCompanyid(String companyid) { + this.companyid = companyid; + } + + public String getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(String isVirtual) { + this.isVirtual = isVirtual; + } + + public String getPsubcompanyid() { + return psubcompanyid; + } + + public void setPsubcompanyid(String psubcompanyid) { + this.psubcompanyid = psubcompanyid; + } + + public String getDisplayType() { + return displayType; + } + + public void setDisplayType(String displayType) { + this.displayType = displayType; + } + + public boolean isCanceled() { + return isCanceled; + } + + public void setCanceled(boolean canceled) { + isCanceled = canceled; + } + + public String getRequestParams() { + return requestParams; + } + + public void setRequestParams(String requestParams) { + this.requestParams = requestParams; + } + + public String getParentComp() { + return parentComp; + } + + public void setParentComp(String parentComp) { + this.parentComp = parentComp; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } SearchTree that = (SearchTree) o; return isCanceled == that.isCanceled && Objects.equals(this.getId(), that.getId()) &&Objects.equals(companyid, that.companyid) && Objects.equals(isVirtual, that.isVirtual) && Objects.equals(psubcompanyid, that.psubcompanyid) && Objects.equals(displayType, that.displayType) && Objects.equals(requestParams, that.requestParams) && Objects.equals(parentComp, that.parentComp) && Objects.equals(orderNum, that.orderNum); } diff --git a/src/com/engine/organization/entity/searchtree/SearchTreeParams.java b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java index bc1b08f2..34018fbe 100644 --- a/src/com/engine/organization/entity/searchtree/SearchTreeParams.java +++ b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java @@ -1,6 +1,12 @@ package com.engine.organization.entity.searchtree; import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; /** * @description: @@ -26,5 +32,38 @@ public class SearchTreeParams { private String virtualCompanyid; private String isLoadSubDepartment; + // 人员筛选,添加分部、部门、岗位、人员搜索条件 + private String subcompanyid1; + private String departmentid; + private String jobId; + private String resourceId; + private boolean personnelScreening; + + public List getSubcompanyid1() { + if (StringUtils.isBlank(subcompanyid1)) { + return new ArrayList<>(); + } + return Arrays.stream(subcompanyid1.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + } + + public List getDepartmentid() { + if (StringUtils.isBlank(departmentid)) { + return new ArrayList<>(); + } + return Arrays.stream(departmentid.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + } + + public List getJobId() { + if (StringUtils.isBlank(jobId)) { + return new ArrayList<>(); + } + return Arrays.stream(jobId.split(",")).map(Long::parseLong).collect(Collectors.toList()); + } + public List getResourceId() { + if (StringUtils.isBlank(resourceId)) { + return new ArrayList<>(); + } + return Arrays.stream(resourceId.split(",")).map(Long::parseLong).collect(Collectors.toList()); + } } diff --git a/src/com/engine/organization/entity/staff/param/StaffSearchParam.java b/src/com/engine/organization/entity/staff/param/StaffSearchParam.java index 29e944ae..003231c5 100644 --- a/src/com/engine/organization/entity/staff/param/StaffSearchParam.java +++ b/src/com/engine/organization/entity/staff/param/StaffSearchParam.java @@ -27,13 +27,13 @@ public class StaffSearchParam { /** * 分部 */ - private Long compId; - private Long ecCompany; + private Integer compId; + private Integer ecCompany; /** * 部门 */ - private Long deptId; - private Long ecDepartment; + private Integer deptId; + private Integer ecDepartment; /** * 岗位 */ diff --git a/src/com/engine/organization/entity/staff/po/StaffPO.java b/src/com/engine/organization/entity/staff/po/StaffPO.java index 82db7e65..f1681d3c 100644 --- a/src/com/engine/organization/entity/staff/po/StaffPO.java +++ b/src/com/engine/organization/entity/staff/po/StaffPO.java @@ -29,13 +29,13 @@ public class StaffPO { /** * 分部 */ - private Long compId; - private Long ecCompany; + private Integer compId; + private Integer ecCompany; /** * 部门 */ - private Long deptId; - private Long ecDepartment; + private Integer deptId; + private Integer ecDepartment; /** * 岗位 */ diff --git a/src/com/engine/organization/entity/version/HrmDepartmentDto.java b/src/com/engine/organization/entity/version/HrmDepartmentDto.java new file mode 100644 index 00000000..39304088 --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmDepartmentDto.java @@ -0,0 +1,18 @@ +package com.engine.organization.entity.version; + +import lombok.Data; + +@Data +public class HrmDepartmentDto { + + int id; + String departmentmark; + String departmentcode; + String departmentname; + String subcompanyid1; + String supdepid; + String bmfzr; + String showorder; + String canceled; + +} diff --git a/src/com/engine/organization/entity/version/HrmDepartmentVersion.java b/src/com/engine/organization/entity/version/HrmDepartmentVersion.java new file mode 100644 index 00000000..402e3f90 --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmDepartmentVersion.java @@ -0,0 +1,28 @@ +package com.engine.organization.entity.version; + +import lombok.Data; + +import java.util.Date; + +@Data +public class HrmDepartmentVersion { + + int id; + Integer departmentId; + String departmentMark; + String departmentCode; + String departmentName; + Integer subCompanyId1; + Integer supDepId; + String bmfzr; + Integer showOrder; + Integer canceled; + String description; + String operator; + Double version; + Date operateTime; + + String subcompanyname; + String supDepName; + String bmfzrName; +} diff --git a/src/com/engine/organization/entity/version/HrmResourceDto.java b/src/com/engine/organization/entity/version/HrmResourceDto.java new file mode 100644 index 00000000..702b559d --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmResourceDto.java @@ -0,0 +1,25 @@ +package com.engine.organization.entity.version; + + +import lombok.Data; + +@Data +public class HrmResourceDto { + private Integer id; + + private Integer departmentid; + + private String dsporder; + + private Integer subcompanyid1; + + private Integer jobtitle; + + private String mobile; + + private String telephone; + + private String managerid; + + private String lastname; +} diff --git a/src/com/engine/organization/entity/version/HrmResourceVersion.java b/src/com/engine/organization/entity/version/HrmResourceVersion.java new file mode 100644 index 00000000..37e149af --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmResourceVersion.java @@ -0,0 +1,166 @@ +package com.engine.organization.entity.version; + +import lombok.Data; + +import java.util.Date; + +@Data +public class HrmResourceVersion { + + private Integer id; + + private Integer resourceid; + + private Date companystartdate; + + private Integer companyworkyear; + + private Date workstartdate; + + private Integer workyear; + + private Integer usekind; + + private Integer jobcall; + + private String accumfundaccount; + + private String birthplace; + + private String folk; + + private String residentphone; + + private String residentpostcode; + + private String extphone; + + private String managerstr; + + private Integer status; + + private String fax; + + private String islabouunion; + + private Integer weight; + + private String tempresidentnumber; + + private Date probationenddate; + + private Integer countryid; + + private Date passwdchgdate; + + private String lloginid; + + private Integer dsporder; + + private Integer passwordstate; + + private Integer accounttype; + + private Integer belongto; + + private String messagerurl; + + private String accountname; + + private String loginid; + + private String password; + + private String lastname; + + private String sex; + + private String birthday; + + private Integer nationality; + + private String maritalstatus; + + private String telephone; + + private String mobile; + + private String mobilecall; + + private String email; + + private Integer locationid; + + private String workroom; + + private String homeaddress; + + private String resourcetype; + + private Date startdate; + + private Date enddate; + + private Integer jobtitle; + + private String jobactivitydesc; + + private Integer joblevel; + + private Integer seclevel; + + private Integer departmentid; + + private Integer subcompanyid1; + + private Integer costcenterid; + + private Integer managerid; + + private Integer assistantid; + + private Integer bankid1; + + private String accountid1; + + private Integer resourceimageid; + + private String certificatenum; + + private String nativeplace; + + private Integer educationlevel; + + private Date bememberdate; + + private Date bepartydate; + + private String workcode; + + private String regresidentplace; + + private String healthinfo; + + private String residentplace; + + private String policy; + + private String degree; + + private String height; + + private String classification; + + private String description; + + private String operator; + + private Double version; + + private Date operateTime; + + String departmentname; + String subcompanyname; + String jobtitlename; + +} diff --git a/src/com/engine/organization/entity/version/HrmSubCompanyDto.java b/src/com/engine/organization/entity/version/HrmSubCompanyDto.java new file mode 100644 index 00000000..4168004e --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmSubCompanyDto.java @@ -0,0 +1,15 @@ +package com.engine.organization.entity.version; + +import lombok.Data; + +@Data +public class HrmSubCompanyDto { + + int id; + String subcompanydesc; + String subcompanycode; + String subcompanyname; + String supsubcomid; + String showorder; + String canceled; +} diff --git a/src/com/engine/organization/entity/version/HrmSubCompanyVersion.java b/src/com/engine/organization/entity/version/HrmSubCompanyVersion.java new file mode 100644 index 00000000..c9524ecc --- /dev/null +++ b/src/com/engine/organization/entity/version/HrmSubCompanyVersion.java @@ -0,0 +1,24 @@ +package com.engine.organization.entity.version; + +import lombok.Data; + +import java.util.Date; + +@Data +public class HrmSubCompanyVersion { + + Integer id; + Integer subComId; + String subCompanyDesc; + String subCompanyCode; + String subCompanyName; + Integer supSubComId; + Integer showOrder; + Integer canceled; + String description; + String operator; + Double version; + Date operateTime; + + String supSubComName; +} diff --git a/src/com/engine/organization/entity/version/VersionData.java b/src/com/engine/organization/entity/version/VersionData.java new file mode 100644 index 00000000..a6d31888 --- /dev/null +++ b/src/com/engine/organization/entity/version/VersionData.java @@ -0,0 +1,15 @@ +package com.engine.organization.entity.version; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class VersionData { + private String fieldId; + private String fieldValue; +} diff --git a/src/com/engine/organization/enums/HrmGroupEnum.java b/src/com/engine/organization/enums/HrmGroupEnum.java new file mode 100644 index 00000000..f4280465 --- /dev/null +++ b/src/com/engine/organization/enums/HrmGroupEnum.java @@ -0,0 +1,20 @@ +package com.engine.organization.enums; + +/** + * @author:dxfeng + * @createTime: 2022/12/06 + * @version: 1.0 + */ +public enum HrmGroupEnum { + HRM_BASIC(-1), HRM_PERSONAL(1), HRM_WORK(3), COMPANY(4), DEPARTMENT(5); + + HrmGroupEnum(Integer groupType) { + this.groupType = groupType; + } + + private Integer groupType; + + public Integer getGroupType() { + return groupType; + } +} diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 1f636132..d139b49d 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.List; -import java.util.Map; /** * @description: @@ -19,7 +18,9 @@ public interface CompMapper { * * @return */ - List list(@Param("orderSql") String orderSql); + List listAll(@Param("orderSql") String orderSql); + + List listByFilter(@Param("CompanyPO") CompPO CompanyPO, @Param("orderSql") String orderSql); /** * 查询所有被引用的ID @@ -30,48 +31,13 @@ public interface CompMapper { List listUsedIds(); - List hasSubs(); - - List hasDetachSubs(@Param("companyIds") Collection companyIds); - - /** - * 根据搜索条件查询数据 - * - * @return - */ - List listByFilter(@Param("compPO") CompPO compPO, @Param("orderSql") String orderSql); - - /** - * 获取顶级数据 - * - * @return - */ - List listParent(); - /** * 获取子层级数据 * * @param ids * @return */ - List listChild(@Param("ids") Collection ids); - - /** - * 获取当前ID的子元素 - * - * @param pid - * @return - */ - List listChildByPID(@Param("pid") String pid); - - - /** - * 获取当前ID的子元素个数 - * - * @param pid - * @return - */ - int countChildByPID(@Param("pid") long pid); + List listChild(@Param("ids") Collection ids); /** * 根据ID查询数据 @@ -79,33 +45,7 @@ public interface CompMapper { * @param id * @return */ - CompPO listById(@Param("id") Long id); - - /** - * 根据UUID查询数据 - * - * @param uuid - * @return - */ - CompPO getCompanyByUUID(@Param("uuid") String uuid); - - - /** - * 根据No查询数据 - * - * @param compNo - * @return - */ - List listByNo(@Param("compNo") String compNo); - - - /** - * 浏览按钮展示数据查询 - * - * @param ids - * @return - */ - List> listCompsByIds(@Param("ids") Collection ids); + CompPO listById(@Param("id") Integer id); /** * 根据ID批量查询数据 @@ -115,38 +55,25 @@ public interface CompMapper { */ List getCompsByIds(@Param("ids") Collection ids); - /** - * 保存公司/分部基础信息 + * 获取顶级数据 * - * @param compPO * @return */ - int insertIgnoreNull(CompPO compPO); + List listParent(); + List hasSubs(); - /** - * 更新主表内容 - * - * @param compPO - * @return - */ - int updateBaseComp(CompPO compPO); + List hasDetachSubs(@Param("companyIds") Collection companyIds); /** - * 更新禁用标记 + * 根据名称和上级查找ID * - * @param compPO + * @param subCompanyName + * @param supSubComId * @return */ - int updateForbiddenTagById(CompPO compPO); - - /** - * 批量删除 - * - * @param ids - */ - int deleteByIds(@Param("ids") Collection ids); + Integer getIdByNameAndPid(@Param("subCompanyName") String subCompanyName, @Param("supSubComId") Integer supSubComId); /** * 获取最大排序 @@ -155,27 +82,5 @@ public interface CompMapper { */ 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 getCompanyIdsByUuid(@Param("uuids") List uuids); - + Integer getIdBySubCompanyCode(@Param("subCompanyCode") String subCompanyCode); } diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 63e2fcf2..75381ec0 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -3,23 +3,18 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + @@ -27,524 +22,229 @@ 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.subCompanyName + , t.subCompanyDesc + , t.companyId + , t.supSubComId + , t.url + , t.canceled + , t.subCompanyCode + , t.outKey + , t.limitUsers , t.uuid + , t.showOrder + , t.showOrderOfTree - - and ifnull(parent_company,'0')='0' - - - - and isnull(parent_company,'0')='0' - - - - and NVL(parent_company,'0')='0' - - - - and ifnull(parent_company,0) = - #{parentCompany} - - - - and isnull(parent_company,0) = - #{parentCompany} - - - - and NVL(parent_company,0) = - #{parentCompany} - - - - INSERT INTO jcl_org_comp - - - creator, - - - delete_type, - - - create_time, - - - update_time, - - - comp_no, - - - comp_name, - - - comp_name_short, - - - parent_company, - - - ec_company, - - - org_code, - - - industry, - - - comp_principal, - - - description, - - forbidden_tag, - - show_order, - - - - - #{creator}, - - - #{deleteType}, - - - #{createTime}, - - - #{updateTime}, - - - #{compNo}, - - - #{compName}, - - - #{compNameShort}, - - - #{parentCompany}, - - - #{ecCompany}, - - - #{orgCode}, - - - #{industry}, - - - #{compPrincipal}, - - - #{description}, - - 0, - - #{showOrder}, - - - - - - - select JCL_ORG_COMP_ID.currval from dual - - INSERT INTO jcl_org_comp - - - creator, - - - delete_type, - - - create_time, - - - update_time, - - - comp_no, - - - comp_name, - - - comp_name_short, - - - parent_company, - - - ec_company, - - - org_code, - - - industry, - - - comp_principal, - - - description, - - forbidden_tag, - - show_order, - - - - - #{creator}, - - - #{deleteType}, - - - #{createTime}, - - - #{updateTime}, - - - #{compNo}, - - - #{compName}, - - - #{compNameShort}, - - - #{parentCompany}, - - - #{ecCompany}, - - - #{orgCode}, - - - #{industry}, - - - #{compPrincipal}, - - - #{description}, - - 0, - - #{showOrder}, - - - - - SELECT FROM - jcl_org_comp t - WHERE t.delete_type = 0 order by ${orderSql} - - - - - - - - - - - - - - - - + - SELECT FROM - jcl_org_comp t - WHERE t.delete_type = 0 - and uuid = #{uuid} + hrmsubcompany t + WHERE supsubcomid IN + + #{id} + - + SELECT + + FROM + hrmsubcompany t + WHERE id = #{id} - select - from from jcl_org_comp t - where t.delete_type = 0 - AND comp_no = #{companyNo} + from hrmsubcompany t + WHERE id IN + + #{id} + + + + - + - - update jcl_org_comp - - forbidden_tag=#{forbiddenTag}, - - WHERE id = #{id} AND delete_type = 0 - + - - UPDATE jcl_org_comp - SET delete_type = 1 - WHERE delete_type = 0 - AND id IN - - #{id} - - + + - - update jcl_org_comp - - 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}, - - WHERE id = #{id} AND delete_type = 0 - - - and t.comp_no like CONCAT('%',#{compPO.compNo},'%') - - - and t.comp_name like CONCAT('%',#{compPO.compName},'%') + + and t.subCompanyCode like CONCAT('%',#{CompanyPO.subCompanyCode},'%') - - and t.comp_name_short like CONCAT('%',#{compPO.compNameShort},'%') + + and t.subCompanyDesc like CONCAT('%',#{CompanyPO.subCompanyDesc},'%') - - and t.org_code like CONCAT('%',#{compPO.orgCode},'%') + + and t.subCompanyName like CONCAT('%',#{CompanyPO.subCompanyName},'%') - - and t.comp_no like '%'||#{compPO.compNo}||'%' + + and t.subCompanyCode like '%'||#{CompanyPO.subCompanyCode}||'%' - - and t.comp_name like '%'||#{compPO.compName}||'%' + + and t.subCompanyDesc like '%'||#{CompanyPO.subCompanyDesc}||'%' - - and t.comp_name_short like '%'||#{compPO.compNameShort}||'%' + + and t.subCompanyName like '%'||#{CompanyPO.subCompanyName}||'%' - - and t.org_code like '%'||#{compPO.orgCode}||'%' + + + + and t.subCompanyCode like '%'||#{CompanyPO.subCompanyCode}||'%' + + + and t.subCompanyDesc like '%'||#{CompanyPO.subCompanyDesc}||'%' + + + and t.subCompanyName like '%'||#{CompanyPO.subCompanyName}||'%' - - and t.comp_no like '%'+#{compPO.compNo}+'%' - - - and t.comp_name like '%'+#{compPO.compName}+'%' + + and t.subCompanyCode like '%'+#{CompanyPO.subCompanyCode}+'%' - - and t.comp_name_short like '%'+#{compPO.compNameShort}+'%' + + and t.subCompanyDesc like '%'+#{CompanyPO.subCompanyDesc}+'%' - - and t.org_code like '%'+#{compPO.orgCode}+'%' + + and t.subCompanyName like '%'+#{CompanyPO.subCompanyName}+'%' + + and ifnull(canceled,0)=0 + + + and nvl(canceled,0)=0 + + + and isnull(canceled,0)=0 + + + and COALESCE(canceled,'0')='0' + + + + and ifnull(canceled,0)= + #{CompanyPO.canceled} + + + and nvl(canceled,0)= + #{CompanyPO.canceled} + + + and isnull(canceled,0)= + #{CompanyPO.canceled} + + + and COALESCE(canceled,'0')= + #{CompanyPO.canceled} + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index 4e205c53..8efd277e 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -14,28 +14,22 @@ import java.util.Map; * @Version V1.0 **/ public interface DepartmentMapper { - - List getDeptListByCompId(@Param("parentComp") Integer parentComp); - - List getDeptListByPId(@Param("PId") Long PId); - - int countChildByPID(@Param("pid") Long pid); - + List getDeptListByPId(@Param("PId") Integer PId); /** * 查询所有数据 * * @return */ - List list(@Param("orderSql") String orderSql); + List listAll(@Param("orderSql") String orderSql); /** * 根据No查询数据 * - * @param deptNo + * @param departmentCode * @return */ - List listByNo(@Param("deptNo") String deptNo); + List listByNo(@Param("departmentCode") String departmentCode); /** * 根据搜索条件查询数据 @@ -60,15 +54,7 @@ public interface DepartmentMapper { * @param id * @return */ - DepartmentPO getDeptById(@Param("id") Long id); - - /** - * 根据UUID查询数据 - * - * @param uuid - * @return - */ - DepartmentPO getDepartmentByUUID(@Param("uuid") String uuid); + DepartmentPO getDeptById(@Param("id") Integer id); /** * 根据ID查询名称 @@ -76,38 +62,7 @@ public interface DepartmentMapper { * @param id * @return */ - String getDeptNameById(@Param("id") Long id); - - /** - * 添加数据 - * - * @param departmentPO - * @return - */ - int insertIgnoreNull(DepartmentPO departmentPO); - - /** - * 更新主表内容 - * - * @param departmentPO - * @return - */ - int updateBaseDept(DepartmentPO departmentPO); - - /** - * 更新禁用标记 - * - * @param departmentPO - * @return - */ - int updateForbiddenTagById(DepartmentPO departmentPO); - - /** - * 批量删除 - * - * @param ids - */ - int deleteByIds(@Param("ids") Collection ids); + String getDeptNameById(@Param("id") Integer id); /** * 查询所有被引用的ID @@ -121,21 +76,26 @@ public interface DepartmentMapper { * * @return */ - Integer getMaxShowOrder(); + Double getMaxShowOrder(); /** * 根据名称、上级 查询部门元素 * * @param departmentName - * @param parentCompany - * @param parentDepartment + * @param subCompanyId1 + * @param supDepId * @return */ - Long getIdByNameAndPid(@Param("departmentName") String departmentName, @Param("parentCompany") Long parentCompany, @Param("parentDepartment") Long parentDepartment); + Integer getIdByNameAndPid(@Param("departmentName") String departmentName, @Param("subCompanyId1") Integer subCompanyId1, @Param("supDepId") Integer supDepId); - int checkRepeatNo(@Param("departmentNo") String departmentNo, @Param("id") Long id); + int checkRepeatNo(@Param("departmentCode") String departmentCode, @Param("id") Long id); List hasSubs(); - int countUsedInJob(@Param("departmentId") Long departmentId); + int countUsedInJob(@Param("supDepId") Long supDepId); + + String getIdByDepartmentCode(@Param("departmentCode") String departmentCode); + + String getDepartmentPrincipal(@Param("deptId") Integer deptId); + } diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index 018fd1a2..a21e4c44 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -3,22 +3,15 @@ - - - - - - - - - - - - - - - - + + + + + + + + + @@ -28,39 +21,28 @@ . id , - t.dept_no, - t.dept_name, - t.dept_name_short, - t.parent_comp, - t.ec_company, - t.parent_dept, - t.ec_department, - t.dept_principal, - t.show_order, - t.description, - t.forbidden_tag, + t.departmentMark, + t.departmentName, + t.subCompanyId1, + t.supDepId, + t.allSupDepId, + t.canceled, + t.departmentCode, + t.coadjutant, + t.showOrder, t.uuid - - @@ -68,437 +50,168 @@ resultMap="BaseResultMap"> select - from jcl_org_dept t - where delete_type = 0 + from hrmdepartment t + where 1=1 - - and t.ec_company = #{departmentPO.ecCompany} - - - and t.ec_department = #{departmentPO.ecDepartment} - - - and t.parent_comp = #{departmentPO.parentComp} - - - and t.parent_dept = #{departmentPO.parentDept} + + and t.subCompanyId1 = #{departmentPO.subCompanyId1} - - and t.dept_principal = #{departmentPO.deptPrincipal} + + and t.supDepId = #{departmentPO.supDepId} - - and t.show_order = #{departmentPO.showOrder} - - - and t.forbidden_tag = #{departmentPO.forbiddenTag} + + and t.id = #{departmentPO.departmentId} + order by ${orderSql} - select - from jcl_org_dept t - where delete_type = 0 - and id = #{id} + from hrmdepartment t + where id = #{id} - SELECT - FROM jcl_org_dept t - WHERE t.delete_type = 0 order by ${orderSql} + FROM hrmdepartment t order by ${orderSql} - - + select max(showOrder) + from hrmdepartment - select id - from jcl_org_dept - where delete_type = 0 and dept_name = #{departmentName} - and parent_comp = #{parentCompany} - - - + + - - and ifnull(parent_dept,0) = - #{parentDepartment} - - - - and isnull(parent_dept,0) = - #{parentDepartment} - - - - and NVL(parent_dept,0) = - #{parentDepartment} - - - - INSERT INTO jcl_org_dept - - - creator, - - - delete_type, - - - create_time, - - - update_time, - - - - dept_no, - - - dept_name, - - - dept_name_short, - - - parent_comp, - - - ec_company, - - - parent_dept, - - - ec_department, - - - dept_principal, - - - show_order, - - - description, - - - uuid, - - forbidden_tag, - - - - #{creator}, - - - #{deleteType}, - - - #{createTime}, - - - #{updateTime}, - - - #{deptNo}, - - - #{deptName}, - - - #{deptNameShort}, - - - #{parentComp}, - - - #{ecCompany}, - - - #{parentDept}, - - - #{ecDepartment}, - - - #{deptPrincipal}, - - - #{showOrder}, - - - #{description}, - - - #{uuid}, - - 0, - - - - - select JCL_ORG_DEPT_ID.currval from dual - - INSERT INTO jcl_org_dept - - - creator, - - - delete_type, - - - create_time, - - - update_time, - - - - dept_no, - - - dept_name, - - - dept_name_short, - - - parent_comp, - - - ec_company, - - - parent_dept, - - - ec_department, - - - dept_principal, - - - show_order, - - - description, - - - uuid, - - forbidden_tag, - - - - #{creator}, - - - #{deleteType}, - - - #{createTime}, - - - #{updateTime}, - - - #{deptNo}, - - - #{deptName}, - - - #{deptNameShort}, - - - #{parentComp}, - - - #{ecCompany}, - - - #{parentDept}, - - - #{ecDepartment}, - - - #{deptPrincipal}, - - - #{showOrder}, - - - #{description}, - - - #{uuid}, - - 0, - - - - - update jcl_org_dept - - creator=#{creator}, - update_time=#{updateTime}, - dept_name=#{deptName}, - dept_name_short=#{deptNameShort}, - parent_comp=#{parentComp}, - ec_company=#{ecCompany}, - parent_dept=#{parentDept}, - ec_department=#{ecDepartment}, - dept_principal=#{deptPrincipal}, - show_order=#{showOrder}, - description=#{description}, - - forbidden_tag=#{forbiddenTag}, - - - WHERE id = #{id} AND delete_type = 0 - - - - update jcl_org_dept - - forbidden_tag=#{forbiddenTag}, - - WHERE id = #{id} AND delete_type = 0 - - - - UPDATE jcl_org_dept - SET delete_type = 1 - WHERE delete_type = 0 - AND id IN - - #{id} - - - - - and t.dept_no like CONCAT('%',#{departmentPO.deptNo},'%') + + and t.departmentCode like CONCAT('%',#{departmentPO.departmentCode},'%') - - and t.dept_name like CONCAT('%',#{departmentPO.deptName},'%') - - - and t.dept_name_short like CONCAT('%',#{departmentPO.deptNameShort},'%') + + and t.departmentName like CONCAT('%',#{departmentPO.departmentName},'%') - - and t.dept_no like '%'||#{departmentPO.deptNo}||'%' + + and t.departmentCode like '%'||#{departmentPO.departmentCode}||'%' - - and t.dept_name like '%'||#{departmentPO.deptName}||'%' + + and t.departmentName like '%'||#{departmentPO.departmentName}||'%' - - and t.dept_name_short like '%'||#{departmentPO.deptNameShort}||'%' + + + + and t.departmentCode like '%'||#{departmentPO.departmentCode}||'%' + + + and t.departmentName like '%'||#{departmentPO.departmentName}||'%' - - and t.dept_no like '%'+#{departmentPO.deptNo}+'%' - - - and t.dept_name like '%'+#{departmentPO.deptName}+'%' + + and t.departmentCode like '%'+#{departmentPO.departmentCode}+'%' - - and t.dept_name_short like '%'+#{departmentPO.deptNameShort}+'%' + + and t.departmentName like '%'+#{departmentPO.departmentName}+'%' - - and ifnull(parent_dept,'0')='0' + + + and ifnull(canceled,0)= #{departmentPO.canceled} + - - - and isnull(parent_dept,'0')='0' + + + and nvl(canceled,0)= #{departmentPO.canceled} + - - - and NVL(parent_dept,'0')='0' + + + and isnull(canceled,0)= #{departmentPO.canceled} + + + + + and COALESCE(canceled,'0')= #{departmentPO.canceled} + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.java b/src/com/engine/organization/mapper/employee/EmployeeMapper.java index 0419a3cf..158d2ee4 100644 --- a/src/com/engine/organization/mapper/employee/EmployeeMapper.java +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.java @@ -15,9 +15,12 @@ import java.util.Map; **/ public interface EmployeeMapper { - String getEmployeeNameById(@Param("employeeId") Long id); + List getEmployeeNameById(@Param("ids") Collection ids); List getResourceIds(@Param("lastName") String lastName); - List> getBrowserDatas(@Param("ids") Collection ids); + List getResourceIdsByName(@Param("lastName") String lastName); + + + List> getBrowserDatas(@Param("ids") Collection ids); } diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.xml b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml index 8419c565..0e55f4d5 100644 --- a/src/com/engine/organization/mapper/employee/EmployeeMapper.xml +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml @@ -12,6 +12,11 @@ AND t.lastname like '%'||#{lastName}||'%' + + + AND t.lastname like '%'||#{lastName}||'%' + + AND t.lastname like '%'+#{lastName}+'%' @@ -21,7 +26,10 @@ @@ -43,5 +51,10 @@ #{id} + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/extend/ExtDTMapper.java b/src/com/engine/organization/mapper/extend/ExtDTMapper.java index 47737dc8..d0b865ba 100644 --- a/src/com/engine/organization/mapper/extend/ExtDTMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtDTMapper.java @@ -37,5 +37,5 @@ public interface ExtDTMapper { * @param mainId * @return */ - int deleteByMainID(@Param("tableName") String tableName, @Param("mainId") long mainId); + int deleteByMainID(@Param("tableName") String tableName, @Param("mainId") long mainId, @Param("groupId") Long groupId); } diff --git a/src/com/engine/organization/mapper/extend/ExtDTMapper.xml b/src/com/engine/organization/mapper/extend/ExtDTMapper.xml index d9ef99a7..422e31ba 100644 --- a/src/com/engine/organization/mapper/extend/ExtDTMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtDTMapper.xml @@ -19,6 +19,9 @@ delete from ${tableName} where mainid = #{mainId} + + and group_id = #{groupId} + - select max(id) - from jcl_org_hrmresource - - - - - - - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java index 4e6353a6..ca16794d 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java @@ -19,7 +19,7 @@ public interface SystemDataMapper { String getScCompanyNameById(@Param("companyId") String companyId); - List> getBrowserDatas(@Param("ids") Collection ids); + List> getBrowserDatas(@Param("ids") Collection ids); String getScDepartmentNameById(@Param("departmentId") String departmentId); @@ -31,7 +31,7 @@ public interface SystemDataMapper { RecordInfo getHrmJobTitleByName(@Param("name") String name); - List getHrmResourceIds(@Param("departmentId") Long departmentId, @Param("jobTitle") String jobTitle); + List getHrmResourceIds(@Param("departmentId") Integer departmentId, @Param("jobTitle") String jobTitle); List getHrmResourceIdsByDept(@Param("departmentId") String departmentId); @@ -59,6 +59,9 @@ public interface SystemDataMapper { Long getHrmResourceMaxId(); - List getBatchUuidByIds(@Param("tableName") String tableName,@Param("ecIds") List ecIds); + List getBatchUuidByIds(@Param("tableName") String tableName, @Param("ecIds") List ecIds); + List getHrmFieldsByScopeId(@Param("scopeId") String scopeId); + + List getJobTitleIds(@Param("jobActivityId") String jobActivityId, @Param("jobGroupId") String jobGroupId); } diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml index bf7783c0..496434fe 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml @@ -12,6 +12,8 @@ + + @@ -100,7 +102,7 @@ + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/jclimport/ImportMapper.java b/src/com/engine/organization/mapper/jclimport/ImportMapper.java new file mode 100644 index 00000000..e036ca3d --- /dev/null +++ b/src/com/engine/organization/mapper/jclimport/ImportMapper.java @@ -0,0 +1,20 @@ +package com.engine.organization.mapper.jclimport; + +import com.engine.organization.entity.jclimport.po.HrmFormFieldPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author:dxfeng + * @createTime: 2022/12/06 + * @version: 1.0 + */ +public interface ImportMapper { + + List getImportFields(@Param("languageId") Integer languageId, @Param("groupType") Integer groupType); + + List getImportFieldInfo(@Param("languageId") Integer languageId, @Param("groupType") Integer groupType, @Param("labelName") String labelName); + + List getResourceExceptedFields(); +} diff --git a/src/com/engine/organization/mapper/jclimport/ImportMapper.xml b/src/com/engine/organization/mapper/jclimport/ImportMapper.xml new file mode 100644 index 00000000..94ac3e18 --- /dev/null +++ b/src/com/engine/organization/mapper/jclimport/ImportMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java index 8ed57b8e..9d8e7a9f 100644 --- a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java +++ b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java @@ -4,6 +4,7 @@ import com.engine.organization.entity.map.JclOrgMap; import org.apache.ibatis.annotations.Param; import java.sql.Date; +import java.util.List; /** * @author:dxfeng @@ -26,4 +27,25 @@ public interface JclOrgMapper { JclOrgMap getSumPlanAndJobByFParentId(@Param("currentDate") Date currentDate, @Param("fparentid") String fparentid); int updateMapById(@Param("id") Integer id,@Param("fplan") Integer fplan,@Param("fonjob") Integer fonjob,@Param("currentDate") Date currentDate); + + List getJclOrgMapByType(@Param("fType") String fType, @Param("currentDate") Date currentDate); + + int deleteAllMap(@Param("currentDate") Date currentDate); + + int updateAllMap(@Param("currentDate") Date currentDate, @Param("yesterday") Date yesterday); + + int insertResToMap(@Param("level") String level, @Param("grade") String grade); + + int insertJobToMap(); + + int insertDeptToMap(@Param("level") String level, @Param("grade") String grade); + + int insertSubComToMap(); + + int insertComToMap(); + + int deleteJobNull(@Param("currentDate") Date currentDate); + + JclOrgMap getResInfo(@Param("level") String level, @Param("grade") String grade, @Param("id") String id); + } diff --git a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml index e72f55a3..6d46360c 100644 --- a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml +++ b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml @@ -59,11 +59,352 @@ update jcl_org_map - fplan=#{fplan}, - fonjob=#{fonjob}, + + fplan=#{fplan}, + + + fonjob=#{fonjob}, + where id=#{id} AND FDATEBEGIN <= #{currentDate} AND FDATEEND >= #{currentDate} + + + + + delete from jcl_org_map where fdatebegin = #{currentDate} + + + + update jcl_org_map + + fdateend=#{yesterday}, + + where fdateend > #{currentDate} + + + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg, + fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fisvitual,fdatebegin,fdateend) + select a.id+300000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl, + c.id,c.jobtitlename,e.level_name,f.grade_name, isnull( b.id, '' ) +200000000,b.id, + 0,convert(varchar(100),getDate(),23),'2099-12-31' + from hrmresource a + left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle and a.subcompanyid1=b.ec_company and a.departmentid=b.ec_department + left join HrmJobTitles c on b.ec_jobTitle = c.id + left join cus_fielddata d on a.id = d.id and d.scope='HrmCustomFieldByInfoType' and d.scopeid=3 + left join jcl_org_level e on d.${level}=e.id + left join jcl_org_grade f on d.${grade}=f.id + where a.status < 4 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg, + fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fisvitual,fdatebegin,fdateend) + select a.id+300000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl, + c.id,c.jobtitlename,e.level_name,f.grade_name, ifnull( b.id, '' ) +200000000,b.id, + 0,NOW(),'2099-12-31' + from hrmresource a + left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle and a.subcompanyid1=b.ec_company and a.departmentid=b.ec_department + left join HrmJobTitles c on b.ec_jobTitle = c.id + left join cus_fielddata d on a.id = d.id and d.scope='HrmCustomFieldByInfoType' and d.scopeid=3 + left join jcl_org_level e on d.${level}=e.id + left join jcl_org_grade f on d.${grade}=f.id + where a.status < 4 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg, + fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fisvitual,fdatebegin,fdateend) + select a.id+300000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl, + c.id,c.jobtitlename,e.level_name,f.grade_name, COALESCE( b.id, 0 ) +200000000,b.id, + 0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31' + from hrmresource a + left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle and a.subcompanyid1=b.ec_company and a.departmentid=b.ec_department + left join HrmJobTitles c on b.ec_jobTitle = c.id + left join cus_fielddata d on a.id = d.id and d.scope='HrmCustomFieldByInfoType' and d.scopeid=3 + left join jcl_org_level e on NULLIF(d.${level},'')=e.id + left join jcl_org_grade f on NULLIF(d.${grade},'')=f.id + where a.status < 4 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg, + fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fisvitual,fdatebegin,fdateend) + select a.id+300000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl, + c.id,c.jobtitlename,e.level_name,f.grade_name, nvl( b.id, '' ) +200000000,b.id, + 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') + from hrmresource a + left join jcl_org_job b ON a.JOBTITLE = b.ec_jobTitle and a.subcompanyid1=b.ec_company and a.departmentid=b.ec_department + left join HrmJobTitles c on b.ec_jobTitle = c.id + left join cus_fielddata d on a.id = d.id and d.scope='HrmCustomFieldByInfoType' and d.scopeid=3 + left join jcl_org_level e on ${level}=e.id + left join jcl_org_grade f on ${grade}=f.id + where a.status < 4 + + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname, + fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+200000000,3,a.id,g.uuid,0,'行政维度',a.job_no,g.jobtitlename, + ec_department+100000000, + ec_department, + isnull(e.fcnt,0),isnull(f.fcnt,0),0,convert(varchar(100),getDate(),23),'2099-12-31' + from JCL_ORG_job as a + left join (select job_id,sum(isnull(staff_num,0)) fcnt from JCL_ORG_STAFF + where plan_id in (select id from JCL_ORG_STAFFPLAN + where time_start <= convert(varchar(100),getDate(),23) and time_end > convert(varchar(100),getDate(),23)) and delete_type=0 + group by job_id) e on a.id=e.job_id + left join ( select c.id,count(1) fcnt from hrmresource a + left join Hrmjobtitles b on a.jobtitle=b.id and a.status<4 + left join jcl_org_job c on b.id=c.ec_jobtitle and a.subcompanyid1=c.ec_company and a.departmentid=c.ec_department + group by c.id) f + on f.id=a.id + left join HrmJobTitles g on a.ec_jobTitle = g.id + where isnull(a.delete_type,0) <> 1 and isnull(a.forbidden_tag,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname, + fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+200000000,3,a.id,g.uuid,0,'行政维度',a.job_no,g.jobtitlename, + ec_department+100000000, + ec_department, + ifnull(e.fcnt,0),ifnull(f.fcnt,0),0,NOW(),'2099-12-31' + from JCL_ORG_job as a + left join (select job_id,sum(ifnull(staff_num,0)) fcnt from JCL_ORG_STAFF + where plan_id in (select id from JCL_ORG_STAFFPLAN + where time_start<=NOW() and time_end > NOW() and delete_type=0) + group by job_id) e on a.id=e.job_id + left join ( select c.id,count(1) fcnt from hrmresource a + left join Hrmjobtitles b on a.jobtitle=b.id and a.status<4 + left join jcl_org_job c on b.id=c.ec_jobtitle and a.subcompanyid1=c.ec_company and a.departmentid=c.ec_department + group by c.id) f + on f.id=a.id + left join HrmJobTitles g on a.ec_jobTitle = g.id + where ifnull(a.delete_type,0) <> 1 and ifnull(a.forbidden_tag,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname, + fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+200000000,3,a.id,g.uuid,0,'行政维度',a.job_no,g.jobtitlename, + ec_department+100000000, + ec_department, + COALESCE(e.fcnt,0),COALESCE(f.fcnt,0),0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31' + from JCL_ORG_job as a + left join (select job_id,sum(COALESCE(staff_num,0)) fcnt from JCL_ORG_STAFF + where plan_id in (select id from JCL_ORG_STAFFPLAN + where time_start<=TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd') and time_end > TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd') and delete_type=0) + group by job_id) e on a.id=e.job_id + left join ( select c.id,count(1) fcnt from hrmresource a + left join Hrmjobtitles b on a.jobtitle=b.id and a.status<4 + left join jcl_org_job c on b.id=c.ec_jobtitle and a.subcompanyid1=c.ec_company and a.departmentid=c.ec_department + group by c.id) f + on f.id=a.id + left join HrmJobTitles g on a.ec_jobTitle = g.id + where COALESCE(a.delete_type,0) <> 1 and COALESCE(a.forbidden_tag,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname, + fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+200000000,3,a.id,g.uuid,0,'行政维度',a.job_no,g.jobtitlename, + ec_department+100000000, + ec_department, + nvl(e.fcnt,0),nvl(f.fcnt,0),0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') + from JCL_ORG_job a + left join (select job_id,sum(nvl(staff_num,0)) fcnt from JCL_ORG_STAFF + where plan_id in (select id from JCL_ORG_STAFFPLAN + where time_start<=TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd') and time_end>TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd')) and delete_type=0 + group by job_id) e on a.id=e.job_id + left join ( select c.id,count(1) fcnt from hrmresource a + left join Hrmjobtitles b on a.jobtitle=b.id and a.status<4 + left join jcl_org_job c on b.id=c.ec_jobtitle and a.subcompanyid1=c.ec_company and a.departmentid=c.ec_department + group by c.id) f + on f.id=a.id + left join HrmJobTitles g on a.ec_jobTitle = g.id + where nvl(a.delete_type,0) <> 1 and nvl(a.forbidden_tag,0) <> 1 + + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,cast(b.BMFZR as varchar(10)),c.messagerurl, + c.lastname,c.jobtitle,d.jobtitlemark,f.level_name,g.grade_name, + (case isnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end), + (case isnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end), + 0,0,0,convert(varchar(100),getDate(),23),'2099-12-31' + from + HrmDepartment as a + left join hrmdepartmentdefined as b on a.id=b.deptid + left join hrmresource as c on cast(b.BMFZR as varchar(10))=cast(c.ID as varchar(10)) + left join hrmjobtitles as d on c.JOBTITLE=d.id + left join cus_fielddata e on c.id = e.id and e.scope='HrmCustomFieldByInfoType' and e.scopeid=3 + left join jcl_org_level f on e.${level}=f.id + left join jcl_org_grade g on e.${grade}=g.id + where isnull(a.canceled,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,b.BMFZR,c.messagerurl, + c.lastname,c.jobtitle,d.jobtitlemark,f.level_name,g.grade_name, + (case ifnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end), + (case ifnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end), + 0,0,0,NOW(),'2099-12-31' + from + HrmDepartment as a + left join hrmdepartmentdefined as b on a.id=b.deptid + left join hrmresource as c on b.BMFZR=c.ID + left join hrmjobtitles as d on c.JOBTITLE=d.id + left join cus_fielddata e on c.id = e.id and e.scope='HrmCustomFieldByInfoType' and e.scopeid=3 + left join jcl_org_level f on e.${level}=f.id + left join jcl_org_grade g on e.${grade}=g.id + where ifnull(a.canceled,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,b.BMFZR,c.messagerurl, + c.lastname,c.jobtitle,d.jobtitlemark,f.level_name,g.grade_name, + (case COALESCE(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end), + (case COALESCE(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end), + 0,0,0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31' + from + HrmDepartment as a + left join hrmdepartmentdefined as b on a.id=b.deptid + left join hrmresource as c on NULLIF(b.BMFZR,'')=c.ID + left join hrmjobtitles as d on c.JOBTITLE=d.id + left join cus_fielddata e on c.id = e.id and e.scope='HrmCustomFieldByInfoType' and e.scopeid=3 + left join jcl_org_level f on NULLIF(e.${level},'')=f.id + left join jcl_org_grade g on NULLIF(e.${grade},'')=g.id + where COALESCE(a.canceled,'0') <> '1' + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,to_char(b.BMFZR),c.messagerurl, + c.lastname,c.jobtitle,d.jobtitlemark,f.level_name,g.grade_name, + (case nvl(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end), + (case nvl(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end), + 0,0,0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') + from HrmDepartment a + left join hrmdepartmentdefined b on a.id=b.deptid + left join hrmresource c on to_char(b.BMFZR)=to_char(c.ID) + left join hrmjobtitles d on c.JOBTITLE=d.id + left join cus_fielddata e on c.id = e.id and e.scope='HrmCustomFieldByInfoType' and e.scopeid=3 + left join jcl_org_level f on e.${level}=f.id + left join jcl_org_grade g on e.${grade}=g.id + where nvl(a.canceled,0) <> 1 + + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'', + '',NULL,'','','',isnull(a.supsubcomid,0),isnull(a.supsubcomid,0), + 0,0,0,convert(varchar(100),getDate(),23),'2099-12-31' from hrmsubcompany as a + where isnull(a.canceled,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'', + '',NULL,'','','',ifnull(a.supsubcomid,0),ifnull(a.supsubcomid,0), + 0,0,0,NOW(),'2099-12-31' from hrmsubcompany as a + where IFNULL(a.canceled,0) <> 1 + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'', + '',NULL,'','','',COALESCE(a.supsubcomid,0),COALESCE(a.supsubcomid,0), + 0,0,0,TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'),'2099-12-31' from hrmsubcompany as a + where COALESCE(a.canceled,'0') <> '1' + + + insert into jcl_org_map + (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg, + fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid, + fplan,fonjob,fisvitual,fdatebegin,fdateend) + select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'', + '',NULL,'','','',nvl(a.supsubcomid,0),nvl(a.supsubcomid,0), + 0,0,0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') from hrmsubcompany a + where nvl(a.canceled,0) <> 1 + + + + INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname, + fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid, + fplan, fonjob, fisvitual, fdatebegin, fdateend) + SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname, + 0, NULL, NULL, 0, NULL, -1, 0, + 0, 0, 0, convert(varchar(100),getDate(),23), '2099-12-31' FROM hrmcompany + + + INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname, + fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid, + fplan, fonjob, fisvitual, fdatebegin, fdateend) + SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname, + 0, NULL, NULL, 0, NULL, -1, 0, + 0, 0, 0, TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') FROM hrmcompany + + + INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname, + fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid, + fplan, fonjob, fisvitual, fdatebegin, fdateend) + SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname, + 0, NULL, NULL, 0, NULL, -1, 0, + 0, 0, 0, NOW(), '2099-12-31' FROM hrmcompany + + + INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname, + fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid, + fplan, fonjob, fisvitual, fdatebegin, fdateend) + SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname, + 0, NULL, NULL, 0, NULL, -1, 0, + 0, 0, 0, TO_DATE(to_char(NOW(),'yyyy-MM-dd'),'yyyy-MM-dd'), '2099-12-31' FROM hrmcompany + + + delete from jcl_org_map where ftype =3 and fdateend > #{currentDate} and id not in (select a.FPARENTID from (select FPARENTID from jcl_org_map where ftype=4 and fdateend > #{currentDate}) a) + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/job/JobMapper.java b/src/com/engine/organization/mapper/job/JobMapper.java index 9b6eab4f..e1a03e49 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.java +++ b/src/com/engine/organization/mapper/job/JobMapper.java @@ -1,5 +1,6 @@ package com.engine.organization.mapper.job; +import com.engine.organization.entity.hrmresource.po.ResourcePO; import com.engine.organization.entity.job.dto.JobListDTO; import com.engine.organization.entity.job.po.JobPO; import org.apache.ibatis.annotations.Param; @@ -79,24 +80,6 @@ public interface JobMapper { */ List listByNo(@Param("jobNo") String jobNo); - /** - * 查询是否存在同名岗位 - * - * @param jobName - * @param id - * @return - */ - List listByNameExceptId(@Param("jobName") String jobName, @Param("id") Long id); - - /** - * 统计同一层级下是否有重名岗位 - * @param jobName - * @param id - * @param parentJob - * @param ecDepartment - * @return - */ - Integer countRepeatNameByPid(@Param("jobName") String jobName, @Param("id") Long id, @Param("parentJob") Long parentJob, @Param("ecDepartment") Long ecDepartment); /** * 根据所属部门查询数据 @@ -139,14 +122,6 @@ public interface JobMapper { */ int deleteByIds(@Param("ids") Collection ids); - /** - * 查询所有被引用的ID - * - * @return - */ - List listUsedId(); - - /** * 获取最大排序 * @@ -163,20 +138,15 @@ public interface JobMapper { * @param parentJob * @return */ - Long getIdByNameAndPid(@Param("jobName") String jobName, @Param("parentCompany") Long parentCompany, @Param("parentDepartment") Long parentDepartment, @Param("parentJob") Long parentJob); + Long getIdByNameAndPid(@Param("jobName") String jobName, @Param("parentCompany") Integer parentCompany, @Param("parentDepartment") Integer parentDepartment, @Param("parentJob") Long parentJob); - Long getIdByNameAndEcId(@Param("jobName") String jobName, @Param("ecCompany") String ecCompany, @Param("ecDepartment") String ecDepartment); + int updateJobCompany(@Param("ids") Collection ids, @Param("parentCompany") Integer parentCompany, @Param("ecCompany") Integer ecCompany); - int checkRepeatNo(@Param("jobNo") String jobNo, @Param("id") Long id); + int selectByConditions(@Param("resourcePO") ResourcePO resourcePO); - /** - * 批量更新岗位的所属分部 - * - * @param ids - * @param parentCompany - * @return - */ - int updateJobCompany(@Param("ids") Collection ids, @Param("parentCompany") Long parentCompany, @Param("ecCompany") String ecCompany); + List listUsedId(); + + List isAllowDelete(@Param("jobId") Long jobId); - int isHasResource(@Param("jobId") Long jobId); + JobPO getJobByResource(@Param("resourcePO") ResourcePO resourcePO); } diff --git a/src/com/engine/organization/mapper/job/JobMapper.xml b/src/com/engine/organization/mapper/job/JobMapper.xml index 12498ca0..663ef720 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.xml +++ b/src/com/engine/organization/mapper/job/JobMapper.xml @@ -4,11 +4,11 @@ - - - + + + @@ -34,9 +34,8 @@ id , t.job_no, - t.job_name, - t.parent_comp, - t.parent_dept, + h.jobtitlename, + t.ec_jobTitle, t.ec_company, t.ec_department, t.sequence_id, @@ -73,15 +72,6 @@ job_no, - - job_name, - - - parent_comp, - - - parent_dept, - sequence_id, @@ -115,6 +105,9 @@ ec_department, + + ec_jobTitle, + forbidden_tag, @@ -133,16 +126,6 @@ #{jobNo}, - - #{jobName}, - - - - #{parentComp}, - - - #{parentDept}, - #{sequenceId}, @@ -176,6 +159,9 @@ #{ecDepartment}, + + #{ecJobTitle}, + 0, @@ -202,15 +188,6 @@ job_no, - - job_name, - - - parent_comp, - - - parent_dept, - sequence_id, @@ -244,6 +221,9 @@ ec_department, + + ec_jobTitle, + forbidden_tag, @@ -262,16 +242,6 @@ #{jobNo}, - - #{jobName}, - - - - #{parentComp}, - - - #{parentDept}, - #{sequenceId}, @@ -305,6 +275,9 @@ #{ecDepartment}, + + #{ecJobTitle}, + 0, @@ -314,9 +287,6 @@ creator=#{creator}, update_time=#{updateTime}, - job_name=#{jobName}, - parent_comp=#{parentComp}, - parent_dept=#{parentDept}, ec_company=#{ecCompany}, ec_department=#{ecDepartment}, sequence_id=#{sequenceId}, @@ -351,44 +321,29 @@ #{id} - - update jcl_org_job - - parent_comp = #{parentCompany}, - ec_company =#{ecCompany}, - - where delete_type = 0 - AND id IN - - #{id} - - + SELECT - a.comp_name , - b.dept_name , + a.subcompanyname , + b.departmentname , c.sequence_name, d.scheme_name, FROM jcl_org_job t - left join jcl_org_comp a on - t.parent_comp = a.id - left join jcl_org_dept b on - t.parent_dept = b.id + left join hrmsubcompany a on + t.ec_company = a.id + left join hrmdepartment b on + t.ec_department = b.id left join jcl_org_sequence c on t.sequence_id = c.id left join jcl_org_scheme d on t.scheme_id = d.id + left join hrmjobtitles h on t.ec_jobTitle = h.id WHERE t.delete_type = 0 order by ${orderSql} @@ -436,16 +392,18 @@ select from jcl_org_job t - where delete_type = 0 - and id = #{id} + left join hrmjobtitles h on t.ec_jobTitle = h.id + where t.delete_type = 0 + and t.id = #{id} select - from jcl_org_job t where job_no = #{jobNo} AND delete_type = 0 + from jcl_org_job t + left join hrmjobtitles h on t.ec_jobTitle = h.id + where job_no = #{jobNo} AND delete_type = 0 - - + select count(1) from jcl_org_job - where delete_type = 0 and job_name = #{jobName} - and parent_comp = #{parentCompany} + where ec_company = #{resourcePO.subcompanyid1} + and ec_department = #{resourcePO.departmentid} + and ec_jobtitle = #{resourcePO.jobtitle} + and delete_type = 0 + + + - + select t.id from jcl_org_job t - where delete_type = 0 - AND job_name = #{jobName} - AND id != #{id} + inner join hrmresource h on t.ec_jobtitle = h.jobtitle and t.ec_company = h.subcompanyid1 and + t.ec_department = h.departmentid - + select t.id from jcl_org_job t + inner join hrmresource h on t.ec_jobtitle = h.jobtitle and t.ec_company = h.subcompanyid1 and + t.ec_department = h.departmentid and t.id = #{jobId} + + - - - - - and ifnull(parent_job,0) = - #{parentJob} - - - and isnull(parent_job,0) = - #{parentJob} - + + update jcl_org_job + + parent_comp = #{parentCompany}, + ec_company =#{ecCompany}, + + where delete_type = 0 + AND id IN + + #{id} + + + - - and NVL(parent_job,0) = - #{parentJob} - - and ifnull(parent_dept,0) = + and ifnull(ec_department,0) = #{parentDepartment} - and isnull(parent_dept,0) = + and isnull(ec_department,0) = #{parentDepartment} - and NVL(parent_dept,0) = + and NVL(ec_department,0) = + #{parentDepartment} + + + and COALESCE(ec_department,0) = #{parentDepartment} @@ -611,8 +571,8 @@ and t.job_no like CONCAT('%',#{jobPO.jobNo},'%') - - and t.job_name like CONCAT('%',#{jobPO.jobName},'%') + + and h.jobtitlename like CONCAT('%',#{jobPO.jobTitleName},'%') and t.workplace like CONCAT('%',#{jobPO.workplace},'%') @@ -632,8 +592,28 @@ and t.job_no like '%'||#{jobPO.jobNo}||'%' - - and t.job_name like '%'||#{jobPO.jobName}||'%' + + and h.jobtitlename like '%'||#{jobPO.jobTitleName}||'%' + + + and t.workplace like '%'||#{jobPO.workplace}||'%' + + + and t.description like '%'||#{jobPO.description}||'%' + + + and t.work_duty like '%'||#{jobPO.workDuty}||'%' + + + and t.work_authority like '%'||#{jobPO.workAuthority}||'%' + + + + + and t.job_no like '%'||#{jobPO.jobNo}||'%' + + + and h.jobtitlename like '%'||#{jobPO.jobTitleName}||'%' and t.workplace like '%'||#{jobPO.workplace}||'%' @@ -653,8 +633,8 @@ and t.job_no like '%'+#{jobPO.jobNo}+'%' - - and t.job_name like '%'+#{jobPO.jobName}+'%' + + and h.jobTitleName like '%'+#{jobPO.jobTitleName}+'%' and t.workplace like '%'+#{jobPO.workplace}+'%' diff --git a/src/com/engine/organization/mapper/personnelcard/CardAccessMapper.xml b/src/com/engine/organization/mapper/personnelcard/CardAccessMapper.xml index 5488d10e..8ddf3310 100644 --- a/src/com/engine/organization/mapper/personnelcard/CardAccessMapper.xml +++ b/src/com/engine/organization/mapper/personnelcard/CardAccessMapper.xml @@ -12,8 +12,6 @@ - - @@ -29,8 +27,6 @@ , t.custom , t.creator , t.delete_type - , t.create_time - , t.update_time @@ -110,8 +106,9 @@ - - + + select JCL_ORG_CARDACCESS_ID.currval from dual INSERT INTO jcl_org_cardaccess @@ -222,7 +219,7 @@ - when id=#{item.id} then #{item.custom} + when id=#{item.id} then #{item.custom} @@ -239,6 +236,50 @@ + + update jcl_org_cardaccess + + + + + when id=#{item.id} then #{item.status} + + + + + + + when id=#{item.id} then #{item.allPeople} + + + + + + + when id=#{item.id} then #{item.superior} + + + + + + + when id=#{item.id} then #{item.allSuperior} + + + + + + when id=#{item.id} then #{item.custom} + + + update_time=now(), + + where + + id=#{item.id} + + + UPDATE jcl_org_cardaccess SET delete_type = 1 diff --git a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java index b2f70821..bba63a8d 100644 --- a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java +++ b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java @@ -1,7 +1,9 @@ package com.engine.organization.mapper.personnelcard; import com.engine.organization.entity.personnelcard.po.CardButtonPO; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -16,4 +18,10 @@ public interface CardButtonMapper { List listEnableButton(); + + List listAllId(); + + int deleteByIds(@Param("ids")Collection ids); + + CardButtonPO getEditButton(); } diff --git a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml index 558ee6f7..617561c6 100644 --- a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml +++ b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml @@ -8,10 +8,10 @@ + + - - @@ -25,21 +25,40 @@ , t.url , t.roles , t.sys_default + , t.show_order + , t.open_type , t.creator , t.delete_type - , t.create_time - , t.update_time + + delete from jcl_org_cardbutton where id in + + #{id} + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.java b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.java index 48828b3f..b7a27de0 100644 --- a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.java +++ b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.java @@ -2,6 +2,7 @@ package com.engine.organization.mapper.personnelcard; import com.engine.organization.entity.personnelcard.ResourceBaseTab; import com.engine.organization.entity.personnelcard.UserCard; +import com.engine.organization.entity.personnelcard.po.CusTreeFormPO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -22,7 +23,16 @@ public interface PersonnelCardMapper { /** * 获取自定义显示栏目 + * * @return */ List getResourceBaseTabList(); + + /** + * 获取基本分组 + * + * @return + */ + List getCusTreeForms(@Param("parentId") Integer parentId); + } diff --git a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml index a9184400..3b45911f 100644 --- a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml +++ b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml @@ -3,12 +3,12 @@ - - + + - + @@ -25,17 +25,26 @@ + + + + + + + + + @@ -45,4 +54,12 @@ where isopen = 1 order by dsporder + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java new file mode 100644 index 00000000..1556a3d8 --- /dev/null +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java @@ -0,0 +1,81 @@ +package com.engine.organization.mapper.resource; + +import com.alibaba.fastjson.JSONObject; +import com.engine.organization.entity.hrmresource.po.ResourcePO; +import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; +import com.engine.organization.entity.hrmresource.po.SearchTemplatePO; +import com.engine.organization.entity.resume.po.HrmFamilyInfoPO; +import com.engine.organization.entity.resume.po.PersonnelResumePO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/15 + * @Version V1.0 + **/ +public interface HrmResourceMapper { + + List selectFilterDatas(); + + List listByFilter(@Param("resourcePO") ResourcePO resourcePO); + + PersonnelResumePO getPersonnelResumeById(@Param("id") Integer id); + + List getPersonnelResumeList(); + + List getHrmFamilyInfoByUser(@Param("resourceId") Integer resourceId); + + /** + * 获取人员过滤后的人员信息 + * + * @param subcompanyid1 + * @param departmentid + * @param jobId + * @param resourceId + * @return + */ + List getPersonnelScreening(@Param("subCompanyIds") List subcompanyid1, @Param("departmentIds") List departmentid, @Param("jobIds") List jobId, @Param("resourceIds") List resourceId); + + /** + * 根据用户ID获取查询模板 + * + * @param userId + * @return + */ + List getSearchTemplatesByUser(@Param("userId") Integer userId); + + /** + * 根据用户ID获取列定制模板 + * + * @param userId + * @return + */ + List getCustomTemplatesByUser(@Param("userId") Integer userId); + + SearchTemplatePO getSearchTemplateById(@Param("id") String id); + + SearchTemplatePO getSearchTemplateByName(@Param("userId") Integer userId, @Param("name") String name); + + SearchTemplatePO getCustomTemplateById(@Param("id") String id); + + SearchTemplatePO getCustomTemplateByName(@Param("userId") Integer userId, @Param("name") String name); + + SearchTemplatePO getUsedCustomTemplateByUser(@Param("userId") Integer userId); + + Integer insertSearchTemplate(SearchTemplatePO templatePO); + + Integer deleteSearchTemplate(@Param("id") Integer Id, @Param("userId") Integer userId); + + Integer insertCustomTemplate(SearchTemplatePO templatePO); + + Integer deleteCustomTemplate(@Param("id") Integer Id, @Param("userId") Integer userId); + + List queryAllResColumns(@Param("level") String level, @Param("grade") String grade); + + String queryLabelName(@Param("fieldName") String fieldName, @Param("scopeId") String scopeId); + + +} diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml new file mode 100644 index 00000000..6269d647 --- /dev/null +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml @@ -0,0 +1,446 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO JCL_ORG_SEARCH_TEMPLATE + + + creator, + + + create_time, + + + update_time, + + + name, + + + basic_fields, + + + personal_fields, + + + work_fields, + + + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{name}, + + + #{basicFields}, + + + #{personalFields}, + + + #{workFields}, + + + + + + + select JCL_ORG_SEARCH_TEMPLATE_ID.currval from dual + + INSERT INTO JCL_ORG_SEARCH_TEMPLATE + + + creator, + + + create_time, + + + update_time, + + + name, + + + basic_fields, + + + personal_fields, + + + work_fields, + + + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{name}, + + + #{basicFields}, + + + #{personalFields}, + + + #{workFields}, + + + + + INSERT INTO JCL_ORG_CUSTOM_TEMPLATE + + + creator, + + + create_time, + + + update_time, + + + name, + + + basic_fields, + + + personal_fields, + + + work_fields, + + + isused, + + + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{name}, + + + #{basicFields}, + + + #{personalFields}, + + + #{workFields}, + + + #{isused}, + + + + + + + select JCL_ORG_CUSTOM_TEMPLATE_ID.currval from dual + + INSERT INTO JCL_ORG_CUSTOM_TEMPLATE + + + creator, + + + create_time, + + + update_time, + + + name, + + + basic_fields, + + + personal_fields, + + + work_fields, + + + isused, + + + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{name}, + + + #{basicFields}, + + + #{personalFields}, + + + #{workFields}, + + + #{isused}, + + + + + + delete + from jcl_org_search_template + where id = #{id} + and creator = #{userId} + + + + delete + from jcl_org_custom_template + where id = #{id} + and creator = #{userId} + + + + + AND t.lastname like CONCAT('%',#{resourcePO.lastName},'%') + + + + + AND t.lastname like '%'||#{resourcePO.lastName}||'%' + + + + + AND t.lastname like '%'||#{resourcePO.lastName}||'%' + + + + + AND t.lastname like '%'+#{resourcePO.lastName}+'%' + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java new file mode 100644 index 00000000..f2a095d5 --- /dev/null +++ b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.java @@ -0,0 +1,39 @@ +package com.engine.organization.mapper.resource; + +import com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplatePO; +import org.apache.ibatis.annotations.Param; + +import java.util.Collection; +import java.util.List; + +/** +* @author Mlin +* @description 针对表【jcl_org_custom_template】的数据库操作Mapper +* @createDate 2023-01-12 10:28:52 +* @Entity com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplate +*/ +public interface JclOrgCustomTemplateMapper { + + int deleteByPrimaryKey(Long id); + + int insert(JclOrgCustomTemplatePO record); + + int insertSelective(JclOrgCustomTemplatePO record); + + JclOrgCustomTemplatePO selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(JclOrgCustomTemplatePO record); + + int updateByPrimaryKey(JclOrgCustomTemplatePO record); + + List listAll(); + + List listAllId(); + + int deleteByIds(@Param("ids") Collection ids); + + int updateUsed(@Param("isused")String isused,@Param("id") String id,@Param("creator") String creator); + + JclOrgCustomTemplatePO queryIsusedTemp(@Param("isused")String isused,@Param("creator") String creator); + +} diff --git a/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml new file mode 100644 index 00000000..3343baf8 --- /dev/null +++ b/src/com/engine/organization/mapper/resource/JclOrgCustomTemplateMapper.xml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + id,name,basic_fields, + personal_fields,work_fields,isused, + creator,create_time,update_time + + + + + + + delete from jcl_org_custom_template + where id = #{id,jdbcType=INTEGER} + + + insert into jcl_org_custom_template + (name,basic_fields + ,personal_fields,work_fields,isused + ,creator,create_time,update_time + ) + values (#{name,jdbcType=VARCHAR},#{basicFields,jdbcType=VARCHAR} + ,#{personalFields,jdbcType=VARCHAR},#{workFields,jdbcType=VARCHAR},#{isused,jdbcType=INTEGER} + ,#{creator,jdbcType=INTEGER},#{createTime,jdbcType=DATE},#{updateTime,jdbcType=DATE} + ) + + + insert into jcl_org_custom_template + + id, + name, + basic_fields, + personal_fields, + work_fields, + isused, + creator, + create_time, + update_time, + + + #{id,jdbcType=INTEGER}, + #{name,jdbcType=VARCHAR}, + #{basicFields,jdbcType=VARCHAR}, + #{personalFields,jdbcType=VARCHAR}, + #{workFields,jdbcType=VARCHAR}, + #{isused,jdbcType=INTEGER}, + #{creator,jdbcType=INTEGER}, + #{createTime,jdbcType=DATE}, + #{updateTime,jdbcType=DATE}, + + + + update jcl_org_custom_template + + + name = #{name,jdbcType=VARCHAR}, + + + basic_fields = #{basicFields,jdbcType=VARCHAR}, + + + personal_fields = #{personalFields,jdbcType=VARCHAR}, + + + work_fields = #{workFields,jdbcType=VARCHAR}, + + + isused = #{isused,jdbcType=INTEGER}, + + + creator = #{creator,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=DATE}, + + + update_time = #{updateTime,jdbcType=DATE}, + + + where id = #{id,jdbcType=INTEGER} + + + update jcl_org_custom_template + set + name = #{name,jdbcType=VARCHAR}, + basic_fields = #{basicFields,jdbcType=VARCHAR}, + personal_fields = #{personalFields,jdbcType=VARCHAR}, + work_fields = #{workFields,jdbcType=VARCHAR}, + isused = #{isused,jdbcType=INTEGER}, + creator = #{creator,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=DATE}, + update_time = #{updateTime,jdbcType=DATE} + where id = #{id,jdbcType=INTEGER} + + + + + + delete from jcl_org_custom_template where id in + + #{id} + + + + + update JCL_ORG_CUSTOM_TEMPLATE set isused = #{isused} + + + id = #{id} + + + and creator = #{creator} + + + + + + + diff --git a/src/com/engine/organization/mapper/resource/ResourceMapper.java b/src/com/engine/organization/mapper/resource/ResourceMapper.java index 1dfe0889..3883e6fd 100644 --- a/src/com/engine/organization/mapper/resource/ResourceMapper.java +++ b/src/com/engine/organization/mapper/resource/ResourceMapper.java @@ -15,15 +15,28 @@ import java.util.List; **/ public interface ResourceMapper { - List listAll(@Param("ids")List ids); + List listAll(@Param("ids") List ids); List listDetachAll(@Param("ids") List ids, @Param("companyIds") List companyIds); List getResourceListByJobId(@Param("jobId") Long jobId); - int updateResourceJob(@Param("originalJobId") Long originalJobId, @Param("targetJobId") Long targetJobId, @Param("parentComp") Long parentComp, @Param("parentDept") Long parentDept, @Param("ecCompany") Long ecCompany, @Param("ecDepartment") Long ecDepartment); + int updateResourceJob(@Param("originalJobId") Long originalJobId, @Param("targetJobId") Long targetJobId, @Param("parentComp") Integer parentComp, @Param("parentDept") Integer parentDept, @Param("ecCompany") Integer ecCompany, @Param("ecDepartment") Integer ecDepartment); HrmResourcePO getResourceById(@Param("id") String id); List listByNo(@Param("workCode") String workCode); + + Long getMaxShowOrder(); + + /** + * 根据所选关键字段查询ID + * + * @param keyField + * @param keyFieldValue + * @return + */ + List getIdByKeyField(@Param("keyField") String keyField, @Param("keyFieldValue") String keyFieldValue); + + } diff --git a/src/com/engine/organization/mapper/resource/ResourceMapper.xml b/src/com/engine/organization/mapper/resource/ResourceMapper.xml index d6410eba..93500789 100644 --- a/src/com/engine/organization/mapper/resource/ResourceMapper.xml +++ b/src/com/engine/organization/mapper/resource/ResourceMapper.xml @@ -33,7 +33,10 @@ - t.id,t.work_code,t.last_name,t.sex,t.status,t.account_type, + t + . + id + ,t.work_code,t.last_name,t.sex,t.status,t.account_type, t.belong_to,t.ec_company,t.job_title,t.ec_department,t. scheme_id,t.sequence_id,t.job_grade,t.job_level,t.job_group_id, t.job_activity,t.location_id,t.show_order,t.company_start_date, @@ -53,12 +56,12 @@ + + + + @@ -137,6 +150,11 @@ AND t.last_name like '%'||#{param.lastName}||'%' + + + AND t.last_name like '%'||#{param.lastName}||'%' + + AND t.last_name like '%'+#{param.lastName}+'%' diff --git a/src/com/engine/organization/mapper/scheme/GradeMapper.xml b/src/com/engine/organization/mapper/scheme/GradeMapper.xml index b92e37c7..59fccd53 100644 --- a/src/com/engine/organization/mapper/scheme/GradeMapper.xml +++ b/src/com/engine/organization/mapper/scheme/GradeMapper.xml @@ -280,6 +280,9 @@ ','||level_id||',' like '%,'||#{levelId}+',%' + + ','||level_id||',' like '%,'||#{levelId}+',%' + ','+level_id+',' like '%,'+cast(#{levelId} as varchar(20))+',%' diff --git a/src/com/engine/organization/mapper/trigger/CompTriggerMapper.java b/src/com/engine/organization/mapper/trigger/CompTriggerMapper.java deleted file mode 100644 index 4ad23e77..00000000 --- a/src/com/engine/organization/mapper/trigger/CompTriggerMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.engine.organization.mapper.trigger; - - -import com.engine.organization.entity.hrmresource.po.HrmResourcePO; -import org.apache.ibatis.annotations.Param; -import weaver.hrm.passwordprotection.domain.HrmResource; - -import java.sql.Date; - - -/** - * @Author dxfeng - * @Date 2022/8/30 - * @Version V1.0 - **/ -public interface CompTriggerMapper { - Integer getEcCompanyIdByUuid(@Param("uuid") String uuid); - - HrmResource getHrmResourceById(@Param("id") Integer id); - - String getJobTitleMarkById(@Param("id") Integer id); - - Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("compId") Integer compId); - - int deleteMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin); - - int updateMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin, @Param("fdate") Date fdate); - - HrmResourcePO getResourceByEcId(@Param("ecId") Integer ecId); -} diff --git a/src/com/engine/organization/mapper/trigger/CompTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/CompTriggerMapper.xml deleted file mode 100644 index 7204e3cb..00000000 --- a/src/com/engine/organization/mapper/trigger/CompTriggerMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - update jcl_org_map - - fdateend=#{fdate}, - - where ftype=#{ftype} and fobjid=#{fobjid} and fdateend > #{fdatebegin} - - - delete - from jcl_org_map - where ftype = #{ftype} - and fobjid = #{fobjid} - and fdatebegin = #{fdatebegin} - - - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.java b/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.java deleted file mode 100644 index 482e1da6..00000000 --- a/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.engine.organization.mapper.trigger; - - -import org.apache.ibatis.annotations.Param; - -import java.sql.Date; - -/** - * @Author dxfeng - * @Date 2022/8/30 - * @Version V1.0 - **/ -public interface DepartmentTriggerMapper { - Integer getEcDepartmentIdByUuid(@Param("uuid") String uuid); - - Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("departmentId") Integer departmentId); - - - Integer countHrmResource(@Param("departmentid") Integer departmentid); -} diff --git a/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.xml deleted file mode 100644 index 6e74a7b6..00000000 --- a/src/com/engine/organization/mapper/trigger/DepartmentTriggerMapper.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.java b/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.java deleted file mode 100644 index ef14a4ce..00000000 --- a/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.engine.organization.mapper.trigger; - - -import org.apache.ibatis.annotations.Param; - -import java.sql.Date; - -/** - * @Author dxfeng - * @Date 2022/8/30 - * @Version V1.0 - **/ -public interface GroupTriggerMapper { - - Integer getInfoValue(@Param("id") Integer id); - - Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin); - - Integer countHrmResource(); - - int deleteMap(@Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin); - - int updateMap(@Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin, @Param("fdate") Date fdate); -} diff --git a/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.xml deleted file mode 100644 index 41087495..00000000 --- a/src/com/engine/organization/mapper/trigger/GroupTriggerMapper.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - update jcl_org_map - set fdateend=#{fdate} - where fobjid = #{fobjid} - and fdateend > #{fdatebegin} - - - delete - from jcl_org_map - where fobjid = 0 - and fdatebegin = #{fdatebegin} - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.java b/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.java deleted file mode 100644 index 2fb269fe..00000000 --- a/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.engine.organization.mapper.trigger; - -import org.apache.ibatis.annotations.Param; -import weaver.hrm.passwordprotection.domain.HrmResource; - -import java.sql.Date; -import java.util.List; - -/** - * @author:dxfeng - * @createTime: 2022/09/01 - * @version: 1.0 - */ -public interface HrmResourceTriggerMapper { - HrmResource getHrmResource(@Param("id") Long id); - - List getFidsByFleader(@Param("fLeader") String fLeader, @Param("currentDate") Date currentDate); - - int updateLeaders(@Param("currentDate") Date currentDate,@Param("fLeader") String fLeader, @Param("fLeaderImg") String fLeaderImg, @Param("fLeaderName") String fLeaderName, @Param("fLeaderJobId") Integer fLeaderJobId, @Param("fLeaderJob") String fLeaderJob, @Param("fLeaderLv") String fLeaderLv, @Param("fLeaderSt") String fLeaderSt); - -} diff --git a/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.xml deleted file mode 100644 index cd09e5ac..00000000 --- a/src/com/engine/organization/mapper/trigger/HrmResourceTriggerMapper.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - update jcl_org_map - - fleaderimg = #{fLeaderImg}, - fleadername = #{fLeaderName}, - fleaderjobid = #{fLeaderJobId}, - fleaderjob = #{fLeaderJob}, - fleaderlv = #{fLeaderLv}, - fleaderst = #{fLeaderSt}, - - where fleader = #{fLeader} AND fdatebegin <= #{currentDate} - AND fdateend >= #{currentDate} - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/trigger/JobTriggerMapper.java b/src/com/engine/organization/mapper/trigger/JobTriggerMapper.java deleted file mode 100644 index f7a47f51..00000000 --- a/src/com/engine/organization/mapper/trigger/JobTriggerMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.engine.organization.mapper.trigger; - - -import org.apache.ibatis.annotations.Param; - -import java.sql.Date; - -/** - * @Author dxfeng - * @Date 2022/8/30 - * @Version V1.0 - **/ -public interface JobTriggerMapper { - Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("jobId") Integer jobId); - - Integer countHrmResource(@Param("parentdept") Integer parentdept, @Param("fname") String fname); -} diff --git a/src/com/engine/organization/mapper/trigger/JobTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/JobTriggerMapper.xml deleted file mode 100644 index 2a3908d4..00000000 --- a/src/com/engine/organization/mapper/trigger/JobTriggerMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.java b/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.java deleted file mode 100644 index 3b27ad8d..00000000 --- a/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.engine.organization.mapper.trigger; - -import org.apache.ibatis.annotations.Param; - -import java.sql.Date; - -/** - * @author:dxfeng - * @createTime: 2022/09/21 - * @version: 1.0 - */ -public interface StaffTriggerMapper { - //Integer countCompanyUsers(@Param("ecCompanyId") String ecCompanyId); - - //Integer countDepartmentUsers(@Param("ecDepartmentId") String ecDepartmentId); - - //Integer countJobUsers(@Param("jobTitle") String jobTitle); - - Integer countOnJobByJObId(@Param("jobId") String jobId); - - //Integer countAllUsers(); - - Integer countCompanyStaffNum(@Param("currentDate") Date currentDate, @Param("companyId") String companyId); - - Integer countDepartmentStaffNum(@Param("currentDate") Date currentDate, @Param("departmentId") String departmentId); - - Integer countJobStaffNum(@Param("currentDate") Date currentDate, @Param("jobId") String jobId); - - Integer updateOrgStaffs(@Param("currentDate") Date currentDate, @Param("fType") String fType, @Param("fObjId") String fObjId, @Param("fPlan") Integer fPlan, @Param("fOnJob") Integer fOnJob); - - String getIdByObjIdAndType(@Param("currentDate") Date currentDate, @Param("fObjId") String fObjId, @Param("fType") String fType); - - Integer sumPlanByParentId(@Param("currentDate") Date currentDate, @Param("parentId") String parentId); - - Integer sumOnJobByParentId(@Param("currentDate") Date currentDate, @Param("parentId") String parentId); -} diff --git a/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.xml b/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.xml deleted file mode 100644 index a74be740..00000000 --- a/src/com/engine/organization/mapper/trigger/StaffTriggerMapper.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - update jcl_org_map - - FPLAN = #{fPlan}, - FONJOB = #{fOnJob}, - - where FTYPE =#{fType} and FOBJID=#{fObjId} - AND FDATEBEGIN <= #{currentDate} - AND FDATEEND >= #{currentDate} - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/com/engine/organization/mapper/version/CompanyVersionMapper.java b/src/com/engine/organization/mapper/version/CompanyVersionMapper.java new file mode 100644 index 00000000..e3e225c1 --- /dev/null +++ b/src/com/engine/organization/mapper/version/CompanyVersionMapper.java @@ -0,0 +1,81 @@ +package com.engine.organization.mapper.version; + +import com.alibaba.fastjson.JSONObject; +import com.engine.organization.entity.version.*; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/8 + * @Version V1.0 + **/ +public interface CompanyVersionMapper { + + /** + * 取分部版本最大记录 + */ + HrmSubCompanyVersion getMaxVersion(@Param("subComId") String subComId); + + /** + * 新增分部版本 + */ + int insertHrmSubComVersion(HrmSubCompanyVersion hrmSubCompanyVersion); + + + /** + * 取部门版本最大记录 + */ + HrmDepartmentVersion getMaxDeptVersion(@Param("departmentid") String departmentid); + + + /** + * 新增部门版本 + */ + int insertHrmDeptVersion(HrmDepartmentVersion hrmDepartmentVersion); + + + /** + * 人员版本最大记录 + */ + HrmResourceVersion getMaxHrmVersion(@Param("resourceid") String resourceid); + + /** + * 新增人员版本 + */ + int insertHrmResourceVersion(HrmResourceVersion hrmResourceVersion); + + /** + * 获取分部信息 + */ + HrmSubCompanyDto getHrmSubComp(@Param("id") String id); + + /** + * 获取部门信息 + */ + HrmDepartmentDto getHrmDepartment(@Param("id") String id); + + /** + * 获取人员信息 + */ + HrmResourceDto getHrmResource(@Param("id") String id); + + /** + * 获取分部版本记录 + */ + List getSubComVersionList(@Param("subComId") String subComId,@Param("version") String version); + + /** + * 获取部门版本记录 + */ + List getDeptVersionList(@Param("departmentid") String departmentid,@Param("version") String version); + + + /** + * 获取人员版本记录 + */ + List getResourceVersionList(@Param("resourceid") String resourceid,@Param("version") String version); + +} diff --git a/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml b/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml new file mode 100644 index 00000000..0908c91a --- /dev/null +++ b/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + t.id ,t.subcomid ,t.subcompanydesc ,t.subcompanycode ,t.subcompanyname ,t.supsubcomid , + t.showorder ,t.canceled ,t.description ,t.operator ,t.version ,t.operate_time + + + + + + + + + insert into hrmsubcompany_version + (subcomid ,subcompanydesc ,subcompanycode ,subcompanyname ,supsubcomid , + showorder ,canceled ,description ,operator ,version ,operate_time) + values (#{subComId}, #{subCompanyDesc}, #{subCompanyCode}, #{subCompanyName}, #{supSubComId}, + #{showOrder}, #{canceled}, #{description}, #{operator}, #{version}, #{operateTime}) + + + + + + + + insert into hrmdepartment_version + (departmentid, departmentmark, departmentcode, departmentname, subcompanyid1, supdepid, + bmfzr, showorder, canceled, description, operator, version, operate_time) + VALUES (#{departmentId}, #{departmentMark}, #{departmentCode}, #{departmentName}, #{subCompanyId1}, #{supDepId}, + #{bmfzr}, #{showOrder}, #{canceled}, #{description}, #{operator}, #{version}, #{operateTime}) + + + + + + + insert into hrmresource_version + + id, + resourceid, + companystartdate, + companyworkyear, + workstartdate, + workyear, + usekind, + jobcall, + accumfundaccount, + birthplace, + folk, + residentphone, + residentpostcode, + extphone, + managerstr, + status, + fax, + islabouunion, + weight, + tempresidentnumber, + probationenddate, + countryid, + passwdchgdate, + lloginid, + dsporder, + passwordstate, + accounttype, + belongto, + messagerurl, + accountname, + loginid, + password, + lastname, + sex, + birthday, + nationality, + maritalstatus, + telephone, + mobile, + mobilecall, + email, + locationid, + workroom, + homeaddress, + resourcetype, + startdate, + enddate, + jobtitle, + jobactivitydesc, + joblevel, + seclevel, + departmentid, + subcompanyid1, + costcenterid, + managerid, + assistantid, + bankid1, + accountid1, + resourceimageid, + certificatenum, + nativeplace, + educationlevel, + bememberdate, + bepartydate, + workcode, + regresidentplace, + healthinfo, + residentplace, + policy, + degree, + height, + classification, + description, + operator, + version, + operate_time, + + + #{id,jdbcType=INTEGER}, + #{resourceid,jdbcType=INTEGER}, + #{companystartdate,jdbcType=TIMESTAMP}, + #{companyworkyear,jdbcType=INTEGER}, + #{workstartdate,jdbcType=TIMESTAMP}, + #{workyear,jdbcType=INTEGER}, + #{usekind,jdbcType=INTEGER}, + #{jobcall,jdbcType=INTEGER}, + #{accumfundaccount,jdbcType=VARCHAR}, + #{birthplace,jdbcType=VARCHAR}, + #{folk,jdbcType=VARCHAR}, + #{residentphone,jdbcType=VARCHAR}, + #{residentpostcode,jdbcType=VARCHAR}, + #{extphone,jdbcType=VARCHAR}, + #{managerstr,jdbcType=VARCHAR}, + #{status,jdbcType=INTEGER}, + #{fax,jdbcType=VARCHAR}, + #{islabouunion,jdbcType=CHAR}, + #{weight,jdbcType=INTEGER}, + #{tempresidentnumber,jdbcType=VARCHAR}, + #{probationenddate,jdbcType=TIMESTAMP}, + #{countryid,jdbcType=INTEGER}, + #{passwdchgdate,jdbcType=TIMESTAMP}, + #{lloginid,jdbcType=VARCHAR}, + #{dsporder,jdbcType=INTEGER}, + #{passwordstate,jdbcType=INTEGER}, + #{accounttype,jdbcType=INTEGER}, + #{belongto,jdbcType=INTEGER}, + #{messagerurl,jdbcType=VARCHAR}, + #{accountname,jdbcType=VARCHAR}, + #{loginid,jdbcType=VARCHAR}, + #{password,jdbcType=VARCHAR}, + #{lastname,jdbcType=VARCHAR}, + #{sex,jdbcType=CHAR}, + #{birthday,jdbcType=CHAR}, + #{nationality,jdbcType=INTEGER}, + #{maritalstatus,jdbcType=CHAR}, + #{telephone,jdbcType=VARCHAR}, + #{mobile,jdbcType=VARCHAR}, + #{mobilecall,jdbcType=VARCHAR}, + #{email,jdbcType=VARCHAR}, + #{locationid,jdbcType=INTEGER}, + #{workroom,jdbcType=VARCHAR}, + #{homeaddress,jdbcType=VARCHAR}, + #{resourcetype,jdbcType=CHAR}, + #{startdate,jdbcType=TIMESTAMP}, + #{enddate,jdbcType=TIMESTAMP}, + #{jobtitle,jdbcType=INTEGER}, + #{jobactivitydesc,jdbcType=VARCHAR}, + #{joblevel,jdbcType=INTEGER}, + #{seclevel,jdbcType=INTEGER}, + #{departmentid,jdbcType=INTEGER}, + #{subcompanyid1,jdbcType=INTEGER}, + #{costcenterid,jdbcType=INTEGER}, + #{managerid,jdbcType=INTEGER}, + #{assistantid,jdbcType=INTEGER}, + #{bankid1,jdbcType=INTEGER}, + #{accountid1,jdbcType=VARCHAR}, + #{resourceimageid,jdbcType=INTEGER}, + #{certificatenum,jdbcType=VARCHAR}, + #{nativeplace,jdbcType=VARCHAR}, + #{educationlevel,jdbcType=INTEGER}, + #{bememberdate,jdbcType=TIMESTAMP}, + #{bepartydate,jdbcType=TIMESTAMP}, + #{workcode,jdbcType=VARCHAR}, + #{regresidentplace,jdbcType=VARCHAR}, + #{healthinfo,jdbcType=CHAR}, + #{residentplace,jdbcType=VARCHAR}, + #{policy,jdbcType=VARCHAR}, + #{degree,jdbcType=VARCHAR}, + #{height,jdbcType=VARCHAR}, + #{classification,jdbcType=CHAR}, + #{description,jdbcType=VARCHAR}, + #{operator,jdbcType=VARCHAR}, + #{version,jdbcType=FLOAT}, + #{operateTime,jdbcType=TIMESTAMP}, + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/CompService.java b/src/com/engine/organization/service/CompService.java index fede7178..f4517480 100644 --- a/src/com/engine/organization/service/CompService.java +++ b/src/com/engine/organization/service/CompService.java @@ -1,11 +1,10 @@ package com.engine.organization.service; import com.api.browser.bean.SearchConditionGroup; -import com.engine.organization.entity.company.param.CompSearchParam; +import com.engine.organization.entity.company.param.CompParam; import com.engine.organization.entity.department.param.DepartmentMoveParam; import com.engine.organization.util.MenuBtn; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -23,7 +22,7 @@ public interface CompService { * @param params * @return */ - Map listPage(CompSearchParam params); + Map listPage(CompParam params); /** * 保存公司/分部基础信息 @@ -38,7 +37,7 @@ public interface CompService { * * @param params */ - int updateForbiddenTagById(CompSearchParam params); + int updateForbiddenTagById(CompParam params); /** @@ -53,17 +52,16 @@ public interface CompService { /** * 根据ID批量删除 * - * @param ids + * @param params */ - int deleteByIds(Collection ids); + Map deleteByIds(Map params); /** * 获取搜索条件 * - * @param params * @return */ - Map getSearchCondition(Map params); + Map getSearchCondition(); /** * 获取列表页面按钮信息 @@ -73,7 +71,7 @@ public interface CompService { Map> getHasRight(); /** - * 获取基本信息表单 + * 获取编辑表单 * * @param params * @return @@ -85,7 +83,7 @@ public interface CompService { * * @return */ - Map getCompSaveForm(); + Map getCompSaveForm(Map params); /** * 转移分部表单 diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java index d405d497..04791771 100644 --- a/src/com/engine/organization/service/DepartmentService.java +++ b/src/com/engine/organization/service/DepartmentService.java @@ -8,7 +8,6 @@ import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.page.PageInfo; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -81,9 +80,9 @@ public interface DepartmentService { /** * 根据ID批量删除 * - * @param ids + * @param params */ - int deleteByIds(Collection ids); + Map deleteByIds(Map params); /** * 获取搜索条件 @@ -114,7 +113,7 @@ public interface DepartmentService { * * @return */ - Map getSaveForm(DeptSearchParam param); + Map getSaveForm(Map params); /** * 复制表单 @@ -136,7 +135,7 @@ public interface DepartmentService { * * @return */ - List getMergeForm(Long id); + List getMergeForm(); /** * 合并到指定部门 diff --git a/src/com/engine/organization/service/HrmResourceService.java b/src/com/engine/organization/service/HrmResourceService.java index f7a3ddc8..f5487042 100644 --- a/src/com/engine/organization/service/HrmResourceService.java +++ b/src/com/engine/organization/service/HrmResourceService.java @@ -1,7 +1,7 @@ package com.engine.organization.service; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; -import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam; +import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; import com.engine.organization.entity.searchtree.SearchTreeParams; import java.util.Map; @@ -27,7 +27,7 @@ public interface HrmResourceService { * @param params * @return */ - Map listPage(HrmResourceSearchParam params); + Map listPage(Map params); /** * 获取新增表单 @@ -95,4 +95,76 @@ public interface HrmResourceService { * @return */ long updateTabForm(HrmRelationSaveParam params); + + /** + * 保存搜索条件模板 + * + * @param params + * @return + */ + Integer saveSearchTemplate(SearchTemplateParam params); + + /** + * 删除搜索条件模板 + * + * @param id + */ + void deleteSearchTemplate(Integer id); + + /** + * 获取模板所选择的列 + * + * @param params + * @return + */ + String getTemplateSelectKeys(Map params); + + /** + * 展示所有搜索模板 + * + * @param params + * @return + */ + Map getSearchTemplate(Map params); + + /** + * 保存定制列模板 + * + * @param params + * @return + */ + Integer saveCustomTemplate(SearchTemplateParam params); + + /** + * 批量修改保存定制列模板 + * + * @param params + * @return + */ + Integer updateCustomTemplate(Map params); + + /** + * 删除定制列模板 + * + * @param id + */ + void deleteCustomTemplate(Integer id); + + + /** + * 展示所有模板 + * @param params + * @return + */ + Map getCustomTemplate(Map params); + + /** + * 获取列定制穿梭框数据 + * + * @param params + * @return + */ + Map getCustomTransferData(Map params); + + Integer saveColumnsCustomTemplate(Map params); } diff --git a/src/com/engine/organization/service/JclOrgService.java b/src/com/engine/organization/service/JclOrgService.java new file mode 100644 index 00000000..0eb83776 --- /dev/null +++ b/src/com/engine/organization/service/JclOrgService.java @@ -0,0 +1,16 @@ +package com.engine.organization.service; + +/** + * @author:dxfeng + * @createTime: 2022/12/16 + * @version: 1.0 + */ +public interface JclOrgService { + + /** + * 根据职等职级字段,补充人员信息 + * + * @param userId 人员ID + */ + void supplementResourceInfo(Integer userId); +} diff --git a/src/com/engine/organization/service/JobService.java b/src/com/engine/organization/service/JobService.java index 799f1ea0..b18793e2 100644 --- a/src/com/engine/organization/service/JobService.java +++ b/src/com/engine/organization/service/JobService.java @@ -117,4 +117,9 @@ public interface JobService { * @return */ int mergeJob(JobMergeParam mergeParam); + + /** + * 刷新岗位数据 + */ + void refresh(); } diff --git a/src/com/engine/organization/service/OrgChartService.java b/src/com/engine/organization/service/OrgChartService.java index 45ed7ed5..676c543a 100644 --- a/src/com/engine/organization/service/OrgChartService.java +++ b/src/com/engine/organization/service/OrgChartService.java @@ -11,14 +11,78 @@ import java.util.Map; * @description: 组织架构图Service **/ public interface OrgChartService { + + /** + * @Description: 高级搜索 + * @Author: liang.cheng + * @Date: 2023/6/26 3:18 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ Map getOptionCondition(Map request2Map, User user); + /** + * 分部树下级数据 + * @param params [params] + * @return java.util.Map + */ + Map getSubCompanyTree(Map params); + + + /** + * @Description: 组织架构图 + * @Author: liang.cheng + * @Date: 2023/6/26 3:19 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ Map getCompanyData(Map request2Map, User user); + /** + * @Description: 组织透视图 + * @Author: liang.cheng + * @Date: 2023/6/26 3:20 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ Map getUserData(Map request2Map, User user); + /** + * @Description: 异步获取 + * @Author: liang.cheng + * @Date: 2023/6/26 3:21 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ Map asyncUserData(Map request2Map, User user); + /** + * @Description: 异步获取 + * @Author: liang.cheng + * @Date: 2023/6/26 3:21 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ Map asyncCompanyData(Map request2Map, User user); + + /** + * @Description: 同步数据 + * @Author: liang.cheng + * @Date: 2023/6/26 3:22 PM + * @param: [request2Map, user] + * @return: java.lang.String + */ + String synchronousData(Map request2Map, User user); + + + /** + * @Description: 版本记录描述存储 + * @Author: liang.cheng + * @Date: 2023/6/28 1:53 PM + * @param: [fclass, description] + * @return: void + */ + void insertChartVersion(Integer fclass,String description); + } diff --git a/src/com/engine/organization/service/OrgVirtualService.java b/src/com/engine/organization/service/OrgVirtualService.java new file mode 100644 index 00000000..a48d22d3 --- /dev/null +++ b/src/com/engine/organization/service/OrgVirtualService.java @@ -0,0 +1,21 @@ +package com.engine.organization.service; + +import java.util.Map; + +/** + * @Author liang.cheng + * @Date 2023/6/27 3:45 PM + * @Description: TODO + * @Version 1.0 + */ +public interface OrgVirtualService { + + /** + * @Description: 虚拟组织列表 + * @Author: liang.cheng + * @Date: 2023/6/27 3:56 PM + * @param: [params] + * @return: java.util.Map + */ + Map listPage(Map params); +} diff --git a/src/com/engine/organization/service/PersonnelResumeService.java b/src/com/engine/organization/service/PersonnelResumeService.java new file mode 100644 index 00000000..291e464c --- /dev/null +++ b/src/com/engine/organization/service/PersonnelResumeService.java @@ -0,0 +1,50 @@ +package com.engine.organization.service; + +import com.api.browser.bean.SearchConditionItem; +import com.engine.organization.entity.searchtree.SearchTreeParams; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +public interface PersonnelResumeService { + /** + * 左侧树 + * + * @param params + * @return + */ + Map getSearchTree(SearchTreeParams params); + + /** + * 获取人员简历列表 + * + * @param uId + * @return + */ + Map getResumeList(Integer uId); + + /** + * 获取列表页面按钮信息 + * + * @return + */ + Map hasRight(); + + + /** + * 人员简历下载 + * @param type + * @param response + * @return + */ + String downloadPerResume(Integer type, HttpServletResponse response) throws Exception; + + + List personnelScreening(); +} diff --git a/src/com/engine/organization/service/VersionManageService.java b/src/com/engine/organization/service/VersionManageService.java new file mode 100644 index 00000000..65312702 --- /dev/null +++ b/src/com/engine/organization/service/VersionManageService.java @@ -0,0 +1,29 @@ +package com.engine.organization.service; + +import com.engine.organization.enums.ModuleTypeEnum; +import weaver.hrm.User; + +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/8 + * @Version V1.0 + **/ +public interface VersionManageService { + + /** + * 版本记录保存 + * @param moduleTypeEnum + * @param params + */ + void save(ModuleTypeEnum moduleTypeEnum, Map params, User user); + + /** + * 版本记录查询 + * @param moduleTypeEnum + * @param params + */ + Map getVersion(ModuleTypeEnum moduleTypeEnum,Map params, User user); +} diff --git a/src/com/engine/organization/service/impl/CardAccessServiceImpl.java b/src/com/engine/organization/service/impl/CardAccessServiceImpl.java index 35bad0d6..f12e9811 100644 --- a/src/com/engine/organization/service/impl/CardAccessServiceImpl.java +++ b/src/com/engine/organization/service/impl/CardAccessServiceImpl.java @@ -4,19 +4,24 @@ import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.personnelcard.po.CardAccessPO; import com.engine.organization.entity.personnelcard.po.CardButtonPO; import com.engine.organization.entity.personnelcard.vo.CardAccessVO; +import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.personnelcard.CardAccessMapper; import com.engine.organization.mapper.personnelcard.CardButtonMapper; import com.engine.organization.service.CardAccessService; import com.engine.organization.transmethod.SystemTransMethod; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import weaver.general.Util; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -65,12 +70,12 @@ public class CardAccessServiceImpl extends Service implements CardAccessService List dataList = new ArrayList<>(); for (int i = 0; i < rowNum; i++) { CardAccessPO data = CardAccessPO.builder() - .id(Util.getIntValue((String)params.get("id_"+i))) - .status(Util.getIntValue((String)params.get("status_"+i))) - .allPeople(Util.getIntValue((String)params.get("all_people_"+i))) - .superior(Util.getIntValue((String)params.get("superior_"+i))) - .allSuperior(Util.getIntValue((String)params.get("all_superior_"+i))) - .custom(Util.null2String(params.get("custom_"+i))) + .id(Util.getIntValue((String) params.get("id_" + i))) + .status(Util.getIntValue((String) params.get("status_" + i))) + .allPeople(Util.getIntValue((String) params.get("all_people_" + i))) + .superior(Util.getIntValue((String) params.get("superior_" + i))) + .allSuperior(Util.getIntValue((String) params.get("all_superior_" + i))) + .custom(Util.null2String(params.get("custom_" + i))) .updateTime(new Date()) .build(); dataList.add(data); @@ -89,40 +94,84 @@ public class CardAccessServiceImpl extends Service implements CardAccessService } @Override - public int updateTabName(String name,Integer id) { - return getCardAccessMapper().updateTabName(name,id); + public int updateTabName(String name, Integer id) { + return getCardAccessMapper().updateTabName(name, id); } @Override public Map getCardButtonTable() { List infoPOList = new ArrayList<>(); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("name").fieldNameDesc("按钮名称").fieldType("varchar(50)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build()); - infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("status").fieldNameDesc("启用").fieldType("char(1)").controlType(4).browserType("1").customValue("[\"check\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); + infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("status").fieldNameDesc("启用").fieldType("char(1)").controlType(7).browserType("1").customValue("[\"check\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("url").fieldNameDesc("跳转地址").fieldType("varchar(1000)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"1000\"]").showOrder(3).isrequired(0).isSystemDefault(0).build()); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("roles").fieldNameDesc("角色").fieldType("text").controlType(3).browserType("65").customValue("[\"browser\",{\"valueSpan\":\"多角色\",\"replaceDatas\":[{\"itemorderid\":\"65\",\"name\":\"多角色\",\"id\":\"65\",\"parenttitle\":\"人员\",\"title\":\"人员-多角色\"}],\"value\":\"65\"}]").showOrder(4).isrequired(0).isSystemDefault(0).build()); Map tabInfoMap = new HashMap<>(); - tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false)); + tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false, true)); List cardButtonPOS = getCardButtonMapper().listAll(); + List isUsed = new ArrayList<>(); + AtomicInteger index = new AtomicInteger(0); List> collect = cardButtonPOS.stream().map(item -> { Map resultMap = new HashMap<>(); resultMap.put("id", item.getId()); resultMap.put("name", item.getName()); - resultMap.put("status", item.getStatus()); + resultMap.put("status", ""); resultMap.put("url", item.getUrl()); resultMap.put("roles", item.getRoles()); resultMap.put("rolesspan", SystemTransMethod.getRoleName(item.getRoles())); + + if (1 == item.getStatus()) { + isUsed.add(index.get()); + } + index.getAndIncrement(); + return resultMap; }).collect(Collectors.toList()); + tabInfoMap.put("datas", collect); tabInfoMap.put("api_status", true); + Map> isUsedMap = new HashMap<>(); + isUsedMap.put("status", isUsed); + tabInfoMap.put("selectedData", isUsedMap); + tabInfoMap.put("isModalEdit", false); return tabInfoMap; } @Override public int saveCardButton(Map params) { - return 0; + String tableName = "JCL_ORG_CARDBUTTON"; + int rowNum = Util.getIntValue((String) params.get("rownum")); + int count = 0; + List allIds = getCardButtonMapper().listAllId(); + for (int i = 0; i < rowNum; i++) { + String recordIndex = "_" + i; + Map recordData = new HashMap<>(); + recordData.put("name", params.get("name" + recordIndex)); + recordData.put("status", params.get("status" + recordIndex)); + recordData.put("url", params.get("url" + recordIndex)); + recordData.put("roles", params.get("roles" + recordIndex)); + // 排序字段 + recordData.put("show_order", i); + // 预留字段 + // recordData.put("open", null); + String id = Util.null2String(params.get("id" + recordIndex)); + if (StringUtils.isNotBlank(id)) { + // 更新 + long buttonId = Long.parseLong(id); + count += MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().tableName(tableName).id(buttonId).params(recordData).build()); + allIds.remove(buttonId); + } else { + //插入 + recordData.put("sys_default", 1); + recordData.put("delete_type", 0); + count += MapperProxyFactory.getProxy(ExtMapper.class).insertTable(ExtendInfoParams.builder().tableName(tableName).params(recordData).build()); + } + } + if (CollectionUtils.isNotEmpty(allIds)) { + count += getCardButtonMapper().deleteByIds(allIds); + } + return count; } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index a00b4bf7..94933d3d 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -1,49 +1,46 @@ package com.engine.organization.service.impl; -import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; -import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.hrm.entity.RuleCodeType; +import com.engine.hrm.service.impl.OrganizationServiceImpl; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.DeleteParam; -import com.engine.organization.entity.codesetting.po.CodeRulePO; -import com.engine.organization.entity.commom.RecordInfo; +import com.engine.organization.entity.TopTab; import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.dto.CompListDTO; -import com.engine.organization.entity.company.param.CompSearchParam; +import com.engine.organization.entity.company.param.CompParam; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.param.DepartmentMoveParam; -import com.engine.organization.entity.extend.po.ExtendTitlePO; import com.engine.organization.enums.LogModuleNameEnum; import com.engine.organization.enums.OperateTypeEnum; -import com.engine.organization.mapper.codesetting.CodeRuleMapper; +import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.extend.ExtDTMapper; -import com.engine.organization.mapper.extend.ExtMapper; -import com.engine.organization.mapper.extend.ExtendTitleMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.service.CompService; -import com.engine.organization.service.ExtService; import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.util.*; -import com.engine.organization.util.coderule.CodeRuleUtil; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; -import com.engine.organization.util.relation.EcHrmRelationUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import weaver.general.StringUtil; +import weaver.conn.RecordSet; import weaver.general.Util; -import weaver.hrm.User; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; import java.util.*; import java.util.stream.Collectors; @@ -55,71 +52,34 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class CompServiceImpl extends Service implements CompService { - /** - * 分组类型 - * 1:分部 - * 2:部门 - * 3:岗位 - */ - private static final String EXTEND_TYPE = "1"; - /** - * 主表表名 - */ - private static final String JCL_ORG_COMP = "JCL_ORG_COMP"; - /** - * 主表拓展表 - */ - private static final String JCL_ORG_COMPEXT = "JCL_ORG_COMPEXT"; - /** - * 明细表拓展表 - */ - private static final String JCL_ORG_COMPEXT_DT1 = "JCL_ORG_COMPEXT_DT1"; private static final String RIGHT_NAME = "Company:All"; - private static final String HRM_COMPANY = "hrmsubcompany"; - - /** - * 公司/分部主表title指定ID - */ - private static final Long GROUP_ID = 1L; - private static CompMapper getCompMapper() { return MapperProxyFactory.getProxy(CompMapper.class); } - private ExtendTitleMapper getExtendTitleMapper() { - return MapperProxyFactory.getProxy(ExtendTitleMapper.class); - } - - private SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); - } - - private ExtService getExtService(User user) { - return ServiceUtil.getService(ExtServiceImpl.class, user); - } - - @Override - public Map listPage(CompSearchParam params) { + public Map listPage(CompParam params) { Map datas = new HashMap<>(); boolean hasRight = HasRightUtil.hasRight(user, RIGHT_NAME, true); datas.put("hasRight", hasRight); if (!hasRight) { return datas; } - CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); - boolean filter = isFilter(compPO); + CompPO companyPO = CompBO.convertParamToPO(params, user.getUID()); + boolean filter = isFilter(companyPO); PageInfo pageInfos; - String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams()); - List allList = getCompMapper().list(orderSql); - new DetachUtil(user.getUID()).filterCompanyList(allList); + String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams(), " showorder "); + List allList = getCompMapper().listAll(orderSql); + + new DetachUtil(user).filterCompanyList(allList); + // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 - List filterCompPOs = getCompMapper().listByFilter(compPO, orderSql); - new DetachUtil(user.getUID()).filterCompanyList(filterCompPOs); + List filterCompPOs = getCompMapper().listByFilter(companyPO, orderSql); + new DetachUtil(user).filterCompanyList(filterCompPOs); // 添加父级元素 List compListDTOS = CompBO.buildCompDTOList(allList, filterCompPOs); @@ -140,9 +100,7 @@ public class CompServiceImpl extends Service implements CompService { OrganizationWeaTable table = new OrganizationWeaTable<>(user, CompListDTO.class); List columns = pageInfos.getColumns(); List weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList()); - table.setColumns(weaTableColumn); - WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); @@ -155,129 +113,67 @@ public class CompServiceImpl extends Service implements CompService { @Override public Long saveBaseComp(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - String compNo = (String) params.get("comp_no"); - // 判断是否开启自动编号 - compNo = repeatDetermine(compNo); - params.put("comp_no", compNo); - if (null == params.get("show_order") || StringUtils.isBlank(params.get("show_order").toString())) { - Integer maxShowOrder = getCompMapper().getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0; - } - params.put("show_order", maxShowOrder + 1); - } - // 赋值上级分部 - String ecCompany = Util.null2String(params.get("ec_company")); - if (StringUtils.isNotBlank(ecCompany)) { - params.put("parent_company", EcHrmRelationUtil.getJclCompanyId(ecCompany).getId()); - } Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, params).sync(); - String ecCompanyID = Util.null2String(syncMap.get("id")); - OrganizationAssert.isTrue(StringUtils.isNotBlank(ecCompanyID), syncMap.get("message").toString()); - // 查询UUID - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_COMPANY, ecCompanyID); - params.put("uuid", recordInfo.getUuid()); - return getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, "", null); + String companyId = Util.null2String(syncMap.get("id")); + OrganizationAssert.isTrue(StringUtils.isNotBlank(companyId), syncMap.get("message").toString()); + return Long.parseLong(companyId); } @Override - public int updateForbiddenTagById(CompSearchParam params) { + public int updateForbiddenTagById(CompParam params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - CompPO compPO = CompPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build(); + CompPO compPO = CompPO.builder().id(params.getId()).canceled(params.getCanceled() ? 0 : 1).build(); Map map = new HashMap<>(); - map.put("id", compPO.getId()); - map.put("forbiddenTag", compPO.getForbiddenTag()); + map.put("id", compPO.getId().toString()); + map.put("forbiddenTag", compPO.getCanceled()); new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.CANCELED, map).sync(); - return getCompMapper().updateForbiddenTagById(compPO); + return 1; } @Override public Long updateComp(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - CompSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), CompSearchParam.class); - String groupId = (String) params.get("viewCondition"); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); - } - String oldCompNo = getCompMapper().listById(searchParam.getId()).getCompNo(); - String compNo = searchParam.getCompNo(); - if (!compNo.equals(oldCompNo)) { - compNo = repeatDetermine(compNo); - params.put("comp_no", compNo); - } - // 上级分部 - String ecCompany = Util.null2String(params.get("ec_company")); - if (StringUtils.isNotBlank(ecCompany)) { - Long parent_company = Objects.requireNonNull(EcHrmRelationUtil.getJclCompanyId(ecCompany)).getId(); - // 上级分部不能选择本身 - OrganizationAssert.isFalse(parent_company.equals(searchParam.getId()), "上级分部不能选择本身"); - params.put("parent_company", parent_company); - }else{ - params.put("parent_company", ""); + Integer ecCompanyId = Integer.parseInt(Util.null2String(params.get("id"))); + String supSubComId = Util.null2String(params.get("supsubcomid")); + if (StringUtils.isNotBlank(supSubComId)) { + Set disableIds = new HashSet<>(); + disableIds.add(ecCompanyId); + List compPOS = getCompMapper().listChild(Collections.singletonList(ecCompanyId)); + if (CollectionUtils.isNotEmpty(compPOS)) { + addDisableIds(disableIds, compPOS); + } + OrganizationAssert.isFalse(disableIds.contains(Integer.parseInt(supSubComId)), "上级分部不能选择分部本身及其下级分部"); } + new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync(); - // 更新主表数据 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMP, params, "", searchParam.getId()); - // 更新主表拓展表 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_COMPEXT, params, groupId, searchParam.getId()); - //更新明细表 - getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_COMPEXT_DT1, params, searchParam.getId()); - - return searchParam.getId(); + return (long) ecCompanyId; } @Override - public int deleteByIds(Collection ids) { + public Map deleteByIds(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); - Map map = new HashMap<>(); - for (Long id : ids) { - map.put("id", id); - new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.CANCELED, map).sync(); - // 删除拓展表、明细表 - MapperProxyFactory.getProxy(ExtMapper.class).deleteByID("jcl_org_compext", id); - MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_compext_dt1", id); - } - return getCompMapper().deleteByIds(ids); + return ServiceUtil.getService(OrganizationServiceImpl.class, user).delSubCompany(params, user); } @Override - public Map getSearchCondition(Map params) { + public Map getSearchCondition() { Map apiDatas = new HashMap<>(); List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); // 编号 - SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "compNo"); + SearchConditionItem subCompanyCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "subCompanyCode"); // 名称 - SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "compName"); + SearchConditionItem subCompanyDescItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "subCompanyDesc"); // 简称 - SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "compNameShort"); + SearchConditionItem subCompanyNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "subCompanyName"); // 上级公司 - SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "164", "ecCompany", ""); - // 组织机构代码 - SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode"); - // 行业 - SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", ""); - // 负责人 - SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", ""); - // 禁用标记 - List selectOptions = new ArrayList<>(); - SearchConditionOption enableOption = new SearchConditionOption("true", "启用"); - SearchConditionOption disableOption = new SearchConditionOption("false", "禁用"); - selectOptions.add(enableOption); - selectOptions.add(disableOption); - SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag"); - - conditionItems.add(compNoItem); - conditionItems.add(compNameItem); - conditionItems.add(compNameShortItem); - conditionItems.add(compBrowserItem); - conditionItems.add(orgCodeItem); - conditionItems.add(industryItem); - conditionItems.add(compPrincipalItem); - conditionItems.add(forbiddenTagItem); + SearchConditionItem supSubComIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "supSubComId", ""); + conditionItems.add(subCompanyCodeItem); + conditionItems.add(subCompanyDescItem); + conditionItems.add(subCompanyNameItem); + conditionItems.add(supSubComIdItem); addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems)); apiDatas.put("conditions", addGroups); return apiDatas; @@ -291,62 +187,169 @@ public class CompServiceImpl extends Service implements CompService { @Override public Map getCompBaseForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); - // 2编辑 1查看 + Map retMap = new HashMap<>(); + List groupList = new ArrayList<>(); + List itemList; + + String id = Util.null2String(params.get("id")); int viewAttr = Integer.parseInt((String) params.get("viewAttr")); - long id = Long.parseLong((String) params.get("id")); - String groupId = (String) params.get("viewCondition"); - HashMap buttonsMap = new HashMap<>(); - buttonsMap.put("hasEdit", true); - buttonsMap.put("hasSave", true); + if (2 == viewAttr) { + params.put("viewattr", viewAttr); + groupList = getCompanyConditionGroups(true, params); + } else { + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem; + HrmFieldBean hrmFieldBean; + HrmDeptFieldManagerE9 hfm; + try { + hfm = new HrmDeptFieldManagerE9(4); + } catch (Exception e) { + throw new RuntimeException(e); + } - List addGroups = new ArrayList<>(); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); - } - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId), "1"); + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) { + String groupId = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupId); + if (lsField.size() == 0) { + continue; + } + if (hfm.getGroupCount(lsField) == 0) { + continue; + } + if (!"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)))) { + continue; + } + + String groupLabel = HrmFieldGroupComInfo.getLabel(groupId); + itemList = new ArrayList<>(); + for (Object o : lsField) { + String fieldId = (String) o; + String isUse = HrmFieldComInfo.getIsused(fieldId); + if (!"1".equals(isUse)) { + continue; + } + String fieldName = HrmFieldComInfo.getFieldname(fieldId); + String fieldLabel = HrmFieldComInfo.getLabel(fieldId); + String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId); + String type = HrmFieldComInfo.getFieldType(fieldId); + String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); + String isSystem = HrmFieldComInfo.getIssystem(fieldId); + String fieldValue; + if ("1".equals(isSystem)) { + fieldValue = hfm.getData(fieldName); + } else { + fieldValue = hfm.getData("hrmsubcompanydefined", fieldName); + } + + if ("84".equals(fieldId)) { + if (user.getUID() != 1) { + continue; + } + fieldValue = "0".equals(fieldValue) ? "" : fieldValue; + } + + if (id.length() > 0 && "subshowid".equals(fieldName)) { + fieldValue = id; + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldId); + hrmFieldBean.setFieldname(fieldName); + hrmFieldBean.setFieldlabel(fieldLabel); + hrmFieldBean.setFieldhtmltype(fieldHtmlType); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlUrl); + hrmFieldBean.setIssystem("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (searchConditionItem.getBrowserConditionParam() != null) { + searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr); + } + if ("showorder".equals(fieldName)) { + searchConditionItem.setPrecision(2); + } + + if ("6".equals(fieldHtmlType)) {//附件 + Map otherParams1 = new HashMap<>(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + + searchConditionItem.setViewAttr(viewAttr); + itemList.add(searchConditionItem); + } - if (CollectionUtils.isNotEmpty(extendTitles)) { - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_COMP : JCL_ORG_COMPEXT, viewAttr, id, extendTitle.getId() + "", ""); - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); + int operateLevel; + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmDetachAble = manageDetachComInfo.isUseHrmManageDetach(); + if (hrmDetachAble) { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + operateLevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmSubCompanyEdit:Edit", Integer.parseInt(id)); + } else { + operateLevel = 2; } + + if (tmp == 0 && HrmUserVarify.checkUserRight("HrmSubCompanyEdit:Edit", user) && operateLevel > 0) { + int resourceNum = 0; + + String sql; + RecordSet rs = new RecordSet(); + sql = "SELECT COUNT(*) FROM hrmresource WHERE subcompanyid1 = " + id + " and ( status =0 or status = 1 or status = 2 or status = 3)"; + rs.execute(sql); + if (rs.next()) { + resourceNum = rs.getInt(1); + } + //4:解聘 5:离职 6:退休 7:无效 + int resourceNum1 = 0; + sql = "SELECT COUNT(*) FROM hrmresource WHERE subcompanyid1 = " + id + " and status in(4,5,6,7)"; + rs.execute(sql); + if (rs.next()) { + resourceNum1 = rs.getInt(1); + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcomResourceInfo"); + hrmFieldBean.setFieldlabel("382428"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(resourceNum + "/" + resourceNum1); + hrmFieldBean.setDmlurl(""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setViewAttr(viewAttr); + itemList.add(searchConditionItem); + } + groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList)); } } + HashMap buttonsMap = new HashMap<>(); + buttonsMap.put("hasEdit", true); + buttonsMap.put("hasSave", true); - HashMap resultMap = new HashMap<>(); - resultMap.put("buttons", buttonsMap); - resultMap.put("conditions", addGroups); - resultMap.put("id", id); - // 拓展页面分组 - resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_COMPEXT)); - // 处理明细表 - resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_COMPEXT_DT1, id, viewAttr, false)); - Map apiDatas = new HashMap<>(); + retMap.put("id", id); + retMap.put("conditions", groupList); + retMap.put("buttons", buttonsMap); + List topTabs = new ArrayList<>(); + topTabs.add(TopTab.builder().color("#000000").groupId("4").showcount(false).title("分部信息").viewCondition("4").build()); + retMap.put("tabInfo", topTabs); - apiDatas.put("result", resultMap); + Map apiDatas = new HashMap<>(); + apiDatas.put("result", retMap); return apiDatas; } @Override - public Map getCompSaveForm() { + public Map getCompSaveForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); Map apiDatas = new HashMap<>(); - List addGroups = new ArrayList<>(); - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID, "1"); - if (CollectionUtils.isNotEmpty(extendTitles)) { - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_COMP, 2, extendTitle.getId() + "", "comp_no", RuleCodeType.SUBCOMPANY.getValue(), null); - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); - } - } - } - apiDatas.put("condition", addGroups); + apiDatas.put("condition", getCompanyConditionGroups(false, params)); return apiDatas; } @@ -364,100 +367,191 @@ public class CompServiceImpl extends Service implements CompService { @Override public int moveCompany(DepartmentMoveParam moveParam) { - Long targetCompanyId = moveParam.getCompany(); - //OrganizationAssert.notNull(targetCompanyId, "请选择要转移到的分部"); - Long companyId = moveParam.getId(); + Integer companyId = moveParam.getId(); + Integer targetCompanyId = moveParam.getCompany(); // 判断目标分部是否为它本身以及子元素 - Set disableIds = new HashSet<>(); + Set disableIds = new HashSet<>(); disableIds.add(companyId); - List compPOS = getCompMapper().listChild(DeleteParam.builder().ids(companyId.toString()).build().getIds()); + + List compPOS = getCompMapper().listChild(Collections.singletonList(companyId)); if (CollectionUtils.isNotEmpty(compPOS)) { addDisableIds(disableIds, compPOS); } OrganizationAssert.isFalse(disableIds.contains(targetCompanyId), "请勿选择当前分部本身及其子分部"); - CompPO compPO = getCompMapper().listById(companyId); - compPO.setEcCompany(targetCompanyId); - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(targetCompanyId)); - if (null != jclCompanyId) { - compPO.setParentCompany(jclCompanyId.getId()); + + Map map = new HashMap<>(); + map.put("id", companyId.toString()); + if (null == targetCompanyId) { + map.put("supsubcomid", "0"); } else { - compPO.setParentCompany(null); + map.put("supsubcomid", targetCompanyId.toString()); } - Map map = new HashMap<>(); - map.put("id", compPO.getId()); - map.put("parent_company", compPO.getParentCompany()); - map.put("comp_no", compPO.getCompNo()); - map.put("comp_name_short", compPO.getCompNameShort()); - map.put("comp_name", compPO.getCompName()); - map.put("show_order", compPO.getShowOrder()); new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map).sync(); - return getCompMapper().updateBaseComp(compPO); + return companyId; } /** * 是否为搜索查询 * - * @param compPO + * @param companyPO * @return */ - private boolean isFilter(CompPO compPO) { - return !(StringUtil.isEmpty(compPO.getCompName()) - && StringUtil.isEmpty(compPO.getCompNo()) - && StringUtil.isEmpty(compPO.getCompNameShort()) - && StringUtil.isEmpty(compPO.getOrgCode()) - && null == compPO.getEcCompany() - && null == compPO.getIndustry() - && null == compPO.getCompPrincipal() - && null == compPO.getForbiddenTag()); + private boolean isFilter(CompPO companyPO) { + return StringUtils.isNotBlank(companyPO.getSubCompanyCode()) || StringUtils.isNotBlank(companyPO.getSubCompanyDesc()) || StringUtils.isNotBlank(companyPO.getSubCompanyName()) || null != companyPO.getSupSubComId(); } - /** - * 判断编号是否重复 - * - * @return - */ - public static String repeatDetermine(String compNo) { - CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue()); - if (StringUtils.isNotBlank(compNo)) { - compNo = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, compNo); - List list = getCompMapper().listByNo(Util.null2String(compNo)); - OrganizationAssert.isEmpty(list, "编号不允许重复"); - } else { - if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { - compNo = autoCreateCompanyNo(); - } - } - return compNo; - } - - /** - * 自动编号处理 - * - * @return - */ - private static String autoCreateCompanyNo() { - String generateCode = CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, ""); - List list = getCompMapper().listByNo(Util.null2String(generateCode)); - if (CollectionUtils.isNotEmpty(list)) { - generateCode = autoCreateCompanyNo(); - } - return generateCode; - } - /** * 添加子元素ID * * @param disableIds * @param compPOS */ - private void addDisableIds(Set disableIds, List compPOS) { + private void addDisableIds(Set disableIds, List compPOS) { for (CompPO compPO : compPOS) { disableIds.add(compPO.getId()); - List childCompPOS = getCompMapper().listChild(DeleteParam.builder().ids(compPO.getId().toString()).build().getIds()); + List childCompPOS = getCompMapper().listChild(Collections.singletonList(compPO.getId())); addDisableIds(disableIds, childCompPOS); } } + private List getCompanyConditionGroups(Boolean showAll, Map params) { + String id = Util.null2String(params.get("id")); + int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1); + + String addType = Util.null2String(params.get("addType")); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String supSubComId = ""; + if ("sibling".equals(addType)) { + supSubComId = subCompanyComInfo.getSupsubcomid(id); + } else if ("child".equals(addType)) { + supSubComId = id; + } + if (StringUtils.isNotBlank(addType)) { + id = ""; + } + + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + + + HrmDeptFieldManagerE9 hfm; + try { + hfm = new HrmDeptFieldManagerE9(4); + } catch (Exception e) { + throw new OrganizationRunTimeException(""); + } + hfm.isReturnDecryptData(true); + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + List groupList = new ArrayList<>(); + int lsSize = 1; + if (showAll && lsGroup != null) { + lsSize = lsGroup.size(); + } + for (int tmp = 0; tmp < lsSize; tmp++) { + String groupId = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupId); + + boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId))); + String groupLabel = HrmFieldGroupComInfo.getLabel(groupId); + List itemList = new ArrayList<>(); + for (Object o : lsField) { + String fieldId = (String) o; + String fieldName = HrmFieldComInfo.getFieldname(fieldId); + String isUse = HrmFieldComInfo.getIsused(fieldId); + String isSystem = HrmFieldComInfo.getIssystem(fieldId); + if (!"1".equals(isUse)) { + continue; + } + int tmpViewAttr = viewAttr; + String rules = ""; + String fieldLabel = HrmFieldComInfo.getLabel(fieldId); + String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId); + String type = HrmFieldComInfo.getFieldType(fieldId); + String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); + String fieldValue = ""; + if (StringUtils.isBlank(addType)) { + if ("1".equals(isSystem)) { + fieldValue = hfm.getData(fieldName); + } else { + fieldValue = hfm.getData("hrmsubcompanydefined", fieldName); + } + } + + if (!groupHide && tmpViewAttr == 2 && "1".equals(HrmFieldComInfo.getIsmand(fieldId))) { + tmpViewAttr = 3; + if ("1".equals(fieldHtmlType) && "2".equals(type)) { + rules = "required|integer"; + } else { + rules = "required|string"; + } + } + + if ("84".equals(fieldId)) { + if (user.getUID() != 1) { + continue; + } + fieldValue = "0".equals(fieldValue) ? "" : fieldValue; + } + if (supSubComId.length() > 0 && "supsubcomid".equals(fieldName)) { + fieldValue = supSubComId; + } + + if ("subshowid".equals(fieldName)) { + if (StringUtils.isNotBlank(addType)) { + continue; + } else { + fieldValue = id; + tmpViewAttr = 1; + } + } + + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldId); + hrmFieldBean.setFieldname(fieldName); + hrmFieldBean.setFieldlabel(fieldLabel); + hrmFieldBean.setFieldhtmltype(fieldHtmlType); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlUrl); + hrmFieldBean.setViewAttr(tmpViewAttr); + hrmFieldBean.setRules(rules); + hrmFieldBean.setIssystem("1"); + if ("supsubcomid".equals(hrmFieldBean.getFieldname())) { + hrmFieldBean.setHideVirtualOrg(true); + } + if ("subcompanycode".equals(hrmFieldBean.getFieldname())) { + hrmFieldBean.setMultilang(false); + } + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (searchConditionItem != null) { + searchConditionItem.setLabelcol(8); + searchConditionItem.setFieldcol(16); + if ("showorder".equals(hrmFieldBean.getFieldname())) { + searchConditionItem.setPrecision(2); + } + if ("subshowid".equals(fieldName)) { + Map otherParams = new HashMap<>(); + otherParams.put("hasBorder", true); + searchConditionItem.setOtherParams(otherParams); + } + + if ("6".equals(fieldHtmlType)) {//附件 + Map otherParams1 = new HashMap<>(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + itemList.add(searchConditionItem); + + } + } + groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList)); + + } + return groupList; + } } diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 19b72323..955c0b36 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -1,18 +1,19 @@ package com.engine.organization.service.impl; -import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrm.entity.RuleCodeType; +import com.engine.hrm.service.impl.OrganizationServiceImpl; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.DeleteParam; +import com.engine.organization.entity.TopTab; import com.engine.organization.entity.codesetting.po.CodeRulePO; -import com.engine.organization.entity.commom.RecordInfo; import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.bo.DepartmentBO; @@ -20,30 +21,19 @@ import com.engine.organization.entity.department.dto.DepartmentListDTO; import com.engine.organization.entity.department.param.*; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; -import com.engine.organization.entity.extend.po.ExtendTitlePO; import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.job.vo.SingleJobTreeVO; -import com.engine.organization.entity.map.JclOrgMap; import com.engine.organization.entity.searchtree.SearchTree; import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.enums.LogModuleNameEnum; -import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.enums.OperateTypeEnum; +import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.mapper.codesetting.CodeRuleMapper; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.extend.ExtDTMapper; -import com.engine.organization.mapper.extend.ExtMapper; -import com.engine.organization.mapper.extend.ExtendTitleMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; -import com.engine.organization.mapper.jclorgmap.JclOrgMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.service.DepartmentService; -import com.engine.organization.service.ExtService; -import com.engine.organization.thread.DepartmentTriggerRunnable; -import com.engine.organization.thread.HrmResourceTriggerRunnable; -import com.engine.organization.thread.JobTriggerRunnable; import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.util.*; import com.engine.organization.util.coderule.CodeRuleUtil; @@ -52,7 +42,6 @@ import com.engine.organization.util.detach.DetachUtil; import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; -import com.engine.organization.util.relation.EcHrmRelationUtil; import com.engine.organization.util.tree.SearchTreeUtil; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; @@ -60,7 +49,14 @@ import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; -import weaver.hrm.User; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.definedfield.HrmDeptFieldManagerE9; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; import java.util.*; import java.util.stream.Collectors; @@ -73,36 +69,8 @@ import java.util.stream.Collectors; **/ public class DepartmentServiceImpl extends Service implements DepartmentService { - /** - * 分组类型 - * 1:分部 - * 2:部门 - * 3:岗位 - */ - private static final String EXTEND_TYPE = "2"; - /** - * 主表 - */ - private static final String JCL_ORG_DEPT = "JCL_ORG_DEPT"; - /** - * 主表拓展表 - */ - private static final String JCL_ORG_DEPTEXT = "JCL_ORG_DEPTEXT"; - /** - * 明细表拓展表 - */ - private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1"; - private static final String RIGHT_NAME = "Department:All"; - /** - * 部门主表title指定ID - */ - private static final Long GROUP_ID = 2L; - - private static final String HRM_DEPARTMENT = "hrmdepartment"; - - private static DepartmentMapper getDepartmentMapper() { return MapperProxyFactory.getProxy(DepartmentMapper.class); } @@ -115,24 +83,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService return MapperProxyFactory.getProxy(CompMapper.class); } - private ExtendTitleMapper getExtendTitleMapper() { - return MapperProxyFactory.getProxy(ExtendTitleMapper.class); - } - - private SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); - } - - private ExtService getExtService(User user) { - return ServiceUtil.getService(ExtServiceImpl.class, user); - } - @Override public PageInfo getDeptListByPid(QuerySingleDeptListParam param) { //1.查询分部下所有部门 - //PageUtil.start(param.getCurrent(), param.getPageSize()); - List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).list("show_order"); + List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).listAll("showOrder"); PageInfo pageInfo = new PageInfo<>(departmentPOS); List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS, param.getParentComp()); PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class); @@ -176,14 +131,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID()); boolean filter = isFilter(departmentPO); PageInfo pageInfos; - String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams()); - List allList = getDepartmentMapper().list(orderSql); - new DetachUtil(user.getUID()).filterDepartmentList(allList); + String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " showorder "); + List allList = getDepartmentMapper().listAll(orderSql); + new DetachUtil(user).filterDepartmentList(allList); // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 List filterDeptPOs = getDepartmentMapper().listByFilter(departmentPO, orderSql); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeptPOs); + new DetachUtil(user).filterDepartmentList(filterDeptPOs); // 添加父级元素 List compListDTOS = DepartmentBO.buildDeptDTOList(allList, filterDeptPOs); List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS); @@ -218,139 +173,48 @@ public class DepartmentServiceImpl extends Service implements DepartmentService @Override public Long saveBaseForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - String deptNo = (String) params.get("dept_no"); - // 判断是否开启自动编号 - deptNo = repeatDetermine(deptNo); - params.put("dept_no", deptNo); - if (StringUtils.isBlank(Util.null2String(params.get("show_order")))) { - Integer maxShowOrder = getDepartmentMapper().getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0; - } - params.put("show_order", maxShowOrder + 1); - } - // 上级分部 - String ecCompany = Util.null2String(params.get("ec_company")); - if (StringUtils.isNotBlank(ecCompany)) { - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecCompany); - if (null != jclCompanyId) { - params.put("parent_comp", jclCompanyId.getId()); - } - } - // 上级部门 - String ecDepartment = Util.null2String(params.get("ec_department")); - if (StringUtils.isNotBlank(ecDepartment)) { - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment); - if (null != jclDepartmentId) { - params.put("parent_dept", jclDepartmentId.getId()); - // 部门不为空,自动指定所属分部 - params.put("parent_comp", jclDepartmentId.getParentComp()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartmentId.getParentComp()))); - } - - } Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, params).sync(); String ecCompanyID = Util.null2String(syncMap.get("id")); OrganizationAssert.isTrue(StringUtils.isNotBlank(ecCompanyID), syncMap.get("message").toString()); - // 查询UUID - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecCompanyID); - params.put("uuid", recordInfo.getUuid()); - return getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", null); + return Long.parseLong(ecCompanyID); } @Override public int updateForbiddenTagById(DeptSearchParam params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - DepartmentPO departmentPO = DepartmentPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build(); - - if (!params.getForbiddenTag()) { - // 判断当前岗位下是否有启用岗位,如有启用岗位,部门无法禁用 - int countUsedInJob = getDepartmentMapper().countUsedInJob(params.getId()); - OrganizationAssert.isTrue(countUsedInJob == 0, "部门存在下级岗位,不能封存"); - } - + DepartmentPO departmentPO = DepartmentPO.builder().id(params.getId()).canceled(params.getForbiddenTag() ? 0 : 1).build(); Map map = new HashMap<>(); - map.put("id", departmentPO.getId()); - map.put("forbiddenTag", departmentPO.getForbiddenTag()); + map.put("id", Util.null2String(departmentPO.getId())); + map.put("forbiddenTag", Util.null2String(departmentPO.getCanceled())); new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync(); - return getDepartmentMapper().updateForbiddenTagById(departmentPO); + return 1; } @Override public Long updateForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - DeptSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), DeptSearchParam.class); - String groupId = (String) params.get("viewCondition"); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); - } - - DepartmentPO oldDept = getDepartmentMapper().getDeptById(searchParam.getId()); - String deptNo = searchParam.getDeptNo(); - if (!deptNo.equals(oldDept.getDeptNo())) { - deptNo = repeatDetermine(deptNo); - params.put("dept_no", deptNo); - } - // 上级分部 - String ecCompany = Util.null2String(params.get("ec_company")); - if (StringUtils.isNotBlank(ecCompany)) { - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecCompany); - if (null != jclCompanyId) { - params.put("parent_comp", jclCompanyId.getId()); + Integer ecDepartmentId = Integer.parseInt(Util.null2String(params.get("id"))); + String supDepId = Util.null2String(params.get("supdepid")); + if (StringUtils.isNotBlank(supDepId)) { + // 不可选择合并的数据,本身及子部门 + Set disableIds = new HashSet<>(); + // 添加选择部门本身 + disableIds.add(ecDepartmentId); + List deptListByPId = getDepartmentMapper().getDeptListByPId(ecDepartmentId); + if (CollectionUtils.isNotEmpty(deptListByPId)) { + addDisableIds(disableIds, deptListByPId); } + OrganizationAssert.isFalse(disableIds.contains(Integer.parseInt(supDepId)), "上级部门不能选择部门本身及其下级部门"); } - // 上级部门 - String ecDepartment = Util.null2String(params.get("ec_department")); - if (StringUtils.isNotBlank(ecDepartment)) { - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment); - if (null != jclDepartmentId) { - // 上级部门不能选择本身 - OrganizationAssert.isFalse(jclDepartmentId.getId().equals(searchParam.getId()), "上级部门不能选择本身"); - params.put("parent_dept", jclDepartmentId.getId()); - // 部门不为空,自动指定所属分部 - params.put("parent_comp", jclDepartmentId.getParentComp()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartmentId.getParentComp()))); - } - } else { - params.put("parent_dept", ""); - } new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync(); - // 更新主表数据 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", searchParam.getId()); - // 更新主表拓展表 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPTEXT, params, groupId, searchParam.getId()); - //更新明细表 - getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, params, searchParam.getId()); - - DepartmentPO newDeptById = getDepartmentMapper().getDeptById(searchParam.getId()); - new DepartmentTriggerRunnable(oldDept, newDeptById).run(); - - Long parentComp = StringUtils.isNotEmpty(Util.null2String(params.get("parent_comp"))) ? Long.parseLong(Util.null2String(params.get("parent_comp"))) : null; - // 刷新岗位所属分部 - refreshJobComp(searchParam.getId(), parentComp); - List childList = getDepartmentMapper().getDeptListByPId(searchParam.getId()); - String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentComp)); - forbiddenChildTag(parentComp, ecCompanyId, childList); - - return searchParam.getId(); + return (long) ecDepartmentId; } @Override - public int deleteByIds(Collection ids) { + public Map deleteByIds(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); - Map map = new HashMap<>(); - - for (Long id : ids) { - map.put("id", id); - new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync(); - // 删除拓展表、明细表 - MapperProxyFactory.getProxy(ExtMapper.class).deleteByID("jcl_org_deptext", id); - MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_deptext_dt1", id); - } - - return getDepartmentMapper().deleteByIds(ids); + return ServiceUtil.getService(OrganizationServiceImpl.class, user).delDepartment(params, user); } @Override @@ -359,35 +223,18 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List addGroups = new ArrayList<>(); List conditionItems = new ArrayList<>(); // 编号 - SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "deptNo"); + SearchConditionItem departmentCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "departmentCode"); // 名称 - SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "departmentName"); - // 简称 - SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort"); + SearchConditionItem departmentNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "departmentName"); // 所属分部 - SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "ecCompany", ""); + SearchConditionItem subCompanyId1Item = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "subCompanyId1", ""); // 上级部门 - SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "4", "ecDepartment", ""); - // 部门负责人 - SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门负责人", "1", "deptPrincipal", ""); - // 显示顺序 - SearchConditionItem showOrderItem = OrganizationFormItemUtil.inputNumberItem(user, 2, 16, 2, "显示顺序", "showOrder"); - // 禁用标记 - List selectOptions = new ArrayList<>(); - SearchConditionOption enableOption = new SearchConditionOption("true", "启用"); - SearchConditionOption disableOption = new SearchConditionOption("false", "禁用"); - selectOptions.add(enableOption); - selectOptions.add(disableOption); - SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag"); - - conditionItems.add(deptNoItem); - conditionItems.add(deptNameItem); - conditionItems.add(deptNameShortItem); - conditionItems.add(parentCompBrowserItem); - conditionItems.add(parentDeptBrowserItem); - conditionItems.add(deptPrincipalBrowserItem); - conditionItems.add(showOrderItem); - conditionItems.add(forbiddenTagItem); + SearchConditionItem supDepIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "4", "supDepId", ""); + + conditionItems.add(departmentCodeItem); + conditionItems.add(departmentNameItem); + conditionItems.add(subCompanyId1Item); + conditionItems.add(supDepIdItem); addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems)); apiDatas.put("conditions", addGroups); @@ -396,87 +243,169 @@ public class DepartmentServiceImpl extends Service implements DepartmentService @Override public Map> getHasRight() { - return MenuBtn.getDatasHasCopy(); + return MenuBtn.getDatasNoBtnColum(); } @Override public Map getDeptBaseForm(Map params) { OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); - // 2编辑 1查看 int viewAttr = Integer.parseInt((String) params.get("viewAttr")); - long id = Long.parseLong((String) params.get("id")); - String groupId = (String) params.get("viewCondition"); - HashMap buttonsMap = new HashMap<>(); - buttonsMap.put("hasEdit", true); - buttonsMap.put("hasSave", true); + List groupList = new ArrayList<>(); + List itemList; + String id = Util.null2String(params.get("id")); + if (2 == viewAttr) { + params.put("viewattr", viewAttr); + groupList = getDepartmentConditionGroups(true, params); + } else { - List addGroups = new ArrayList<>(); + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem; + HrmFieldBean hrmFieldBean; + HrmDeptFieldManagerE9 hfm; + try { + hfm = new HrmDeptFieldManagerE9(5); + } catch (Exception e) { + throw new RuntimeException(e); + } + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) { + String groupId = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupId); + if (lsField.size() == 0) { + continue; + } + if (hfm.getGroupCount(lsField) == 0) { + continue; + } + if (!"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId)))) { + continue; + } + String groupLabel = HrmFieldGroupComInfo.getLabel(groupId); + itemList = new ArrayList<>(); + for (Object o : lsField) { + String fieldId = (String) o; + String isUse = HrmFieldComInfo.getIsused(fieldId); + if (!"1".equals(isUse)) { + continue; + } + String fieldName = HrmFieldComInfo.getFieldname(fieldId); + String fieldLabel = HrmFieldComInfo.getLabel(fieldId); + String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId); + String type = HrmFieldComInfo.getFieldType(fieldId); + String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); + String isSystem = HrmFieldComInfo.getIssystem(fieldId); + String fieldValue; + if ("1".equals(isSystem)) { + fieldValue = hfm.getData(fieldName); + } else { + fieldValue = hfm.getData("hrmdepartmentdefined", fieldName); + } + + if (id.length() > 0 && "showid".equals(fieldName)) { + fieldValue = id; + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldId); + hrmFieldBean.setFieldname(fieldName); + hrmFieldBean.setFieldlabel(fieldLabel); + hrmFieldBean.setFieldhtmltype(fieldHtmlType); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlUrl); + hrmFieldBean.setIssystem("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (searchConditionItem.getBrowserConditionParam() != null) { + searchConditionItem.getBrowserConditionParam().setViewAttr(viewAttr); + } + if ("showorder".equals(fieldName)) { + searchConditionItem.setPrecision(2); + } + + if ("6".equals(fieldHtmlType)) {//附件 + Map otherParams1 = new HashMap<>(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + + searchConditionItem.setViewAttr(viewAttr); + itemList.add(searchConditionItem); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); - } - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId), "1"); - if (CollectionUtils.isNotEmpty(extendTitles)) { - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_DEPT : JCL_ORG_DEPTEXT, viewAttr, id, extendTitle.getId().toString(), ""); + } + + int operateLevel; + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmDetachAble = manageDetachComInfo.isUseHrmManageDetach(); + if (hrmDetachAble) { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + operateLevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmDepartmentEdit:Edit", Integer.parseInt(departmentComInfo.getSubcompanyid1(id))); + } else { + operateLevel = 2; + } - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); + if (tmp == 0 && HrmUserVarify.checkUserRight("HrmDepartmentEdit:Edit", user) && operateLevel > 0) { + int resourceNum = 0; + RecordSet rs = new RecordSet(); + + String sql = "SELECT COUNT(*) FROM hrmresource WHERE departmentid = " + id + " and ( status =0 or status = 1 or status = 2 or status = 3)"; + rs.execute(sql); + if (rs.next()) { + resourceNum = rs.getInt(1); + } + + //4:解聘 5:离职 6:退休 7:无效 + int resourceNum1 = 0; + sql = "SELECT COUNT(*) FROM hrmresource WHERE departmentid = " + id + " and status in(4,5,6,7)"; + rs.execute(sql); + if (rs.next()) { + resourceNum1 = rs.getInt(1); + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deptResourceInfo"); + hrmFieldBean.setFieldlabel("382428"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue(resourceNum + "/" + resourceNum1); + hrmFieldBean.setDmlurl(""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setViewAttr(viewAttr); + itemList.add(searchConditionItem); } + groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(groupLabel, user.getLanguage()), true, itemList)); + } } + HashMap buttonsMap = new HashMap<>(); + buttonsMap.put("hasEdit", true); + buttonsMap.put("hasSave", true); + HashMap resultMap = new HashMap<>(); resultMap.put("buttons", buttonsMap); - resultMap.put("conditions", addGroups); + resultMap.put("conditions", groupList); resultMap.put("id", id); - // 拓展页面分组 - resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_DEPTEXT)); - // 处理明细表 - resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_DEPTEXT_DT1, id, viewAttr, false)); - Map apiDatas = new HashMap<>(); + List topTabs = new ArrayList<>(); + topTabs.add(TopTab.builder().color("#000000").groupId("4").showcount(false).title("部门信息").viewCondition("4").build()); + resultMap.put("tabInfo", topTabs); + Map apiDatas = new HashMap<>(); apiDatas.put("result", resultMap); - return apiDatas; } @Override - public Map getSaveForm(DeptSearchParam param) { + public Map getSaveForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); Map apiDatas = new HashMap<>(); - List addGroups = new ArrayList<>(); - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID, "1"); - if (CollectionUtils.isNotEmpty(extendTitles)) { - Map params = new HashMap<>(); - // 分部 - if (StringUtils.isNotBlank(Util.null2String(param.getSubcompanyid1()))) { - CompPO compPO = getCompMapper().listById(param.getSubcompanyid1()); - if (null != compPO) { - params.put("parent_comp", compPO.getId()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(compPO.getId().toString())); - } - } - // 部门 - if (StringUtils.isNotBlank(Util.null2String(param.getDepartmentid()))) { - DepartmentPO deptById = getDepartmentMapper().getDeptById(param.getDepartmentid()); - if (null != deptById) { - params.put("parent_dept", deptById.getId()); - params.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(deptById.getId().toString())); - params.put("parent_comp", deptById.getParentComp()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(deptById.getParentComp().toString())); - } - } - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_DEPT, 2, extendTitle.getId().toString(), "dept_no", RuleCodeType.DEPARTMENT.getValue(), params); - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); - } - } - } - apiDatas.put("condition", addGroups); + apiDatas.put("condition", getDepartmentConditionGroups(false, params)); return apiDatas; } @@ -491,16 +420,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List condition = new ArrayList<>(); SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "复制到", "164", "company", ""); compBrowserItem.setRules("required|string"); - SearchConditionItem isCheckItem = OrganizationFormItemUtil.selectItem(user, Lists.newArrayList(new SearchConditionOption("1", "")), 2, 5, 10, false, "复制岗位信息", "copyJob"); - isCheckItem.setDetailtype(2); SearchConditionItem copySubDeptItem = OrganizationFormItemUtil.selectItem(user, Lists.newArrayList(new SearchConditionOption("1", "")), 2, 5, 10, false, "复制子部门信息", "copySubDept"); copySubDeptItem.setDetailtype(2); - SearchConditionItem copySubJob = OrganizationFormItemUtil.selectItem(user, Lists.newArrayList(new SearchConditionOption("1", "")), 2, 5, 10, false, "复制子部门岗位信息", "copySubJob"); - copySubJob.setDetailtype(2); condition.add(compBrowserItem); - condition.add(isCheckItem); condition.add(copySubDeptItem); - condition.add(copySubJob); addGroups.add(new SearchConditionGroup("", true, condition)); return addGroups; } @@ -518,58 +441,46 @@ public class DepartmentServiceImpl extends Service implements DepartmentService OrganizationAssert.notBlank(copyParam.getCompany(), "请指定需要复制的公司/分部"); int insertCount = 0; // 需复制的部门 - List idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList()); - Integer maxShowOrder = getDepartmentMapper().getMaxShowOrder(); + List idList = Arrays.stream(copyParam.getIds().split(",")).map(Integer::parseInt).collect(Collectors.toList()); + Double maxShowOrder = getDepartmentMapper().getMaxShowOrder(); maxShowOrder = null == maxShowOrder ? 0 : maxShowOrder; - for (Long departmentId : idList) { + for (Integer departmentId : idList) { // 复制当前部门 - recursionCopyDept(departmentId, null, Long.parseLong(copyParam.getCompany()), maxShowOrder, copyParam.getCopyJob(), copyParam.getCopySubDept(), copyParam.getCopySubJob()); + recursionCopyDept(departmentId, null, Integer.parseInt(copyParam.getCompany()), maxShowOrder, copyParam.getCopyJob(), copyParam.getCopySubDept(), copyParam.getCopySubJob()); } return insertCount; } - private void recursionCopyDept(Long originalDeptId, Long parentDepartmentId, Long companyId, Integer maxShowOrder, String copyJob, String copySubDept, String copySubJob) { + private void recursionCopyDept(Integer originalDeptId, Integer parentDepartmentId, Integer companyId, Double maxShowOrder, String copyJob, String copySubDept, String copySubJob) { // 源部门 DepartmentPO deptById = getDepartmentMapper().getDeptById(originalDeptId); long timeMillis = System.currentTimeMillis(); - deptById.setDeptName(deptById.getDeptName() + "_" + timeMillis); - deptById.setDeptNameShort(deptById.getDeptNameShort() + "_" + timeMillis); // 处理自动编号 - deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), timeMillis)); + deptById.setDepartmentCode(null); // 设置上级分部 - deptById.setParentComp(EcHrmRelationUtil.getJclCompanyId(Util.null2String(companyId)).getId()); - deptById.setEcCompany(companyId); - deptById.setParentDept(parentDepartmentId); - if (null != parentDepartmentId) { - deptById.setEcDepartment(Long.parseLong(EcHrmRelationUtil.getEcDepartmentId(Util.null2String(parentDepartmentId)))); - } + deptById.setSubCompanyId1(companyId); + deptById.setSupDepId(parentDepartmentId); // 显示顺序字段 deptById.setShowOrder(++maxShowOrder); - deptById.setCreator((long) user.getUID()); - deptById.setCreateTime(new Date()); - deptById.setDeptPrincipal(null); + deptById.setUuid(null); // 新增EC表部门 Map syncMap = addEcDepartment(deptById); String ecDepartmentID = Util.null2String(syncMap.get("id")); OrganizationAssert.isTrue(StringUtils.isNotBlank(ecDepartmentID), syncMap.get("message").toString()); - // 查询UUID - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentID); - deptById.setUuid(recordInfo.getUuid()); - getDepartmentMapper().insertIgnoreNull(deptById); // 更新组织架构图 - new DepartmentTriggerRunnable(deptById.getId()).run(); + //TODO new DepartmentTriggerRunnable(deptById.getId()).run(); // 复制当前部门岗位信息 - if ("1".equals(copyJob)) { - List jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(originalDeptId); - jobPOS = jobPOS.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList()); - Integer maxJobOrder = MapperProxyFactory.getProxy(JobMapper.class).getMaxShowOrder(); - if (maxJobOrder == null) { - maxJobOrder = 0; - } - recursionCopyJob(jobPOS, companyId, deptById.getId(), null, maxJobOrder, timeMillis); - } + //if ("1".equals(copyJob)) { + // List jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(originalDeptId); + // jobPOS = jobPOS.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList()); + // Integer maxJobOrder = MapperProxyFactory.getProxy(JobMapper.class).getMaxShowOrder(); + // if (maxJobOrder == null) { + // maxJobOrder = 0; + // } + // recursionCopyJob(jobPOS, companyId, Integer.parseInt(ecDepartmentID), null, maxJobOrder, timeMillis); + //} // 是否复制子部门信息 if ("1".equals(copySubDept)) { @@ -577,13 +488,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List deptListByPId = getDepartmentMapper().getDeptListByPId(originalDeptId); for (DepartmentPO departmentPO : deptListByPId) { // 复制子部门信息、子部门岗位信息 - recursionCopyDept(departmentPO.getId(), deptById.getId(), companyId, maxShowOrder, copySubJob, copySubDept, copySubJob); + recursionCopyDept(departmentPO.getId(), Integer.parseInt(ecDepartmentID), companyId, maxShowOrder, copySubJob, copySubDept, copySubJob); } } } @Override - public List getMergeForm(Long id) { + public List getMergeForm() { List addGroups = new ArrayList<>(); List condition = new ArrayList<>(); SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "合并到部门", "4", "department", ""); @@ -601,19 +512,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService public int mergeDepartment(DepartmentMergeParam mergeParam) { HasRightUtil.hasRight(user, RIGHT_NAME, false); // 被合并部门 - Long ecParamDepartment = mergeParam.getDepartment(); - DepartmentPO targetDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecParamDepartment)); - // map表中合并部门parentID - Long oldParamDepartment = mergeParam.getId(); - DepartmentPO oldDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(oldParamDepartment)); - Integer oldFParentId = null; - if (null != oldDepartment) { - java.sql.Date currentDate = new java.sql.Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new Date())).getTime()); - JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(currentDate, ModuleTypeEnum.departmentfielddefined.getValue().toString(), oldDepartment.getId().toString()); - if (null != jclOrgMap) { - oldFParentId = jclOrgMap.getFParentId(); - } - } + Integer ecParamDepartment = mergeParam.getDepartment(); + DepartmentPO targetDepartment = getDepartmentMapper().getDeptById(ecParamDepartment); + // 断言判断 OrganizationAssert.isFalse(null == targetDepartment, "被合并部门数据有误,暂时无法合并"); @@ -622,7 +523,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService OrganizationAssert.notBlank(mergeParam.getMergeName(), "请输入合并后的名称"); // 不可选择合并的数据,本身及子部门 - Set disableIds = new HashSet<>(); + Set disableIds = new HashSet<>(); // 添加选择部门本身 disableIds.add(mergeParam.getId()); List deptListByPId = getDepartmentMapper().getDeptListByPId(mergeParam.getId()); @@ -635,59 +536,52 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List firstChildDeptList = getDepartmentMapper().getDeptListByPId(mergeParam.getId()); // 更新所属部门、所属分部 for (DepartmentPO departmentPO : firstChildDeptList) { - departmentPO.setParentDept(targetDepartment.getId()); - departmentPO.setEcDepartment(ecParamDepartment); - departmentPO.setParentComp(targetDepartment.getParentComp()); - departmentPO.setEcCompany(targetDepartment.getEcCompany()); + departmentPO.setSupDepId(targetDepartment.getId()); + departmentPO.setSubCompanyId1(targetDepartment.getSubCompanyId1()); updateEcDepartment(departmentPO); - getDepartmentMapper().updateBaseDept(departmentPO); // 更新组织架构图 - new DepartmentTriggerRunnable(departmentPO.getId()).run(); + //TODO new DepartmentTriggerRunnable(departmentPO.getId()).run(); } // 查询该部门一级岗位、更新岗位所属分部、所属部门 - List firstChildJobList = getJobMapper().listJobsByDepartmentId(mergeParam.getId()); - firstChildJobList = firstChildJobList.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList()); + //List firstChildJobList = getJobMapper().listJobsByDepartmentId(mergeParam.getId()); + //firstChildJobList = firstChildJobList.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList()); // 批量更新部门、所属分部 RecordSet rs = new RecordSet(); - String targetEcDeptId = EcHrmRelationUtil.getEcDepartmentId(targetDepartment.getId().toString()); - String mergeEcDeptId = EcHrmRelationUtil.getEcDepartmentId(mergeParam.getId().toString()); - rs.executeUpdate("update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where parent_dept =?", targetDepartment.getParentComp(), targetDepartment.getEcCompany(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId()); + String targetEcDeptId = targetDepartment.getId().toString(); + String mergeEcDeptId = mergeParam.getId().toString(); + //rs.executeUpdate("update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where ec_department =?", targetDepartment.getSubCompanyId1(), targetDepartment.getSubCompanyId1(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId()); // 更新岗位组织架构图 - for (JobPO jobPO : firstChildJobList) { - // 刷新组织架构图 - new JobTriggerRunnable(jobPO.getId()).run(); - } + //for (JobPO jobPO : firstChildJobList) { + // // 刷新组织架构图 + // TODO new JobTriggerRunnable(jobPO.getId()).run(); + //} // 更新当前部门下的人员 - List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(mergeParam.getId().toString()); - rs.executeUpdate("update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =?", targetDepartment.getEcCompany(), targetEcDeptId, mergeEcDeptId); - new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? ,department_id = ?, ec_department = ?where department_id =?", targetDepartment.getParentComp(), targetDepartment.getEcCompany(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId()); - // 更新人员组织架构图 - for (Long hrmResourceId : hrmResourceIds) { - new HrmResourceTriggerRunnable(hrmResourceId).run(); - } + rs.executeUpdate("update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =?", targetDepartment.getSubCompanyId1(), targetEcDeptId, mergeEcDeptId); + //new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? ,department_id = ?, ec_department = ?where department_id =?", targetDepartment.getParentComp(), targetDepartment.getEcCompany(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId()); + //List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(mergeParam.getId().toString()); + //// 更新人员组织架构图 + //for (Long hrmResourceId : hrmResourceIds) { + //TODO new HrmResourceTriggerRunnable(hrmResourceId).run(); + //} // 更新子部门下岗位的所属分部 for (DepartmentPO departmentPO : firstChildDeptList) { List deptList = getDepartmentMapper().getDeptListByPId(departmentPO.getId()); - forbiddenChildTag(targetDepartment.getParentComp(), Util.null2String(targetDepartment.getEcCompany()), deptList); + forbiddenChildTag(targetDepartment.getSubCompanyId1(), deptList); } // 原部门删除 - DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId()); + // DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId()); Map map = new HashMap<>(); - map.put("id", mergeParam.getId()); - new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync(); - // 删除拓展表、明细表 - MapperProxyFactory.getProxy(ExtMapper.class).deleteByID("jcl_org_deptext", mergeParam.getId()); - MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_deptext_dt1", mergeParam.getId()); - getDepartmentMapper().deleteByIds(DeleteParam.builder().ids(mergeParam.getId().toString()).build().getIds()); + map.put("id", Util.null2String(mergeParam.getId())); + // 删除部门 + ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(map, user); // 更新组织架构图 - new DepartmentTriggerRunnable(mergeDepartment).run(); + // TODO new DepartmentTriggerRunnable(mergeDepartment).run(); // 更新部门合并后名称 - targetDepartment.setDeptName(mergeParam.getMergeName()); - targetDepartment.setDeptNameShort(mergeParam.getMergeName()); + targetDepartment.setDepartmentName(mergeParam.getMergeName()); + targetDepartment.setDepartmentMark(mergeParam.getMergeName()); updateEcDepartment(targetDepartment); - getDepartmentMapper().updateBaseDept(targetDepartment); // 更新组织架构图 - new DepartmentTriggerRunnable(oldFParentId,targetDepartment.getId()).run(); + // TODO new DepartmentTriggerRunnable(oldFParentId, targetDepartment.getId()).run(); return 0; } @@ -722,87 +616,76 @@ public class DepartmentServiceImpl extends Service implements DepartmentService DepartmentPO deptById = getDepartmentMapper().getDeptById(moveParam.getId()); // 0:公司/分部 1:部门 if ("0".equals(moveParam.getMoveType())) { - Long company = moveParam.getCompany(); + Integer company = moveParam.getCompany(); OrganizationAssert.notNull(company, "请选择要转移到的分部"); - deptById.setEcCompany(company); - deptById.setParentComp(Objects.requireNonNull(EcHrmRelationUtil.getJclCompanyId(Util.null2String(company))).getId()); - deptById.setParentDept(null); - deptById.setEcDepartment(null); + deptById.setSubCompanyId1(company); + deptById.setSupDepId(null); // 更新组织架构图 - new DepartmentTriggerRunnable(company.toString(),deptById).run(); + //TODO new DepartmentTriggerRunnable(company.toString(), deptById).run(); } else if ("1".equals(moveParam.getMoveType())) { - Long department = moveParam.getDepartment(); - Long departmentId = Objects.requireNonNull(EcHrmRelationUtil.getJclDepartmentId(Util.null2String(department))).getId(); + Integer departmentId = moveParam.getDepartment(); OrganizationAssert.notNull(departmentId, "请选择要转移到的部门"); List deptListByPId = getDepartmentMapper().getDeptListByPId(moveParam.getId()); - Set disableIds = new HashSet<>(); + Set disableIds = new HashSet<>(); disableIds.add(moveParam.getId()); if (CollectionUtils.isNotEmpty(deptListByPId)) { addDisableIds(disableIds, deptListByPId); } OrganizationAssert.isFalse(disableIds.contains(departmentId), "请勿选择当前部门本身及其子部门"); - deptById.setParentDept(departmentId); - deptById.setEcDepartment(department); + deptById.setSupDepId(departmentId); DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(departmentId); - deptById.setParentComp(parentDepartment.getParentComp()); - deptById.setEcCompany(parentDepartment.getEcCompany()); + deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1()); // 更新组织架构图 - new DepartmentTriggerRunnable(Integer.toString(100000000+department.intValue()),deptById).run(); + // TODO new DepartmentTriggerRunnable(Integer.toString(100000000 + department.intValue()), deptById).run(); } // 更新EC部门 updateEcDepartment(deptById); - int updateBaseDept = getDepartmentMapper().updateBaseDept(deptById); // 刷新岗位分部 - refreshJobComp(deptById.getId(), deptById.getParentComp()); + //refreshJobComp(deptById.getId(), deptById.getSubCompanyId1()); List deptList = getDepartmentMapper().getDeptListByPId(deptById.getId()); - String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(Util.null2String(deptById.getParentComp())); // 更新当前部门下的人员 - List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(deptById.getId().toString()); - String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(deptById.getId().toString()); - new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId); - new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", deptById.getParentComp(), ecCompanyId, deptById.getId()); - // 更新人员组织架构图 - for (Long hrmResourceId : hrmResourceIds) { - new HrmResourceTriggerRunnable(hrmResourceId).run(); - } - forbiddenChildTag(deptById.getParentComp(), ecCompanyId, deptList); + // new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", deptById.getSubCompanyId1(), deptById.getId()); + //// 更新人员组织架构图 + //List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(deptById.getId().toString()); + //for (Long hrmResourceId : hrmResourceIds) { + //TODO new HrmResourceTriggerRunnable(hrmResourceId).run(); + //} + forbiddenChildTag(deptById.getSubCompanyId1(), deptList); // 递归更新下级部门、岗位 - return updateBaseDept; + return 1; } /** * 获取所有子部门id * - * @param parentComp + * @param subCompanyId1 * @param deptList */ - void forbiddenChildTag(Long parentComp, String ecCompanyId, List deptList) { + void forbiddenChildTag(Integer subCompanyId1, List deptList) { if (CollectionUtils.isNotEmpty(deptList)) { for (DepartmentPO departmentPO : deptList) { - departmentPO.setParentComp(parentComp); - departmentPO.setEcCompany(Long.parseLong(ecCompanyId)); + departmentPO.setSubCompanyId1(subCompanyId1); // 更新EC表部门 updateEcDepartment(departmentPO); - getDepartmentMapper().updateBaseDept(departmentPO); // 更新组织架构图 - new DepartmentTriggerRunnable(departmentPO.getId()).run(); + // TODO new DepartmentTriggerRunnable(departmentPO.getId()).run(); // 刷新岗位所属分部 - refreshJobComp(departmentPO.getId(), parentComp); + //refreshJobComp(departmentPO.getId(), subCompanyId1); // 更新当前部门下的人员 - List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(departmentPO.getId().toString()); - String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString()); - new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId); - new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", parentComp, ecCompanyId, departmentPO.getId()); - // 更新人员组织架构图 - for (Long hrmResourceId : hrmResourceIds) { - new HrmResourceTriggerRunnable(hrmResourceId).run(); - } + // String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString()); + //new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId); + //new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", parentComp, ecCompanyId, departmentPO.getId()); + //List hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(departmentPO.getId().toString()); + //// 更新人员组织架构图 + //for (Long hrmResourceId : hrmResourceIds) { + //TODO new HrmResourceTriggerRunnable(hrmResourceId).run(); + //} List childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId()); - forbiddenChildTag(parentComp, ecCompanyId, childList); + forbiddenChildTag(subCompanyId1, childList); } } } @@ -814,16 +697,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService * @return */ private boolean isFilter(DepartmentPO departmentPO) { - return !(StringUtil.isEmpty(departmentPO.getDeptNo()) - && StringUtil.isEmpty(departmentPO.getDeptName()) - && StringUtil.isEmpty(departmentPO.getDeptNameShort()) - && null == departmentPO.getEcCompany() - && null == departmentPO.getEcDepartment() - && null == departmentPO.getParentComp() - && null == departmentPO.getParentDept() - && null == departmentPO.getDeptPrincipal() - && null == departmentPO.getShowOrder() - && null == departmentPO.getForbiddenTag()); + return !(StringUtil.isEmpty(departmentPO.getDepartmentCode()) + && StringUtil.isEmpty(departmentPO.getDepartmentName()) + && null == departmentPO.getSubCompanyId1() + && null == departmentPO.getSupDepId() + && null == departmentPO.getDepartmentId()); } @@ -836,18 +714,18 @@ public class DepartmentServiceImpl extends Service implements DepartmentService */ private List getFilterCompany(String id, String keyword) { // 查询部门信息 - Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id); - CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).forbiddenTag(0).build(); - List allCompanys = getCompMapper().list("show_order"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); - List filterComps = getCompMapper().listByFilter(compBuild, "show_order"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); + CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build(); + List allCompanys = getCompMapper().listAll("showOrder"); + new DetachUtil(user).filterCompanyList(allCompanys); + List filterComps = getCompMapper().listByFilter(compBuild, "showOrder"); + new DetachUtil(user).filterCompanyList(filterComps); - Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); + Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); Set builderComps = new HashSet<>(); - for (CompPO compPO : filterComps) { - buildParentComps(compPO, builderComps,allMaps); + for (CompPO companyPO : filterComps) { + buildParentComps(companyPO, builderComps, allMaps); } return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps)); @@ -859,10 +737,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService * @param compPO * @param builderComps */ - private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { + private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { builderComps.add(compPO); - CompPO parentComp = allMaps.get(compPO.getParentCompany()); - if (null != parentComp && 0 == parentComp.getForbiddenTag()) { + CompPO parentComp = allMaps.get(compPO.getSupSubComId()); + if (null != parentComp && (null == parentComp.getCanceled() || 0 == parentComp.getCanceled())) { buildParentComps(parentComp, builderComps, allMaps); } } @@ -879,9 +757,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService List list = getDepartmentMapper().listByNo(Util.null2String(deptNo)); OrganizationAssert.isEmpty(list, "编号不允许重复"); } else { - if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { - deptNo = autoCreateCompanyNo(); - } + OrganizationAssert.isTrue(null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable()), "编号不允许为空"); + deptNo = autoCreateCompanyNo(); } return deptNo; } @@ -900,52 +777,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService return generateCode; } - /** - * 递归复制岗位信息 - * - * @param jobPOS - * @param parentCompId - * @param parentDeptId - * @param orderNum - */ - private void recursionCopyJob(List jobPOS, Long parentCompId, Long parentDeptId, Long currentParentJobId, int orderNum, long timeMillis) { - for (JobPO jobPO : jobPOS) { - orderNum++; - - // 查询源岗位的下级岗位 - List jobsByPid = MapperProxyFactory.getProxy(JobMapper.class).getJobsByPid(jobPO.getId()); - - // 处理自动编号 - jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), timeMillis)); - - // 所属部门赋值 - jobPO.setParentDept(parentDeptId); - String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(parentDeptId.toString()); - if (StringUtils.isNotBlank(ecDepartmentId)) { - jobPO.setEcDepartment(Long.parseLong(ecDepartmentId)); - } - // 所属分部赋值 - jobPO.setEcCompany(parentCompId); - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(parentCompId)); - if (null != jclCompanyId) { - jobPO.setParentComp(jclCompanyId.getId()); - } - // 指定上级岗位 - jobPO.setParentJob(currentParentJobId); - jobPO.setCreator((long) user.getUID()); - jobPO.setCreateTime(new Date()); - jobPO.setShowOrder(orderNum); - MapperProxyFactory.getProxy(JobMapper.class).insertIgnoreNull(jobPO); - // 更新组织架构图 - new JobTriggerRunnable(jobPO.getId()).run(); - // 处理子级元素 - - if (CollectionUtils.isNotEmpty(jobsByPid)) { - recursionCopyJob(jobsByPid, parentCompId, parentDeptId, jobPO.getId(), orderNum, timeMillis); - } - } - } - /** * 更新EC表部门 * @@ -953,14 +784,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService */ private void updateEcDepartment(DepartmentPO departmentPO) { Map map = new HashMap<>(); - map.put("dept_name_short", departmentPO.getDeptNameShort()); - map.put("dept_name", departmentPO.getDeptName()); - map.put("parent_comp", departmentPO.getParentComp()); - map.put("parent_dept", departmentPO.getParentDept()); - map.put("show_order", departmentPO.getShowOrder()); - map.put("dept_no", departmentPO.getDeptNo()); - map.put("dept_principal", departmentPO.getDeptPrincipal()); - map.put("id", departmentPO.getId()); + map.put("departmentmark", departmentPO.getDepartmentMark()); + map.put("departmentname", departmentPO.getDepartmentName()); + map.put("subcompanyid1", Util.null2String(departmentPO.getSubCompanyId1())); + map.put("supdepid", Util.null2String(departmentPO.getSupDepId())); + map.put("showorder", Util.null2String(departmentPO.getShowOrder())); + map.put("departmentcode", departmentPO.getDepartmentCode()); + map.put("coadjutant", Util.null2String(departmentPO.getCoadjutant())); + map.put("id", Util.null2String(departmentPO.getId())); new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).sync(); } @@ -972,30 +803,17 @@ public class DepartmentServiceImpl extends Service implements DepartmentService */ private Map addEcDepartment(DepartmentPO departmentPO) { Map map = new HashMap<>(); - map.put("dept_name_short", departmentPO.getDeptNameShort()); - map.put("dept_name", departmentPO.getDeptName()); - map.put("parent_comp", departmentPO.getParentComp()); - map.put("parent_dept", departmentPO.getParentDept()); - map.put("show_order", departmentPO.getShowOrder()); - map.put("dept_no", departmentPO.getDeptNo()); - map.put("dept_principal", departmentPO.getDeptPrincipal()); - map.put("id", departmentPO.getId()); + map.put("departmentmark", departmentPO.getDepartmentMark()); + map.put("departmentname", departmentPO.getDepartmentName()); + map.put("subcompanyid1", Util.null2String(departmentPO.getSubCompanyId1())); + map.put("supdepid", Util.null2String(departmentPO.getSupDepId())); + map.put("showorder", Util.null2String(departmentPO.getShowOrder())); + map.put("departmentcode", departmentPO.getDepartmentCode()); return new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).sync(); } - /** - * 封存EC表部门 - * - * @param id - */ - private void cancelEcDepartment(Long id) { - Map map = new HashMap<>(); - map.put("id", id); - map.put("forbiddenTag", 1); - new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.CANCELED, map).sync(); - } - private void addDisableIds(Set disableIds, List deptListByPId) { + private void addDisableIds(Set disableIds, List deptListByPId) { for (DepartmentPO departmentPO : deptListByPId) { disableIds.add(departmentPO.getId()); List childDeptPOS = getDepartmentMapper().getDeptListByPId(departmentPO.getId()); @@ -1009,17 +827,145 @@ public class DepartmentServiceImpl extends Service implements DepartmentService * @param parentDepartment * @param parentComp */ - private void refreshJobComp(Long parentDepartment, Long parentComp) { + private void refreshJobComp(Integer parentDepartment, Integer parentComp) { List jobPOS = getJobMapper().listJobsByDepartmentId(parentDepartment); jobPOS = jobPOS.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(jobPOS)) { - String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(parentComp.toString()); - getJobMapper().updateJobCompany(jobPOS.stream().map(JobPO::getId).collect(Collectors.toList()), parentComp, ecCompanyId); - for (JobPO jobPO : jobPOS) { - // 刷新组织架构图 - new JobTriggerRunnable(jobPO.getId()).run(); + getJobMapper().updateJobCompany(jobPOS.stream().map(JobPO::getId).collect(Collectors.toList()), parentComp, parentComp); + } + } + + private List getDepartmentConditionGroups(Boolean showAll, Map params) { + List groupList = new ArrayList<>(); + List itemList; + + String id = Util.null2String(params.get("id")); + int viewAttr = Util.getIntValue(Util.null2String(params.get("viewattr")), 1); + String addType = Util.null2String(params.get("addType")); + String subcompanyid1 = Util.null2String(params.get("subcompanyid1")); + String supDepId = Util.null2String(params.get("departmentid")); + if (StringUtils.isNotBlank(supDepId)) { + subcompanyid1 = new DepartmentComInfo().getSubcompanyid1(supDepId); + } + + + HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem; + HrmFieldBean hrmFieldBean; + HrmDeptFieldManagerE9 hfm; + try { + hfm = new HrmDeptFieldManagerE9(5); + } catch (Exception e) { + throw new OrganizationRunTimeException(""); + } + hfm.isReturnDecryptData(true); + hfm.getCustomData(Util.getIntValue(id)); + List lsGroup = hfm.getLsGroup(); + int lsSize = 1; + if (showAll && lsGroup != null) { + lsSize = lsGroup.size(); + } + for (int tmp = 0; tmp < lsSize; tmp++) { + String groupId = (String) lsGroup.get(tmp); + List lsField = hfm.getLsField(groupId); + + boolean groupHide = lsField.size() == 0 || hfm.getGroupCount(lsField) == 0 || !"1".equals(Util.null2String(HrmFieldGroupComInfo.getIsShow(groupId))); + String grouplabel = HrmFieldGroupComInfo.getLabel(groupId); + itemList = new ArrayList<>(); + for (Object o : lsField) { + String fieldId = (String) o; + String fieldName = HrmFieldComInfo.getFieldname(fieldId); + String isUse = HrmFieldComInfo.getIsused(fieldId); + if (!"1".equals(isUse)) { + continue; + } + int tmpViewAttr = viewAttr; + String rules = ""; + String fieldLabel = HrmFieldComInfo.getLabel(fieldId); + String fieldHtmlType = HrmFieldComInfo.getFieldhtmltype(fieldId); + String type = HrmFieldComInfo.getFieldType(fieldId); + String dmlUrl = Util.null2String(HrmFieldComInfo.getFieldDmlurl(fieldId)); + String isSystem = HrmFieldComInfo.getIssystem(fieldId); + String fieldValue = ""; + if (StringUtils.isBlank(addType)) { + if ("1".equals(isSystem)) { + fieldValue = hfm.getData(fieldName); + } else { + fieldValue = hfm.getData("hrmdepartmentdefined", fieldName); + } + } + + if (!groupHide && tmpViewAttr == 2 && "1".equals(HrmFieldComInfo.getIsmand(fieldId))) { + tmpViewAttr = 3; + if ("1".equals(fieldHtmlType) && "2".equals(type)) { + rules = "required|integer"; + } else { + rules = "required|string"; + } + } + + if (subcompanyid1.length() > 0 && "subcompanyid1".equals(fieldName)) { + fieldValue = subcompanyid1; + } + + if (supDepId.length() > 0 && "supdepid".equals(fieldName)) { + fieldValue = supDepId; + } + + if ("showid".equals(fieldName)) { + if (addType.length() > 0) { + continue; + } else { + fieldValue = id; + tmpViewAttr = 1; + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(fieldId); + hrmFieldBean.setFieldname(fieldName); + hrmFieldBean.setFieldlabel(fieldLabel); + hrmFieldBean.setFieldhtmltype(fieldHtmlType); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setIssystem("1"); + hrmFieldBean.setFieldvalue(fieldValue); + hrmFieldBean.setDmlurl(dmlUrl); + hrmFieldBean.setViewAttr(tmpViewAttr); + hrmFieldBean.setRules(rules); + if ("subcompanyid1".equals(hrmFieldBean.getFieldname()) || "supdepid".equals(hrmFieldBean.getFieldname())) { + hrmFieldBean.setHideVirtualOrg(true); + } + if ("departmentcode".equals(hrmFieldBean.getFieldname())) { + hrmFieldBean.setMultilang(false); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (searchConditionItem != null) { + searchConditionItem.setLabelcol(8); + searchConditionItem.setFieldcol(16); + if ("showorder".equals(fieldName)) { + searchConditionItem.setPrecision(2); + } + if ("showid".equals(fieldName)) { + Map otherParams = new HashMap<>(); + otherParams.put("hasBorder", true); + searchConditionItem.setOtherParams(otherParams); + } + if ("6".equals(fieldHtmlType)) {//附件 + Map otherParams1 = new HashMap<>(); + otherParams1.put("showOrder", false); + searchConditionItem.setOtherParams(otherParams1); + } + itemList.add(searchConditionItem); + + } } + groupList.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage()), true, itemList)); + } + return groupList; } } diff --git a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java index 02b959f3..9e32e22e 100644 --- a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java @@ -29,7 +29,7 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ public XSSFWorkbook resourceExport(List ids) { List hrmResourceVOS ; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if (StringUtils.isBlank(detachUtil.getJclRoleLevels())) { hrmResourceVOS = new ArrayList<>(); @@ -48,14 +48,15 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ // 2.表头(后面动态获取) List> excelSheetData = new ArrayList<>(); - String[] header = { + Object[] header = { HrmI18nUtil.getI18nLabel( 93270, "姓名"), HrmI18nUtil.getI18nLabel( 93272, "部门"), HrmI18nUtil.getI18nLabel( 93274, "分部"), HrmI18nUtil.getI18nLabel( 93275, "移动电话"), HrmI18nUtil.getI18nLabel( 93278, "办公室电话"), HrmI18nUtil.getI18nLabel( 93279, "直接上级")}; - excelSheetData.add(Arrays.asList(header)); + List strings = Arrays.asList(header); + excelSheetData.add(strings); //数据 List> rows = new LinkedList<>(); diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index 93179f7d..7c1db295 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -1,6 +1,8 @@ package com.engine.organization.service.impl; import com.api.browser.bean.SearchConditionItem; +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; import com.engine.core.impl.Service; import com.engine.organization.entity.TopTab; import com.engine.organization.entity.codesetting.po.CodeRulePO; @@ -10,10 +12,11 @@ import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.extend.po.ExtendTitlePO; +import com.engine.organization.entity.personnelcard.po.CardButtonPO; import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.mapper.codesetting.CodeRuleMapper; import com.engine.organization.mapper.extend.*; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; +import com.engine.organization.mapper.personnelcard.CardButtonMapper; import com.engine.organization.service.ExtService; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.DBType; @@ -69,10 +72,8 @@ public class ExtServiceImpl extends Service implements ExtService { return conditionItems; } List readOnlyFieldList = new ArrayList<>(Arrays.asList(readOnlyFields)); - //TODO 细化权限 - if ("4".equals(extendType) && !user.isAdmin()) { - String ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(String.valueOf(id)); - if (Util.null2String(user.getUID()).equals(ecResourceId)) { + if ("4".equals(extendType) && noEditRight(user)) { + if (Util.null2String(user.getUID()).equals(String.valueOf(id))) { List readOnlyList = infoPOList.stream().filter(item -> !"1".equals(Util.null2String(item.getIsModify()))).map(ExtendInfoPO::getFieldName).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(readOnlyList)) { readOnlyFieldList.addAll(readOnlyList); @@ -156,22 +157,25 @@ public class ExtServiceImpl extends Service implements ExtService { } } Map> allFields = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); - //TODO 控制展示权限 boolean checkRight = true; - if ("4".equals(extendType) && !user.isAdmin()) { + if (2 == viewAttr && "4".equals(extendType) && noEditRight(user)) { checkRight = false; - infoPOList.removeIf(item -> !"1".equals(Util.null2String(item.getIsModify()))); + if (Util.null2String(user.getUID()).equals(String.valueOf(id))) { + infoPOList.removeIf(item -> !"1".equals(Util.null2String(item.getIsModify()))); + } else { + infoPOList = new ArrayList<>(); + } } // 查询所有分布模块,拓展明细表信息 Map> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); // 遍历Map,组装数据 + boolean finalCheckRight = checkRight; for (Map.Entry> entry : groupMap.entrySet()) { Map tableMap = new HashMap<>(); tableMap.put("hide", false); tableMap.put("tabname", getExtendGroupMapper().getGroupNameById(Util.null2String(entry.getKey()))); Map tabinfoMap = new HashMap<>(); - //TODO 需优化 tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, entry.getValue(), viewAttr, showLabel)); tabinfoMap.put("rownum", "rownum" + entry.getKey()); @@ -186,14 +190,18 @@ public class ExtServiceImpl extends Service implements ExtService { List> maps = getExtDTMapper().listCompExtDT(tableName, id, fields); maps.removeIf(Objects::isNull); // 兼容Oracle,map的key转换为小写 - boolean finalCheckRight = checkRight; List> collect = maps.stream().map(item -> { Map resultMap = new HashMap<>(); Set keys = item.keySet(); for (String key : keys) { - resultMap.put(key.toLowerCase(), item.get(key)); + Object o = item.get(key); + if (o instanceof Integer) { + resultMap.put(key.toLowerCase(), Integer.toString((int) o)); + } else { + resultMap.put(key.toLowerCase(), o); + } } - resultMap.put("viewAttr", finalCheckRight ? 2 : 1); + resultMap.put("viewAttr", finalCheckRight ? viewAttr : 1); return resultMap; }).collect(Collectors.toList()); tabinfoMap.put("datas", collect); @@ -246,9 +254,6 @@ public class ExtServiceImpl extends Service implements ExtService { value = null; } if (null == value) { - if ("int".equals(collect.get(key).getFieldType())) { - value = null; - } // 兼容sqlServer数据库text字段类型 if ("text".equals(collect.get(key).getFieldType())) { value = ""; @@ -296,7 +301,7 @@ public class ExtServiceImpl extends Service implements ExtService { int rowNum = Util.getIntValue((String) params.get("rownum" + groupId)); if (deleteFlag && rowNum > 0) { // 删除原有明细表数据 - getExtDTMapper().deleteByMainID(tableName, id); + getExtDTMapper().deleteByMainID(tableName, id, groupId); deleteFlag = false; } List filterS = poMaps.get(groupId); @@ -304,11 +309,12 @@ public class ExtServiceImpl extends Service implements ExtService { Map map = new HashMap<>(); for (ExtendInfoPO extendInfoPO : filterS) { if (BROWSER_TYPE.equals(extendInfoPO.getControlType())) { - map.put(extendInfoPO.getFieldName() + "span", params.get(extendInfoPO.getFieldName() + "span_" + i)); + map.put(extendInfoPO.getFieldName() + "span", parseDetailValue(params.get(extendInfoPO.getFieldName() + "span_" + i))); } - map.put(extendInfoPO.getFieldName(), params.get(extendInfoPO.getFieldName() + "_" + i)); + map.put(extendInfoPO.getFieldName(), parseDetailValue(params.get(extendInfoPO.getFieldName() + "_" + i))); } map.put("mainid", id); + map.put("group_id", groupId); map.put("creator", user.getUID()); map.put("delete_type", 0); map.put("create_time", new Date()); @@ -317,4 +323,40 @@ public class ExtServiceImpl extends Service implements ExtService { } } } + + /** + * 转化明细表字段返回到前端的值 + * + * @param obj + * @return + */ + private Object parseDetailValue(Object obj) { + if (null == obj || StringUtils.isBlank(Util.null2String(obj))) { + return null; + } + return obj; + } + + /** + * 判断是否为管理员或者 + * + * @param user + * @return + */ + private boolean noEditRight(User user) { + boolean hasEditRight = user.isAdmin(); + CardButtonPO editButton = MapperProxyFactory.getProxy(CardButtonMapper.class).getEditButton(); + // 非系统管理员判断是否拥有角色 + if (!hasEditRight && null != editButton) { + // 判断是否有这个角色 + HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + List roleIds = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(user.getUID()).split(","))); + List accessRoleIds = new ArrayList<>(Arrays.asList(Util.null2String(editButton.getRoles()).split(","))); + roleIds.retainAll(accessRoleIds); + hasEditRight = CollectionUtils.isNotEmpty(roleIds); + } + + return !hasEditRight; + + } } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index e2af6eab..c8715fa2 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -249,9 +249,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ if (CollectionUtils.isEmpty(titlesByGroupID)) { // 删除整个分组 getExtendGroupMapper().delete(param.getGroupType()); - if (4 == param.getGroupType()) { - getCardAccessService(user).deleteByIds(DeleteParam.builder().ids(param.getGroupType().toString()).build().getIds()); - } + getCardAccessService(user).deleteByIds(DeleteParam.builder().ids(param.getGroupType().toString()).build().getIds()); return 1; } return 0; @@ -339,7 +337,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ fieldTypeObj.add(tmp); fieldType = SystemEnv.getHtmlLabelName(695, user.getLanguage()); fieldType += " " + SystemEnv.getHtmlLabelName(Util.getIntValue(BrowserComInfo.getBrowserlabelid(browserType), 0), user.getLanguage()); - if (browserType.equals("161") || browserType.equals("162") || browserType.equals("256") || browserType.equals("257")) { + if ("161".equals(browserType) || "162".equals(browserType) || "256".equals(browserType) || "257".equals(browserType)) { tmp = new HashMap<>(); tmp.put("value", SelectOptionParam.getCustomBrowserId(customValue)); tmp.put("valueSpan", SelectOptionParam.getCustomBrowserValueSpan(customValue)); @@ -450,7 +448,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ lsComDetialInfo = new ArrayList<>(); comDetialInfo = new HashMap<>(); comDetialInfo.put("label", ""); - comDetialInfo.put("type", fieldHtmlType.equals("5") ? "CUSTOMFIELD" : "TEXT"); + comDetialInfo.put("type", "5".equals(fieldHtmlType) ? "CUSTOMFIELD" : "TEXT"); comDetialInfo.put("width", "60%"); comDetialInfo.put("key", "fieldType"); lsComDetialInfo.add(comDetialInfo); @@ -464,7 +462,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ fieldTypeInfo.add("select"); Map fieldTypeParamInfo = new HashMap<>(); - if (fieldHtmlType.equals("5")) { + if ("5".equals(fieldHtmlType)) { fieldTypeParamInfo.put("datas", SelectOptionParam.getSelectFields(customValue)); fieldTypeParamInfo.put("sort", "horizontal"); diff --git a/src/com/engine/organization/service/impl/GroupServiceImpl.java b/src/com/engine/organization/service/impl/GroupServiceImpl.java index b66a352c..4f6127ec 100644 --- a/src/com/engine/organization/service/impl/GroupServiceImpl.java +++ b/src/com/engine/organization/service/impl/GroupServiceImpl.java @@ -5,7 +5,6 @@ import com.api.browser.bean.SearchConditionItem; import com.engine.core.impl.Service; import com.engine.organization.entity.TopTab; import com.engine.organization.service.GroupService; -import com.engine.organization.thread.GroupTriggerRunnable; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; @@ -83,7 +82,7 @@ public class GroupServiceImpl extends Service implements GroupService { String companyweb = (String) params.get("companyweb"); RecordSet rs = new RecordSet(); boolean executeUpdate = rs.executeUpdate("update HrmCompany set COMPANYNAME = ?,COMPANYDESC=?,COMPANYWEB=? where id = ?", companyname, companydesc, companyweb, id); - new GroupTriggerRunnable(params).run(); + //TODO new GroupTriggerRunnable(params).run(); return executeUpdate; } diff --git a/src/com/engine/organization/service/impl/HrmPersonnelCardServiceImpl.java b/src/com/engine/organization/service/impl/HrmPersonnelCardServiceImpl.java index 060d7ec3..bb319272 100644 --- a/src/com/engine/organization/service/impl/HrmPersonnelCardServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmPersonnelCardServiceImpl.java @@ -3,44 +3,35 @@ package com.engine.organization.service.impl; import com.engine.common.service.HrmCommonService; import com.engine.common.service.impl.HrmCommonServiceImpl; import com.engine.core.impl.Service; -import com.engine.organization.entity.extend.ExtendInfoOperateType; -import com.engine.organization.entity.extend.bo.ExtendGroupBO; -import com.engine.organization.entity.extend.param.ExtendInfoParams; -import com.engine.organization.entity.extend.po.ExtendGroupPO; -import com.engine.organization.entity.extend.po.ExtendInfoPO; -import com.engine.organization.entity.extend.po.ExtendTitlePO; import com.engine.organization.entity.personnelcard.*; import com.engine.organization.entity.personnelcard.po.CardAccessPO; import com.engine.organization.entity.personnelcard.po.CardButtonPO; +import com.engine.organization.entity.personnelcard.po.CusTreeFormPO; import com.engine.organization.exception.OrganizationRunTimeException; -import com.engine.organization.mapper.extend.ExtMapper; -import com.engine.organization.mapper.extend.ExtendGroupMapper; -import com.engine.organization.mapper.extend.ExtendInfoMapper; -import com.engine.organization.mapper.extend.ExtendTitleMapper; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; import com.engine.organization.mapper.personnelcard.CardAccessMapper; import com.engine.organization.mapper.personnelcard.CardButtonMapper; import com.engine.organization.mapper.personnelcard.PersonnelCardMapper; import com.engine.organization.service.HrmPersonnelCardService; import com.engine.organization.util.OrganizationAssert; -import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.field.FieldDefinedValueUtil; import com.engine.portal.biz.constants.ModuleConstants; import com.engine.portal.biz.nonstandardfunction.SysModuleInfoBiz; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.json.JSONObject; import weaver.blog.BlogShareManager; +import weaver.conn.RecordSet; import weaver.cowork.CoworkShareManager; import weaver.crm.CrmShareBase; import weaver.docs.search.DocSearchComInfo; import weaver.general.BaseBean; import weaver.general.Util; +import weaver.hrm.definedfield.HrmFieldManager; import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; import weaver.workflow.search.WorkflowRequestUtil; import java.util.*; -import java.util.stream.Collectors; /** * @author:dxfeng @@ -48,32 +39,11 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnelCardService { - private static final String IS_SHOW = "1"; private PersonnelCardMapper getPersonnelCardMapper() { return MapperProxyFactory.getProxy(PersonnelCardMapper.class); } - private ExtendGroupMapper getExtendGroupMapper() { - return MapperProxyFactory.getProxy(ExtendGroupMapper.class); - } - - private ExtendTitleMapper getExtendTitleMapper() { - return MapperProxyFactory.getProxy(ExtendTitleMapper.class); - } - - private ExtendInfoMapper getExtendInfoMapper() { - return MapperProxyFactory.getProxy(ExtendInfoMapper.class); - } - - private ExtMapper getExtMapper() { - return MapperProxyFactory.getProxy(ExtMapper.class); - } - - private HrmResourceMapper getHrmResourceMapper() { - return MapperProxyFactory.getProxy(HrmResourceMapper.class); - } - private CardButtonMapper getCardButtonMapper() { return MapperProxyFactory.getProxy(CardButtonMapper.class); } @@ -84,30 +54,38 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel Map resultMap = new HashMap<>(); UserCard userInfo; if (null == uId) { - uId = getHrmResourceMapper().getJclResourceId(Util.null2String(user.getUID())); + uId = (long) user.getUID(); } - String ecResourceId = getHrmResourceMapper().getEcResourceId(uId.toString()); userInfo = getPersonnelCardMapper().getUserById(uId); - userInfo.setEcId(ecResourceId); + userInfo.setEcId(uId.toString()); OrganizationAssert.notNull(uId, "未找到对应数据"); // 人员基本信息 // 统计报表 - Statistical statistical = getStatistical(ecResourceId); - List extendGroupList = getExtendGroupMapper().listByType(4, IS_SHOW); - // 过滤卡片权限 - extendGroupList.removeIf(item -> !hasGroupAccess(item.getId().intValue(), ecResourceId)); + Statistical statistical = getStatistical(userInfo.getEcId()); - // 获取所有模块的信息 + // 获取类型分组信息 + List cusTreeForms = getPersonnelCardMapper().getCusTreeForms(0); + cusTreeForms.removeIf(item -> !hasGroupAccess(item.getId(), userInfo.getEcId())); List formItemList = new ArrayList<>(); - for (ExtendGroupPO groupPO : extendGroupList) { - FormItem formItem = getFormItem(groupPO, uId); - if (CollectionUtils.isEmpty(formItem.getItems())) { - continue; + try { + for (CusTreeFormPO cusTreeForm : cusTreeForms) { + FormItem formItem = getFormItem(cusTreeForm, uId); + if (CollectionUtils.isEmpty(formItem.getItems())) { + continue; + } + + //TODO 明细表暂不处理 + //List> detailList = ServiceUtil.getService(ExtServiceImpl.class, user).getExtendTables(user, "4", groupPO.getId(), "JCL_ORG_HRMRESOURCEEXT_DT1", uId, 1, false); + //formItem.setTables(detailList); + + formItemList.add(formItem); } - formItemList.add(formItem); + } catch (Exception e) { + throw new RuntimeException(e); } + // 所有锚点 List anchorList = new ArrayList<>(); // 添加字段分组信息 @@ -119,7 +97,7 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel for (ResourceBaseTab resourceBaseTab : resourceBaseTabList) { anchorList.add(Anchor.builder().id("tab" + resourceBaseTab.getId()).title(resourceBaseTab.getGroupName()).build()); } - resultMap.put("buttons", getButtonList(ecResourceId)); + resultMap.put("buttons", getButtonList(userInfo.getEcId())); resultMap.put("user", userInfo); resultMap.put("statistical", statistical); resultMap.put("formItems", formItemList); @@ -185,33 +163,58 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel } } - private FormItem getFormItem(ExtendGroupPO extendGroup, Long uId) { + /** + * 获取人员主表信息、拓展表信息 + * + * @param cusTreeFormPO + * @param uId + * @return + * @throws Exception + */ + private FormItem getFormItem(CusTreeFormPO cusTreeFormPO, Long uId) throws Exception { FormItem formItem = new FormItem(); - formItem.setId("group" + extendGroup.getId()); - formItem.setTitle(extendGroup.getGroupName()); - List extendTitleList = getExtendTitleMapper().getTitlesByGroupID(extendGroup.getId(), IS_SHOW); + RecordSet recordSet = new RecordSet(); + formItem.setId(cusTreeFormPO.getId().toString()); + formItem.setTitle(cusTreeFormPO.getFormLabel()); List itemList = new ArrayList<>(); - for (ExtendTitlePO extendTitlePO : extendTitleList) { - List extendInfoList = getExtendInfoMapper().listFields(extendGroup.getExtendType().toString(), extendTitlePO.getId().toString(), ExtendGroupBO.getTableNameByGroupPO(extendGroup), ExtendInfoOperateType.LIST.getValue(), IS_SHOW); - String fields = extendInfoList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); - if (StringUtils.isBlank(fields)) { + HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", cusTreeFormPO.getId()); + hfm.getHrmData(uId.intValue()); + hfm.getCustomFields(); + while (hfm.next()) { + String fieldName = hfm.getFieldname(); + if (!hfm.isUse()) { + continue; + } + JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName); + String fieldLabel = Util.toScreen(SystemEnv.getHtmlLabelName(hrmFieldConf.getInt("fieldlabel"), user.getLanguage()), user.getLanguage()); + if ("resourceimageid".equals(fieldName) || "messagerurl".equals(fieldName) || "职等职级".equals(fieldLabel)) { continue; } - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName(ExtendGroupBO.getTableNameByGroupPO(extendGroup)).fields(fields).params(null).id(uId).build(); - Map fieldValueMap = getExtMapper().listExt(infoParams); - for (ExtendInfoPO extendInfoPO : extendInfoList) { - String fieldShowName = ""; - if (null != fieldValueMap) { - Object fieldValue; - if (DBType.isOracle()) { - fieldValue = fieldValueMap.get(extendInfoPO.getFieldName().toUpperCase()); - } else { - fieldValue = fieldValueMap.get(extendInfoPO.getFieldName()); + String hrmData = ""; + if (hfm.isBaseField(fieldName)) { + if ("jobactivity".equals(fieldName)) { + recordSet.execute("SELECT h1.ID AS jobactivity FROM HRMJOBTITLES h INNER JOIN HRMJOBACTIVITIES h1 ON h.JOBACTIVITYID = h1.ID WHERE h.ID = '" + hfm.getHrmData("jobtitle") + "'"); + if (recordSet.next()) { + hrmData = recordSet.getString(fieldName); + // 职务浏览按钮:282 + hrmFieldConf.put("type", 282); } - fieldShowName = FieldDefinedValueUtil.getFieldValue(user, extendInfoPO, Util.null2String(fieldValue)); + } else if ("jobGroupId".equals(fieldName)) { + recordSet.execute("SELECT h2.ID AS jobGroupId FROM HRMJOBTITLES h INNER JOIN HRMJOBACTIVITIES h1 ON h.JOBACTIVITYID = h1.ID INNER JOIN HRMJOBGROUPS h2 ON h1.JOBGROUPID = h2.ID WHERE h.ID = '" + hfm.getHrmData("jobtitle") + "'"); + if (recordSet.next()) { + hrmData = recordSet.getString(fieldName); + } + } else { + hrmData = hfm.getHrmData(fieldName); + } + } else { + recordSet.execute("select " + fieldName + " from cus_fielddata where SCOPE = '" + cusTreeFormPO.getScope() + "' and SCOPEID =" + cusTreeFormPO.getId() + " and id = " + uId); + if (recordSet.next()) { + hrmData = recordSet.getString(fieldName); } - itemList.add(Item.builder().fieldId(extendInfoPO.getFieldNameDesc()).fieldValue(fieldShowName).build()); } + String fieldValue = hfm.getFieldvalue(null, user, null, hrmFieldConf.getString("dmlurl"), hrmFieldConf.getInt("id"), hrmFieldConf.getInt("fieldhtmltype"), hrmFieldConf.getInt("type"), hrmData, 0, fieldName); + itemList.add(Item.builder().fieldId(fieldLabel).fieldValue(fieldValue).build()); } formItem.setItems(itemList); return formItem; @@ -228,18 +231,15 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel // 人员信息有误,返回false OrganizationAssert.notBlank(userId, "未获取到对应人员"); - // 系统管理员、查看本人卡片直接返回true - if (user.isAdmin() || userId.equals(String.valueOf(user.getUID()))) { - return true; - } - boolean hasAccess = false; CardAccessPO cardAccessPO = MapperProxyFactory.getProxy(CardAccessMapper.class).selectById(typeId); - if (null == cardAccessPO) { + if (null == cardAccessPO || 0 == cardAccessPO.getStatus()) { + // 未配置相应数据、或者未启用返回false return false; } - // 所有人,返回true - if (1 == cardAccessPO.getAllPeople()) { + + // 系统管理员、查看本人卡片,或者所有人有权限直接返回true + if (user.isAdmin() || userId.equals(String.valueOf(user.getUID())) || 1 == cardAccessPO.getAllPeople()) { return true; } @@ -285,10 +285,10 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel List cardButtonPOS = getCardButtonMapper().listEnableButton(); List buttonList = new ArrayList<>(); HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); - List roleIds = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(user.getUID()).split(","))); for (CardButtonPO cardButton : cardButtonPOS) { + List roleIds = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(user.getUID()).split(","))); List accessRoleIds = new ArrayList<>(Arrays.asList(Util.null2String(cardButton.getRoles()).split(","))); roleIds.retainAll(accessRoleIds); if (isAdmin || (isMySelf && "0".equals(cardButton.getSysDefault())) || CollectionUtils.isNotEmpty(roleIds)) { diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index 4d2aa903..273c9fd6 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -1,60 +1,50 @@ package com.engine.organization.service.impl; -import com.alibaba.fastjson.JSONObject; -import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionType; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; -import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; -import com.engine.hrm.entity.RuleCodeType; import com.engine.hrm.util.face.HrmFaceCheckManager; import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.DeleteParam; -import com.engine.organization.entity.browser.po.CustomBrowserBean; -import com.engine.organization.entity.codesetting.po.CodeRulePO; -import com.engine.organization.entity.commom.RecordInfo; import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.bo.DepartmentBO; import com.engine.organization.entity.department.po.DepartmentPO; -import com.engine.organization.entity.extend.po.ExtendTitlePO; +import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.hrmresource.bo.HrmRelationBO; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; -import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam; +import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; import com.engine.organization.entity.hrmresource.po.HrmRelationPO; -import com.engine.organization.entity.hrmresource.po.HrmResourcePO; +import com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplatePO; +import com.engine.organization.entity.hrmresource.po.SearchTemplatePO; +import com.engine.organization.entity.hrmresource.po.TransferDataPO; import com.engine.organization.entity.hrmresource.vo.HrmResourceVO; +import com.engine.organization.entity.jclimport.po.CusFormFieldPO; import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.searchtree.SearchTree; import com.engine.organization.entity.searchtree.SearchTreeParams; -import com.engine.organization.enums.LogModuleNameEnum; -import com.engine.organization.enums.OperateTypeEnum; -import com.engine.organization.mapper.codesetting.CodeRuleMapper; +import com.engine.organization.enums.HrmGroupEnum; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.extend.ExtendTitleMapper; import com.engine.organization.mapper.hrmresource.HrmRelationMapper; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.mapper.post.PostInfoMapper; -import com.engine.organization.mapper.post.PostMapper; -import com.engine.organization.mapper.resource.ResourceMapper; -import com.engine.organization.mapper.scheme.GradeMapper; -import com.engine.organization.mapper.scheme.LevelMapper; -import com.engine.organization.mapper.scheme.SchemeMapper; -import com.engine.organization.mapper.sequence.SequenceMapper; -import com.engine.organization.service.ExtService; +import com.engine.organization.mapper.resource.HrmResourceMapper; +import com.engine.organization.mapper.resource.JclOrgCustomTemplateMapper; import com.engine.organization.service.HrmResourceService; -import com.engine.organization.thread.HrmResourceTriggerRunnable; -import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationAssert; -import com.engine.organization.util.OrganizationFormItemUtil; -import com.engine.organization.util.coderule.CodeRuleUtil; +import com.engine.organization.util.OrganizationDateUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; @@ -62,14 +52,19 @@ import com.engine.organization.util.page.PageUtil; import com.engine.organization.util.tree.SearchTreeUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.json.JSONException; +import org.json.JSONObject; +import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; -import weaver.hrm.User; +import weaver.hrm.definedfield.HrmFieldManager; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @author:dxfeng @@ -89,58 +84,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic private static final String TYPE_DEPT = "2"; private static final String TYPE_JOB = "3"; - private static final Long GROUP_ID = 4L; - - /** - * 分组类型 - * 1:分部 - * 2:部门 - * 3:岗位 - * 4:人员 - */ - private static final String EXTEND_TYPE = "4"; - - /** - * 主表表名 - */ - private static final String JCL_ORG_HRM = "JCL_ORG_HRMRESOURCE"; - /** - * 主表拓展表 - */ - private static final String JCL_ORG_HRMEXT = "JCL_ORG_HRMRESOURCEEXT"; - /** - * 明细表拓展表 - */ - private static final String JCL_ORG_HRMEXT_DT1 = "JCL_ORG_HRMRESOURCEEXT_DT1"; - - private static final String HRM_RESOURCE = "hrmresource"; - - private static final String RIGHT_NAME = "Roster:All"; - private SchemeMapper getSchemeMapper() { - return MapperProxyFactory.getProxy(SchemeMapper.class); - } - - private LevelMapper getLevelMapper() { - return MapperProxyFactory.getProxy(LevelMapper.class); - } - - private GradeMapper getGradeMapper() { - return MapperProxyFactory.getProxy(GradeMapper.class); - } - - private SequenceMapper getSequenceMapper() { - return MapperProxyFactory.getProxy(SequenceMapper.class); - } - - private PostMapper getPostMapper() { - return MapperProxyFactory.getProxy(PostMapper.class); - } - - private PostInfoMapper getPostInfoMapper() { - return MapperProxyFactory.getProxy(PostInfoMapper.class); - } private HrmRelationMapper getHrmRelationMapper() { return MapperProxyFactory.getProxy(HrmRelationMapper.class); @@ -162,22 +107,19 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic return MapperProxyFactory.getProxy(HrmResourceMapper.class); } - private static ResourceMapper getResourceMapper() { - return MapperProxyFactory.getProxy(ResourceMapper.class); - } - - private ExtendTitleMapper getExtendTitleMapper() { - return MapperProxyFactory.getProxy(ExtendTitleMapper.class); - } - private SystemDataMapper getSystemDataMapper() { return MapperProxyFactory.getProxy(SystemDataMapper.class); } - private ExtService getExtService(User user) { - return ServiceUtil.getService(ExtServiceImpl.class, user); + private JclOrgCustomTemplateMapper getJclOrgCustomTemplateMapper() { + return MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class); } + // 所有满足条件的岗位ID + private List jobTitleList = null; + // 是否 + boolean searchJobTitle = false; + @Override public Map getSearchTree(SearchTreeParams params) { @@ -189,10 +131,61 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } @Override - public Map listPage(HrmResourceSearchParam params) { + public Map listPage(Map params) { OrganizationWeaTable table = new OrganizationWeaTable<>(user, HrmResourceVO.class); String sqlWhere = buildSqlWhere(params); table.setSqlwhere(sqlWhere); + List weaTableColumnList = new ArrayList<>(); + JclOrgCustomTemplatePO jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).queryIsusedTemp("1", String.valueOf(user.getUID())); + String columns = ""; + List fields = new ArrayList<>(); + List allConditions = getAllConditions(); + + if (jclOrgCustomTemplatePO != null) { + if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getBasicFields())) { + columns = jclOrgCustomTemplatePO.getBasicFields(); + } + if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getPersonalFields())) { + columns = columns + "," + jclOrgCustomTemplatePO.getPersonalFields(); + } + if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getWorkFields())) { + columns = columns + "," + jclOrgCustomTemplatePO.getWorkFields(); + } + } else { + //初次使用,无模板初始值 + columns = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_sporder"; + } + + List columnList = Arrays.asList(columns.split(",")); + BigDecimal decimal = new BigDecimal(100 / columnList.size()); + for (SearchConditionGroup allCondition : allConditions) { + List items = allCondition.getItems(); + for (SearchConditionItem item : items) { + String columnName = item.getDomkey()[0]; + fields.add(buildTableSql(columnName) + " as " + buildTableSql(columnName).replace(".", "_")); + + String scopeId = columnName.split("_")[0]; + String fieldName = columnName.substring(columnName.lastIndexOf("_") + 1); + WeaTableColumn weaTableColumn = new WeaTableColumn(); + weaTableColumn.setText(getHrmResourceMapper().queryLabelName(fieldName, scopeId)); + weaTableColumn.setColumn(buildTableSql(columnName).replace(".", "_")); + + weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE); + weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue"); + weaTableColumn.setOtherpara(columnName); + weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%"); + weaTableColumnList.add(weaTableColumn); + } + } + // 增加id字段,跳转人员卡片 + WeaTableColumn weaTableColumn = new WeaTableColumn(); + weaTableColumn.setColumn("id"); + weaTableColumn.setDisplay(WeaBoolAttr.FALSE); + + weaTableColumnList.add(weaTableColumn); + fields.add("t.id"); + table.setBackfields(StringUtils.join(fields, ",")); + table.setColumns(weaTableColumnList); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); @@ -203,161 +196,280 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic public Map getSaveForm() { Map apiDatas = new HashMap<>(); List addGroups = new ArrayList<>(); - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID, "1"); - if (CollectionUtils.isNotEmpty(extendTitles)) { - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_HRM, 2, extendTitle.getId().toString(), null, null, null); - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); - } - } - } apiDatas.put("condition", addGroups); return apiDatas; } @Override public Long saveBaseForm(Map params) { - HasRightUtil.hasRight(user, RIGHT_NAME, false); - String workCode = (String) params.get("work_code"); - // 判断是否开启自动编号 - workCode = repeatDetermine(workCode); - params.put("work_code", workCode); - // 完善新增参数 - completeParams(params); - - // 新增EC人员,新增成功后,新增到聚才林人员表 - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.ADD, params).sync(); - String ecResourceId = Util.null2String(syncMap.get("id")); - OrganizationAssert.isTrue(StringUtils.isNotBlank(ecResourceId), Util.null2String(syncMap.get("message"))); - // 获取人员UUID - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_RESOURCE, ecResourceId); - params.put("uuid", recordInfo.getUuid()); - Long resourceId = getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_HRM, params, "", null); - new HrmResourceTriggerRunnable(resourceId).run(); - return resourceId; + return 0L; } @Override public Map getBaseForm(Map params) { - OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型"); - // 2编辑 1查看 - int viewAttr = Integer.parseInt((String) params.get("viewAttr")); - long id = Long.parseLong((String) params.get("id")); - String groupId = (String) params.get("viewCondition"); + return new HashMap<>(); + } - HashMap buttonsMap = new HashMap<>(); - buttonsMap.put("hasEdit", true); - buttonsMap.put("hasSave", true); + @Override + public int updateForm(Map params) { + return 0; + } - List addGroups = new ArrayList<>(); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); + @Override + public Integer saveSearchTemplate(SearchTemplateParam params) { + // 重复名称校验 + SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getSearchTemplateByName(user.getUID(), params.getShowname()); + OrganizationAssert.isFalse("默认模板".equals(params.getShowname()) || null != searchTemplateByName, "该模板名称已存在"); + SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields()); + if (null == templatePO) { + return -1; } - List extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId), "1"); + templatePO.setName(params.getShowname()); + templatePO.setCreator(user.getUID()); + templatePO.setCreateTime(new Date()); + templatePO.setUpdateTime(new Date()); + getHrmResourceMapper().insertSearchTemplate(templatePO); + return templatePO.getId(); + } - if (CollectionUtils.isNotEmpty(extendTitles)) { - for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_HRM : JCL_ORG_HRMEXT, viewAttr, id, extendTitle.getId() + "", ""); - if (CollectionUtils.isNotEmpty(items)) { - addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); - } + @Override + public void deleteSearchTemplate(Integer id) { + getHrmResourceMapper().deleteSearchTemplate(id, user.getUID()); + } + + @Override + public String getTemplateSelectKeys(Map params) { + String templateId = Util.null2String(params.get("templateId")); + templateId = StringUtils.isBlank(templateId) ? "-1" : templateId; + String type = Util.null2String(params.get("type")); + OrganizationAssert.isTrue(StringUtils.isNotBlank(templateId), "数据有误,未找到对应数据"); + // 判断是否为搜索模板 + SearchTemplatePO searchTemplateById; + List selectKeys; + if ("custom".equals(type)) { + if ("-1".equals(templateId)) { + selectKeys = Arrays.asList("-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid".split(",")); + } else { + searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId); + selectKeys = getSelectKeys(searchTemplateById); + } + } else { + if ("-1".equals(templateId)) { + selectKeys = getAllConditions().get(0).getItems().stream().map(item -> item.getDomkey()[0]).collect(Collectors.toList()); + } else { + searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId); + selectKeys = getSelectKeys(searchTemplateById); } } - HashMap resultMap = new HashMap<>(); - resultMap.put("buttons", buttonsMap); - resultMap.put("conditions", addGroups); - resultMap.put("id", id); - // 拓展页面分组 - resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_HRMEXT)); - // 处理明细表 - resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_HRMEXT_DT1, id, viewAttr, false)); - Map apiDatas = new HashMap<>(); + return StringUtils.join(selectKeys, ","); + } - apiDatas.put("result", resultMap); + @Override + public Map getSearchTemplate(Map params) { + Map returnMap = new HashMap<>(); + String type = Util.null2String(params.get("type")); + int userUID = user.getUID(); + // 根据ID查询所存储的模板 + List templates; + if ("custom".equals(type)) { + templates = getHrmResourceMapper().getCustomTemplatesByUser(userUID); + SearchTemplatePO usedCustomTemplate = getHrmResourceMapper().getUsedCustomTemplateByUser(user.getUID()); + if (null != usedCustomTemplate) { + returnMap.put("templateId", usedCustomTemplate.getId().toString()); + } else { + returnMap.put("templateId", "-1"); + } + } else { + templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID); + } + templates.add(0, SearchTemplateParam.builder().key("-1").showname("默认模板").build()); + returnMap.put("templates", templates); + return returnMap; + } - return apiDatas; + @Override + public Integer saveCustomTemplate(SearchTemplateParam params) { + // 重复名称校验 + SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getCustomTemplateByName(user.getUID(), params.getShowname()); + OrganizationAssert.isFalse("默认模板".equals(params.getShowname()) || null != searchTemplateByName, "该模板名称已存在"); + SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields()); + if (null == templatePO) { + return -1; + } + templatePO.setName(params.getShowname()); + templatePO.setCreator(user.getUID()); + templatePO.setIsused("0"); + templatePO.setCreateTime(new Date()); + templatePO.setUpdateTime(new Date()); + getHrmResourceMapper().insertCustomTemplate(templatePO); + return templatePO.getId(); } @Override - public int updateForm(Map params) { - Long id = Long.parseLong((String) params.get("id")); - String groupId = (String) params.get("viewCondition"); - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); + public Integer updateCustomTemplate(Map params) { + int rowNum = Util.getIntValue((String) params.get("rownum")); + int count = 0; + List allIds = getJclOrgCustomTemplateMapper().listAllId(); + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + List nameList = new ArrayList<>(); + for (int i = 0; i < rowNum; i++) { + String recordIndex = "_" + i; + String name = Util.null2String(params.get("name" + recordIndex)); + if (StringUtils.isNotBlank(name)) { + nameList.add(name); + } + } + + OrganizationAssert.isFalse(new HashSet<>(nameList).size() < nameList.size(), "模板名称不能重复"); + for (int i = 0; i < rowNum; i++) { + String recordIndex = "_" + i; + String id = Util.null2String(params.get("id" + recordIndex)); + String name = Util.null2String(params.get("name" + recordIndex)); + JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO(); + if (StringUtils.isNotBlank(id)) { + // 更新 + long jclId = Long.parseLong(id); + jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).selectByPrimaryKey(jclId); + jclOrgCustomTemplatePO.setName(name); + jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).updateByPrimaryKey(jclOrgCustomTemplatePO); + allIds.remove(jclId); + } else { + //插入 + OrganizationAssert.isFalse("".equals(name), "模板名称不能为空"); + jclOrgCustomTemplatePO.setName(name); + jclOrgCustomTemplatePO.setCreator(user.getUID()); + jclOrgCustomTemplatePO.setCreateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).insert(jclOrgCustomTemplatePO); + } } - // 判断编号是否重复 - String workCode = Util.null2String(params.get("work_code")); - HrmResourcePO resourceById = getResourceMapper().getResourceById(id.toString()); - if (!workCode.equals(resourceById.getWorkCode())) { - workCode = repeatDetermine(workCode); - params.put("work_code", workCode); + if (CollectionUtils.isNotEmpty(allIds)) { + count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).deleteByIds(allIds); } + return count; + } - // 完善更新参数 - completeParams(params); + @Override + public void deleteCustomTemplate(Integer id) { + getHrmResourceMapper().deleteCustomTemplate(id, user.getUID()); + } - // 更新EC人员,更新成功后,更新聚才林人员表 - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.UPDATE, params).sync(); - String ecResourceId = Util.null2String(syncMap.get("id")); - OrganizationAssert.isTrue(StringUtils.isNotBlank(ecResourceId), Util.null2String(syncMap.get("message"))); + @Override + public Map getCustomTransferData(Map params) { + Map resultMap = new HashMap<>(); + String templateId = StringUtils.isNotBlank(Util.null2String(params.get("templateId"))) ? Util.null2String(params.get("templateId")) : "-1"; + List transferDatas = new ArrayList<>(); + List transferKeys; + List transferOptions = new ArrayList<>(); + List allConditions = getAllConditions(); + AtomicInteger idx = new AtomicInteger(0); + for (SearchConditionGroup allCondition : allConditions) { + List items = allCondition.getItems(); + List collect = items.stream().map(item -> TransferDataPO.builder().id(item.getDomkey()[0]).label(item.getLabel()).title(allCondition.getTitle()).idx(Integer.toString(idx.get())).build()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + transferDatas.addAll(collect); + } + transferOptions.add(SearchTemplateParam.builder().key(Integer.toString(idx.getAndIncrement())).showname(allCondition.getTitle()).build()); + } + if ("-1".equals(templateId)) { + // 查询当前使用的模板,没有使用的,则展示默认模板 + SearchTemplatePO usedCustomTemplate = getHrmResourceMapper().getUsedCustomTemplateByUser(user.getUID()); + if (null == usedCustomTemplate) { + String selectKeys = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid"; + transferKeys = Arrays.asList(selectKeys.split(",")); + } else { + transferKeys = getSelectKeys(usedCustomTemplate); + templateId = usedCustomTemplate.getId().toString(); + } + } else { + SearchTemplatePO searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId); + transferKeys = getSelectKeys(searchTemplateById); + } + transferOptions.add(0, SearchTemplateParam.builder().key("").showname("").build()); + resultMap.put("transferDatas", transferDatas); + resultMap.put("transferKeys", transferKeys); + resultMap.put("transferOptions", transferOptions); + resultMap.put("templateId", templateId); - int updateCount = 0; - // 更新主表数据 - updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_HRM, params, "", id); - // 更新主表拓展表 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_HRMEXT, params, groupId, id); - //更新明细表 - getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_HRMEXT_DT1, params, id); + return resultMap; + } - new HrmResourceTriggerRunnable(id).run(); - return updateCount; + @Override + public Integer saveColumnsCustomTemplate(Map params) { + String columns = Util.null2String(params.get("columns")); + String templateId = Util.null2String(params.get("templateId")); + SearchTemplatePO templatePO = buildSearchTemplateByFields(columns); + JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO(); + if (StringUtils.isNotBlank(templateId)) { + if (templateId.equals("-1")) { + getJclOrgCustomTemplateMapper().updateUsed("0", null, String.valueOf(user.getUID())); + } else { + jclOrgCustomTemplatePO = getJclOrgCustomTemplateMapper().selectByPrimaryKey(Long.parseLong(templateId)); + if (jclOrgCustomTemplatePO != null) { + jclOrgCustomTemplatePO.setId(Integer.valueOf(templateId)); + jclOrgCustomTemplatePO.setBasicFields(templatePO.getBasicFields()); + jclOrgCustomTemplatePO.setPersonalFields(templatePO.getPersonalFields()); + jclOrgCustomTemplatePO.setWorkFields(templatePO.getWorkFields()); + jclOrgCustomTemplatePO.setIsused(1); + //取消已启用模板 + getJclOrgCustomTemplateMapper().updateUsed("0", null, String.valueOf(user.getUID())); + //启用当前模板 + getJclOrgCustomTemplateMapper().updateByPrimaryKeySelective(jclOrgCustomTemplatePO); + } + } + } + return jclOrgCustomTemplatePO.getId(); } @Override public Map getSearchCondition(Map params) { + String templateId = Util.null2String(params.get("templateId")); + String selectKeys = Util.null2String(params.get("selectKeys")); + if (StringUtils.isBlank(templateId)) { + templateId = "-1"; + } Map apiDatas = new HashMap<>(); List addGroups = new ArrayList<>(); - List conditionItems = new ArrayList<>(); - SearchConditionItem lastNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "姓名", "lastName"); - SearchConditionItem jobTitleItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "岗位", "666", "jobTitle", ""); - BrowserBean browserBean = jobTitleItem.getBrowserConditionParam(); - String s = JSONObject.toJSONString(browserBean); - CustomBrowserBean customBrowserBean = JSONObject.parseObject(s, CustomBrowserBean.class); - customBrowserBean.setHasLeftTree(true); - customBrowserBean.setLeftToSearchKey("treeKey"); - jobTitleItem.setBrowserConditionParam(customBrowserBean); - SearchConditionItem companyIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "分部", "164", "ecCompany", ""); - SearchConditionItem departmentIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门", "4", "ecDepartment", ""); - SearchConditionItem telephoneItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "办公电话", "telephone"); - SearchConditionItem mobileItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "移动电话", "mobile"); - - conditionItems.add(lastNameItem); - conditionItems.add(jobTitleItem); - conditionItems.add(companyIdItem); - conditionItems.add(departmentIdItem); - conditionItems.add(telephoneItem); - conditionItems.add(mobileItem); - - addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems)); - apiDatas.put("conditions", addGroups); + List allConditions = getAllConditions(); + // 穿梭框ID,展示所选字段信息 + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + if ("-1".equals(templateId)) { + if (StringUtils.isNotBlank(selectKeys)) { + SearchTemplatePO templatePO = buildSearchTemplateByFields(selectKeys); + if (null != templatePO) { + buildSearchConditionGroup(templatePO, hrmFieldSearchConditionComInfo, addGroups); + } + } else { + // 未选择模板展示默认模板搜索条件 + if (CollectionUtils.isNotEmpty(allConditions)) { + addGroups.add(allConditions.get(0)); + } + } + } else { + // 选择模板则遍历所选模板所选字段 + SearchTemplatePO searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId); + buildSearchConditionGroup(searchTemplateById, hrmFieldSearchConditionComInfo, addGroups); + } + apiDatas.put("defaultcondition", addGroups); + apiDatas.put("conditions", allConditions); return apiDatas; } @Override public Map getHasRight() { Map btnDatas = new HashMap<>(); + ArrayList topMenuList = new ArrayList<>(); + ArrayList rightMenuList = new ArrayList<>(); if (HasRightUtil.hasRight(user, RIGHT_NAME, true)) { - ArrayList topMenuList = new ArrayList<>(); - ArrayList rightMenuList = new ArrayList<>(); topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build()); - btnDatas.put("topMenu", topMenuList); rightMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build()); - rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("custom").menuIcon("icon-coms-task-list").menuName("显示列定制").type("BTN_COLUMN").build()); - rightMenuList.add(MenuBtn.rightMenu_btnLog()); - btnDatas.put("rightMenu", rightMenuList); } + topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("customization").menuIcon("icon-coms-task-list").menuName("列定制").type("BTN_COLUMN").build()); + rightMenuList.add(MenuBtn.rightMenu_btnLog()); + btnDatas.put("topMenu", topMenuList); + btnDatas.put("rightMenu", rightMenuList); btnDatas.put("hasRight", true); return btnDatas; } @@ -371,61 +483,61 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic int viewAttr = Integer.parseInt(viewAttrStr); Map apiDatas = new HashMap<>(); - List addGroups = new ArrayList<>(); - SearchConditionItem schemeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "等级方案", "161", "schemeId", "schemeBrowser"); - schemeId.setRules("required"); - SearchConditionItem gradeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职级", "161", "gradeId", "gradeBrowser"); - gradeId.setRules("required"); - SearchConditionItem levelId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职等", "162", "levelId", "levelBrowser"); - levelId.setRules("required"); - SearchConditionItem sequenceId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位序列", "161", "sequenceId", "sequenceBrowser"); - sequenceId.setRules("required"); - SearchConditionItem postId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务分类", "161", "postId", "postBrowser"); - postId.setRules("required"); - SearchConditionItem postInfoId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务信息", "161", "postInfoId", "postInfoBrowser"); - postInfoId.setRules("required"); - SearchConditionItem companyId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "分部", "164", "companyId", ""); - companyId.setRules("required"); - SearchConditionItem departmentId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "部门", "4", "departmentId", ""); - departmentId.setRules("required"); - SearchConditionItem jobId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位", "161", "jobId", "jobBrowser"); - jobId.setRules("required"); - - - // 编辑状态下赋值操作 - HrmRelationPO relationPO = getHrmRelationMapper().getRelationById(Long.parseLong(id)); - if (null != relationPO) { - setBrowserValue(schemeId, relationPO.getSchemeId(), getSchemeMapper().listSchemesByIds(Stream.of(relationPO.getSchemeId()).collect(Collectors.toList())), null, null); - setBrowserValue(gradeId, relationPO.getGradeId(), getGradeMapper().listGradessByIds(Stream.of(relationPO.getGradeId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId()); - setBrowserValue(levelId, relationPO.getLevelId(), getLevelMapper().listLevelsByIds(DeleteParam.builder().ids(relationPO.getLevelId()).build().getIds()), "grade_id", relationPO.getGradeId()); - setBrowserValue(sequenceId, relationPO.getSequenceId(), getSequenceMapper().listSequencesByIds(Stream.of(relationPO.getSequenceId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId()); - setBrowserValue(postId, relationPO.getPostId(), getPostMapper().listPostsByIds(Stream.of(relationPO.getPostId()).collect(Collectors.toList())), null, null); - setBrowserValue(postInfoId, relationPO.getPostInfoId(), getPostInfoMapper().listPostInfosByIds(Stream.of(relationPO.getPostInfoId()).collect(Collectors.toList())), "post_id", relationPO.getPostId()); - - List> companyMaps = new ArrayList<>(); - String scCompanyNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScCompanyNameById(relationPO.getCompanyId().toString()); - Map companyMap = new HashMap<>(); - companyMap.put(relationPO.getCompanyId().toString(), scCompanyNameById); - companyMaps.add(companyMap); - setBrowserValue(companyId, relationPO.getCompanyId(), companyMaps, null, null); - - List> departmentMaps = new ArrayList<>(); - String departmentNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScDepartmentNameById(relationPO.getDepartmentId().toString()); - Map departmentMap = new HashMap<>(); - departmentMap.put(relationPO.getDepartmentId().toString(), departmentNameById); - departmentMaps.add(departmentMap); - setBrowserValue(departmentId, relationPO.getDepartmentId(), departmentMaps, "subcompany1", relationPO.getCompanyId()); - - setBrowserValue(jobId, relationPO.getJobId(), getJobMapper().listJobsByIds(Stream.of(relationPO.getJobId()).collect(Collectors.toList())), "departmentid", relationPO.getDepartmentId()); - } - - addGroups.add(new SearchConditionGroup("岗职位体系", true, Stream.of(schemeId, gradeId, levelId, sequenceId, postId, postInfoId).collect(Collectors.toList()))); - addGroups.add(new SearchConditionGroup("组织机构", true, Stream.of(companyId, departmentId, jobId).collect(Collectors.toList()))); - HashMap buttonsMap = new HashMap<>(); - buttonsMap.put("hasEdit", true); - buttonsMap.put("hasSave", true); - apiDatas.put("buttons", buttonsMap); - apiDatas.put("conditions", addGroups); + //List addGroups = new ArrayList<>(); + //SearchConditionItem schemeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "等级方案", "161", "schemeId", "schemeBrowser"); + //schemeId.setRules("required"); + //SearchConditionItem gradeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职级", "161", "gradeId", "gradeBrowser"); + //gradeId.setRules("required"); + //SearchConditionItem levelId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职等", "162", "levelId", "levelBrowser"); + //levelId.setRules("required"); + //SearchConditionItem sequenceId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位序列", "161", "sequenceId", "sequenceBrowser"); + //sequenceId.setRules("required"); + //SearchConditionItem postId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务分类", "161", "postId", "postBrowser"); + //postId.setRules("required"); + //SearchConditionItem postInfoId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务信息", "161", "postInfoId", "postInfoBrowser"); + //postInfoId.setRules("required"); + //SearchConditionItem companyId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "分部", "164", "companyId", ""); + //companyId.setRules("required"); + //SearchConditionItem departmentId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "部门", "4", "departmentId", ""); + //departmentId.setRules("required"); + //SearchConditionItem jobId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位", "161", "jobId", "jobBrowser"); + //jobId.setRules("required"); + // + // + //// 编辑状态下赋值操作 + //HrmRelationPO relationPO = getHrmRelationMapper().getRelationById(Long.parseLong(id)); + //if (null != relationPO) { + // setBrowserValue(schemeId, relationPO.getSchemeId(), getSchemeMapper().listSchemesByIds(Stream.of(relationPO.getSchemeId()).collect(Collectors.toList())), null, null); + // setBrowserValue(gradeId, relationPO.getGradeId(), getGradeMapper().listGradessByIds(Stream.of(relationPO.getGradeId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId()); + // setBrowserValue(levelId, relationPO.getLevelId(), getLevelMapper().listLevelsByIds(DeleteParam.builder().ids(relationPO.getLevelId()).build().getIds()), "grade_id", relationPO.getGradeId()); + // setBrowserValue(sequenceId, relationPO.getSequenceId(), getSequenceMapper().listSequencesByIds(Stream.of(relationPO.getSequenceId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId()); + // setBrowserValue(postId, relationPO.getPostId(), getPostMapper().listPostsByIds(Stream.of(relationPO.getPostId()).collect(Collectors.toList())), null, null); + // setBrowserValue(postInfoId, relationPO.getPostInfoId(), getPostInfoMapper().listPostInfosByIds(Stream.of(relationPO.getPostInfoId()).collect(Collectors.toList())), "post_id", relationPO.getPostId()); + // + // List> companyMaps = new ArrayList<>(); + // String scCompanyNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScCompanyNameById(relationPO.getCompanyId().toString()); + // Map companyMap = new HashMap<>(); + // companyMap.put(relationPO.getCompanyId().toString(), scCompanyNameById); + // companyMaps.add(companyMap); + // setBrowserValue(companyId, relationPO.getCompanyId(), companyMaps, null, null); + // + // List> departmentMaps = new ArrayList<>(); + // String departmentNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScDepartmentNameById(relationPO.getDepartmentId().toString()); + // Map departmentMap = new HashMap<>(); + // departmentMap.put(relationPO.getDepartmentId().toString(), departmentNameById); + // departmentMaps.add(departmentMap); + // setBrowserValue(departmentId, relationPO.getDepartmentId(), departmentMaps, "subcompany1", relationPO.getCompanyId()); + // + // setBrowserValue(jobId, relationPO.getJobId(), getJobMapper().listJobsByIds(Stream.of(relationPO.getJobId()).collect(Collectors.toList())), "departmentid", relationPO.getDepartmentId()); + //} + // + //addGroups.add(new SearchConditionGroup("岗职位体系", true, Stream.of(schemeId, gradeId, levelId, sequenceId, postId, postInfoId).collect(Collectors.toList()))); + //addGroups.add(new SearchConditionGroup("组织机构", true, Stream.of(companyId, departmentId, jobId).collect(Collectors.toList()))); + //HashMap buttonsMap = new HashMap<>(); + //buttonsMap.put("hasEdit", true); + //buttonsMap.put("hasSave", true); + //apiDatas.put("buttons", buttonsMap); + //apiDatas.put("conditions", addGroups); return apiDatas; } @@ -459,34 +571,49 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic return hrmRelationPO.getId(); } - /** - * 浏览按钮赋值 - * - * @param browserItem - * @param browserValue - * @param maps - */ - private void setBrowserValue(SearchConditionItem browserItem, Object browserValue, List> maps, String relateField, Object relatedValue) { - browserItem.setValue(browserValue); - BrowserBean browserBean = browserItem.getBrowserConditionParam(); - browserBean.setReplaceDatas(maps); - browserItem.setBrowserConditionParam(browserBean); - - if (StringUtils.isNotBlank(relateField) && 1 != browserItem.getViewAttr()) { - long l = System.currentTimeMillis(); - Map completeParams = browserBean.getCompleteParams(); - completeParams.put("currenttime", l); - completeParams.put(relateField + "_" + l, relatedValue); - Map conditionDataParams = browserBean.getConditionDataParams(); - conditionDataParams.put("currenttime", l); - conditionDataParams.put(relateField + "_" + l, relatedValue); - Map dataParams = browserBean.getDataParams(); - dataParams.put("currenttime", l); - dataParams.put(relateField + "_" + l, relatedValue); - Map destDataParams = browserBean.getDestDataParams(); - destDataParams.put("currenttime", l); - destDataParams.put(relateField + "_" + l, relatedValue); - } + @Override + public Map getCustomTemplate(Map params) { + List infoPOList = new ArrayList<>(); + infoPOList.add(ExtendInfoPO.builder().viewAttr(2).id(null).fieldName("name").fieldNameDesc("模板名称").fieldType("varchar(255)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build()); + infoPOList.add(ExtendInfoPO.builder().viewAttr(1).id(null).fieldName("createTime").fieldNameDesc("创建时间").fieldType("date").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); + Map tabInfoMap = new HashMap<>(); + tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, false, true)); + List jclOrgCustomTemplatePOS = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).listAll(); + List isUsed = new ArrayList<>(); + AtomicInteger index = new AtomicInteger(0); + List> collect = jclOrgCustomTemplatePOS.stream().map(item -> { + Map resultMap = new HashMap<>(); + resultMap.put("id", item.getId()); + resultMap.put("name", item.getName()); + resultMap.put("createTime", DateUtil.getDate(item.getCreateTime(), "yyyy-MM-dd")); + + if (item.getIsused() != null) { + + if (1 == item.getIsused()) { + isUsed.add(index.get()); + } + index.getAndIncrement(); + } + + return resultMap; + }).collect(Collectors.toList()); + + tabInfoMap.put("datas", collect); + tabInfoMap.put("api_status", true); + Map> isUsedMap = new HashMap<>(); + isUsedMap.put("status", isUsed); + tabInfoMap.put("selectedData", isUsedMap); + tabInfoMap.put("isModalEdit", false); + return tabInfoMap; + + +// OrganizationWeaTable table = new OrganizationWeaTable<>(user, JclOrgCustomTemplateVO.class); +// String sqlWhere = buildSqlWhere(params); +// table.setSqlwhere(sqlWhere); +// WeaResultMsg result = new WeaResultMsg(false); +// result.putAll(table.makeDataResult()); +// result.success(); +// return new HashMap<>(result.getResultMap()); } /** @@ -495,72 +622,88 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic * @param params * @return */ - private String buildSqlWhere(HrmResourceSearchParam params) { + private String buildSqlWhere(Map params) { + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + List conditionItems = new ArrayList<>(); + List hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems); + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems); + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems); + Map allFieldsMap = conditionItems.stream().collect(Collectors.toMap(item -> item.getDomkey()[0], item -> item, (k1, k2) -> k1)); + + DBType dbType = DBType.get(new RecordSet().getDBType()); - String sqlWhere = " where 1=1 "; - String lastName = params.getLastName(); - if (StringUtils.isNotBlank(lastName)) { - sqlWhere += " AND t.last_name " + dbType.like(lastName); - } - Long companyId = params.getCompanyId(); - if (null != companyId) { - sqlWhere += " AND t.company_id = '" + companyId + "'"; - } - Long departmentId = params.getDepartmentId(); - if (null != departmentId) { - sqlWhere += " AND t.department_id = '" + departmentId + "'"; - } - Long ecCompany = params.getEcCompany(); - if (null != ecCompany) { - sqlWhere += " AND t.ec_company = '" + ecCompany + "'"; + StringBuilder sb = new StringBuilder(" where 1=1 "); + if (params.containsKey("lastName")) { + // sb.append(" and t.status = 1"); + sb.append(" and t.status < 4"); } - Long ecDepartment = params.getEcDepartment(); - if (null != ecDepartment) { - sqlWhere += " AND t.ec_department = '" + ecDepartment + "'"; - } - String telephone = params.getTelephone(); - if (StringUtils.isNotBlank(telephone)) { - sqlWhere += " AND t.telephone " + dbType.like(telephone); - } - String mobile = params.getMobile(); - if (StringUtils.isNotBlank(mobile)) { - sqlWhere += " AND t.mobile " + dbType.like(mobile); + for (Map.Entry entry : params.entrySet()) { + String key = entry.getKey(); + String value = Util.null2String(entry.getValue()); + if (StringUtils.isBlank(value)) { + continue; + } + if ("lastName".equals(key)) { + sb.append(" and t.lastname ").append(dbType.like(value)); + } + if ("companyId".equals(key)) { + sb.append(" and t.subcompanyid1 ='").append(value).append("'"); + } + if ("departmentId".equals(key)) { + sb.append(" and t.departmentId ='").append(value).append("'"); + } + if ("jobTitle".equals(key)) { + JobPO jobById = getJobMapper().getJobById(Long.parseLong(value)); + if (null != jobById) { + sb.append(" and t.jobtitle ='").append(Util.null2String(jobById.getEcJobTitle())).append("' and t.subcompanyid1 = '").append(Util.null2String(jobById.getEcCompany())).append("' and t.departmentId ='").append(Util.null2String(jobById.getEcDepartment())).append("'"); + } else { + sb = new StringBuilder(" where 1 = 2 "); + break; + } + } + + SearchConditionItem searchConditionItem = allFieldsMap.get(key); + // 根据不同的类型,不同的查询方式 + buildDynamicSql(searchConditionItem, key, value, sb, dbType); } - Long jobTitle = params.getJobTitle(); - if (null != jobTitle) { - sqlWhere += " AND t.job_title = '" + jobTitle + "'"; + if (searchJobTitle) { + String jobTitleIds = StringUtils.join(jobTitleList, ","); + sb.append(" and t.jobtitle in (").append(StringUtils.isNotBlank(jobTitleIds) ? jobTitleIds : "''").append(") "); } // 分权查询 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); String parentCompanyIds = detachUtil.getJclRoleLevels(); if (detachUtil.isDETACH()) { - sqlWhere += " And t.company_id in(" + parentCompanyIds + ")"; + sb.append(" and t.subcompanyid1 in(").append(parentCompanyIds).append(")"); } - return sqlWhere; + return sb.toString(); } public List getFilterCompany(String id, String type, String keyword) { List searchTree = new ArrayList<>(); // 通过分部、公司 组装数据 if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) { - Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id); - DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).build(); - CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build(); + Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); + DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(parentCompId).canceled(0).build(); + CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build(); // 所属分部下的岗位 - JobPO jobBuild = JobPO.builder().jobName(keyword).parentComp(parentCompId).build(); + JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecCompany(parentCompId).forbiddenTag(0).build(); searchTree = buildTreeByCompAndDept(departmentBuild, compBuild, jobBuild); } else if (TYPE_DEPT.equals(type)) { - Long parentDeptId = Long.parseLong(id); - DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentDept(parentDeptId).build(); + Integer parentDeptId = Integer.parseInt(id); + DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).supDepId(parentDeptId).canceled(0).build(); // 所属分部下的岗位 - JobPO jobBuild = JobPO.builder().jobName(keyword).parentDept(parentDeptId).build(); + JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecDepartment(parentDeptId).forbiddenTag(0).build(); searchTree = buildTreeByDeptAndJob(departmentBuild, jobBuild); } else if (TYPE_JOB.equals(type)) { // 查询部门信息 - List filterDeparts = getJobMapper().listPOsByFilter(JobPO.builder().jobName(keyword).parentJob(Long.parseLong(id)).build()); + List filterDeparts = getJobMapper().listPOsByFilter(JobPO.builder().jobTitleName(keyword).parentJob(Long.parseLong(id)).forbiddenTag(0).build()); Set builderJobs = new HashSet<>(); for (JobPO departmentPO : filterDeparts) { buildParentJobs(departmentPO, builderJobs); @@ -580,9 +723,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic */ private List buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) { List jobPOS = getJobMapper().listPOsByFilter(jobBuild); - new DetachUtil(user.getUID()).filterJobList(jobPOS); - List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "show_order"); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts); + new DetachUtil(user).filterJobList(jobPOS); + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + new DetachUtil(user).filterDepartmentList(filterDeparts); // 添加父级岗位 Set builderJobs = new HashSet<>(); for (JobPO jobPO : jobPOS) { @@ -593,7 +736,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(",")); if (!StringUtil.isEmpty(parentDeptS)) { // 兼容SQLServer每次最多in,2100条数据 - List ids = (List) DeleteParam.builder().ids(parentDeptS).build().getIds(); + List ids = DeleteParam.builder().ids(parentDeptS).build().getIds(); int ceilCount = (int) Math.ceil((double) ids.size() / 1000); List departmentsByIds = new ArrayList<>(); for (int i = 1; i < ceilCount + 1; i++) { @@ -611,8 +754,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } // 查询分部信息 - List filterComps = getCompMapper().listByFilter(compBuild, "show_order"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); + new DetachUtil(user).filterCompanyList(filterComps); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { buildParentDepts(departmentPO, builderDeparts); @@ -628,9 +771,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic filterComps.addAll(compsByIds); } } - List allCompanys = getCompMapper().list("show_order"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); - Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); + List allCompanys = getCompMapper().listAll("showorder"); + new DetachUtil(user).filterCompanyList(allCompanys); + Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); Set builderComps = new HashSet<>(); for (CompPO compPO : filterComps) { buildParentComps(compPO, builderComps, allMaps); @@ -640,7 +783,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic private List buildTreeByDeptAndJob(DepartmentPO departmentBuild, JobPO jobBuild) { List jobPOS = getJobMapper().listPOsByFilter(jobBuild); - List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "show_order"); + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); // 添加父级岗位 Set builderJobs = new HashSet<>(); for (JobPO jobPO : jobPOS) { @@ -651,7 +794,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(",")); if (!StringUtil.isEmpty(parentDeptS)) { // 兼容SQLServer每次最多in,2100条数据 - List ids = (List) DeleteParam.builder().ids(parentDeptS).build().getIds(); + List ids = DeleteParam.builder().ids(parentDeptS).build().getIds(); int ceilCount = (int) Math.ceil((double) ids.size() / 1000); List departmentsByIds = new ArrayList<>(); for (int i = 0; i < ceilCount - 1; i++) { @@ -693,10 +836,10 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic */ private void buildParentDepts(DepartmentPO departmentPO, Set builderDeparts) { builderDeparts.add(departmentPO); - if (SearchTreeUtil.isTop(departmentPO.getParentDept())) { + if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) { return; } - DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept()); + DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getSupDepId()); if (null != parentDept) { buildParentDepts(parentDept, builderDeparts); } @@ -708,72 +851,362 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic * @param compPO * @param builderComps */ - private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { + private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { builderComps.add(compPO); - CompPO parentComp = allMaps.get(compPO.getParentCompany()); + CompPO parentComp = allMaps.get(compPO.getSupSubComId()); if (null != parentComp) { buildParentComps(parentComp, builderComps, allMaps); } } - private void completeParams(Map params) { - String jobId = Util.null2String(params.get("job_title")); - if (StringUtils.isNotBlank(jobId)) { - JobPO jobById = getJobMapper().getJobById(Long.parseLong(jobId)); - params.put("department_id", jobById.getParentDept()); - params.put("company_id", jobById.getParentComp()); - params.put("ec_department", jobById.getEcDepartment()); - params.put("ec_company", jobById.getEcCompany()); - // 等级方案、岗位序列、职等、职级 - params.put("scheme_id", jobById.getSchemeId()); - params.put("sequence_id", jobById.getSequenceId()); - params.put("job_level", jobById.getLevelId()); - params.put("job_grade", jobById.getGradeId()); - String showOrder = Util.null2String(params.get("show_order")); - // 初始化排序字段 - if (StringUtils.isBlank(showOrder)) { - Long orderNum = getHrmResourceMapper().getMaxShowOrder(); - params.put("show_order", null == orderNum ? 1 : orderNum + 1); + + /** + * 获取所有搜索字段信息构建的高级搜索表单 + * + * @return + */ + public List getAllConditions() { + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + List addGroups = new ArrayList<>(); + List basicConditionItems = new ArrayList<>(); + List personalConditionItems = new ArrayList<>(); + List workConditionItems = new ArrayList<>(); + + // 基本信息:-1 + List hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, basicConditionItems); + if (CollectionUtils.isNotEmpty(basicConditionItems)) { + addGroups.add(new SearchConditionGroup("基本信息", true, basicConditionItems)); + } + + // 个人信息:1 + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, personalConditionItems); + if (CollectionUtils.isNotEmpty(personalConditionItems)) { + addGroups.add(new SearchConditionGroup("个人信息", true, personalConditionItems)); + } + + // 工作信息:3 + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString()); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, workConditionItems); + if (CollectionUtils.isNotEmpty(workConditionItems)) { + addGroups.add(new SearchConditionGroup("工作信息", true, workConditionItems)); + } + return addGroups; + } + + /** + * 构建查询条件Item + * + * @param hrmFieldSearchConditionComInfo + * @param formFields + * @param conditionItems + */ + private void createConditionItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List formFields, List conditionItems) { + for (CusFormFieldPO cusFormFieldPO : formFields) { + if ("jobactivity".equals(cusFormFieldPO.getFieldName())) { + // 职务:282 + cusFormFieldPO.setType("282"); } + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(Util.null2String(cusFormFieldPO.getFieldId())); + hrmFieldBean.setFieldname(cusFormFieldPO.getScopeId() + "_" + cusFormFieldPO.getTableName() + "_" + cusFormFieldPO.getFieldName()); + hrmFieldBean.setFieldlabel(cusFormFieldPO.getFieldLabel()); + hrmFieldBean.setFieldhtmltype(Util.null2String(cusFormFieldPO.getFieldHtmlType())); + hrmFieldBean.setType(cusFormFieldPO.getType()); + hrmFieldBean.setIsQuickSearch(false); + hrmFieldBean.setIsScope(false); + hrmFieldBean.setDmlurl(cusFormFieldPO.getDmlUrl()); + hrmFieldBean.setIssystem("hrm".equals(cusFormFieldPO.getTableName()) ? "1" : "0"); + hrmFieldBean.setIsFormField(true); + if ("-1_hrm_status".equals(hrmFieldBean.getFieldname())) { + hrmFieldBean.setFieldvalue("1"); + } + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + conditionItems.add(searchConditionItem); + // 如果为下拉框,添加一条空选项 + if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) { + addEmptyForSelect(searchConditionItem); + } + + } + } - // 人员状态 - String status = Util.null2String(params.get("status")); - if (StringUtils.isBlank(status)) { - params.put("status", "0"); + /** + * 获取模板中的字段,构建搜索条件 + * + * @param hrmFieldSearchConditionComInfo + * @param addGroups + * @param title + * @param scopeid + * @param fieldNames + */ + private void getTemplateItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List addGroups, String title, Integer scopeid, String[] fieldNames) { + try { + + HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeid); + List conditionItems = new ArrayList<>(); + for (String field : fieldNames) { + String fieldName = field.substring(field.lastIndexOf("_") + 1); + JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName); + if (null == hrmFieldConf) { + continue; + } + boolean baseField = hfm.isBaseField(fieldName); + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldid(Util.null2String(hrmFieldConf.getString("id"))); + hrmFieldBean.setFieldname(scopeid + "_" + (baseField ? "hrm" : "cus") + "_" + fieldName); + hrmFieldBean.setFieldlabel(hrmFieldConf.getString("fieldlabel")); + hrmFieldBean.setFieldhtmltype(hrmFieldConf.getString("fieldhtmltype")); + hrmFieldBean.setType(hrmFieldConf.getString("type")); + hrmFieldBean.setDmlurl(hrmFieldConf.getString("dmlurl")); + hrmFieldBean.setIssystem(baseField ? "1" : "0"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setIsQuickSearch(false); + hrmFieldBean.setIsScope(false); + if ("jobactivity".equals(fieldName)) { + // 职务:282 + hrmFieldBean.setType("282"); + } + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + conditionItems.add(searchConditionItem); + // 如果为下拉框,添加一条空选项 + if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) { + addEmptyForSelect(searchConditionItem); + } + } + if (CollectionUtils.isNotEmpty(conditionItems)) { + addGroups.add(new SearchConditionGroup(title, true, conditionItems)); } + } catch (JSONException e) { + throw new RuntimeException(e); } } /** - * 判断编号是否重复 + * 根据所选字段信息,构建搜素模板对象 * + * @param fields * @return */ - public static String repeatDetermine(String workCode) { - CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.USER.getValue()); - if (StringUtils.isNotBlank(workCode)) { - workCode = CodeRuleUtil.generateCode(RuleCodeType.USER, workCode); - List list = getResourceMapper().listByNo(Util.null2String(workCode)); - OrganizationAssert.isEmpty(list, "编号不允许重复"); - } else { - if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { - workCode = autoCreateWorkCode(); + private SearchTemplatePO buildSearchTemplateByFields(String fields) { + String[] split = fields.split(","); + if (split.length > 0) { + List basicFields = new ArrayList<>(); + List personalFields = new ArrayList<>(); + List workFields = new ArrayList<>(); + for (String fieldName : split) { + if (fieldName.startsWith(HrmGroupEnum.HRM_BASIC.getGroupType().toString())) { + basicFields.add(fieldName); + } else if (fieldName.startsWith(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString())) { + personalFields.add(fieldName); + } else if (fieldName.startsWith(HrmGroupEnum.HRM_WORK.getGroupType().toString())) { + workFields.add(fieldName); + } + } + return SearchTemplatePO.builder().basicFields(StringUtils.join(basicFields, ",")).personalFields(StringUtils.join(personalFields, ",")).workFields(StringUtils.join(workFields, ",")).build(); + } + return null; + } + + /** + * 根据搜索模板对象,构建搜索条件表单 + * + * @param templatePO + * @param hrmFieldSearchConditionComInfo + * @param addGroups + */ + private void buildSearchConditionGroup(SearchTemplatePO templatePO, HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List addGroups) { + String[] basicFields = Util.null2String(templatePO.getBasicFields()).split(","); + if (basicFields.length > 0) { + getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "基本信息", HrmGroupEnum.HRM_BASIC.getGroupType(), basicFields); + } + + String[] personalFields = Util.null2String(templatePO.getPersonalFields()).split(","); + if (personalFields.length > 0) { + getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "个人信息", HrmGroupEnum.HRM_PERSONAL.getGroupType(), personalFields); + } + String[] workFields = Util.null2String(templatePO.getWorkFields()).split(","); + if (workFields.length > 0) { + getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "工作信息", HrmGroupEnum.HRM_WORK.getGroupType(), workFields); + } + } + + /** + * 根据字段信息,动态拼接where条件SQL + * + * @param conditionItem + * @param key + * @param value + * @param sb + * @param dbType + */ + private void buildDynamicSql(SearchConditionItem conditionItem, String key, String value, StringBuilder sb, DBType dbType) { + if (null == conditionItem) { + return; + } + if (key.endsWith("workyear") || key.endsWith("companyworkyear")) { + conditionItem.setConditionType(ConditionType.INPUTNUMBER); + } + // 职务 + if (key.endsWith("jobactivity")) { + searchJobTitle = true; + List jobTitleIds = getSystemDataMapper().getJobTitleIds(value, null); + if (null == jobTitleList) { + jobTitleList = jobTitleIds; + } else { + jobTitleList.retainAll(jobTitleIds); + } + return; + } + // 职务类别 + if (key.endsWith("jobGroupId")) { + searchJobTitle = true; + List jobTitleIds = getSystemDataMapper().getJobTitleIds(null, value); + if (null == jobTitleList) { + jobTitleList = jobTitleIds; + } else { + jobTitleList.retainAll(jobTitleIds); } + return; + } + // 岗位 + if (key.endsWith("jobtitle")) { + searchJobTitle = true; + jobTitleList = new ArrayList<>(); + jobTitleList.add(Integer.parseInt(value)); + return; + } + String tableSql = buildTableSql(key); + if (StringUtils.isBlank(tableSql)) { + return; + } + switch (conditionItem.getConditionType()) { + case INPUT:// 单行文本框 + case TEXTAREA:// 多行文本框 + sb.append(" and ").append(tableSql).append(dbType.like(value)); + // 模糊搜索 + break; + + case BROWSER://浏览按钮 + // 兼容多选浏览按钮 + sb.append(" and ").append(dbType.concat(tableSql)).append(dbType.like(value)); + break; + + case INPUTNUMBER:// 数字 + case CHECKBOX: + case SWITCH: + sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" = '").append(value).append("' "); + break; + case SELECT://选择框 + if (!"-1".equals(value)) { + if ("t.status".equalsIgnoreCase(tableSql) && "10".equals(value)) { + sb.append(" and ").append(tableSql).append(" < 4 "); + } else { + sb.append(" and ").append(tableSql).append(" = '").append(value).append("' "); + } + } + break; + case DATE: + case DATEPICKER: + case TIMEPICKER: + case RANGEPICKER: + // 精准搜索 + sb.append(" and ").append(tableSql).append(" = '").append(value).append("' "); + break; + default: + break; } - return workCode; } /** - * 自动编号处理 + * 处理当前字段所在表关系 * + * @param key * @return */ - private static String autoCreateWorkCode() { - String generateCode = CodeRuleUtil.generateCode(RuleCodeType.USER, ""); - List list = getResourceMapper().listByNo(Util.null2String(generateCode)); - if (CollectionUtils.isNotEmpty(list)) { - generateCode = autoCreateWorkCode(); + private String buildTableSql(String key) { + StringBuilder sb = new StringBuilder(); + String[] s = key.split("_"); + if (s.length < 3) { + return ""; } - return generateCode; + + String scopeId = s[0]; + String tableName = s[1]; + String fieldName = s[2]; + + if ("jobactivity".equalsIgnoreCase(fieldName)) { + return "t4.id"; + } + if ("jobGroupId".equalsIgnoreCase(fieldName)) { + return "t5.id"; + } + // 姓名点击事件 + if ("lastname".equalsIgnoreCase(fieldName)) { + return "lastname"; + } + + if ("hrm".equals(tableName)) { + return sb.append("t.").append(fieldName).toString(); + } + + switch (scopeId) { + case "-1": + sb.append("t0.").append(fieldName); + break; + case "1": + sb.append("t1.").append(fieldName); + break; + case "3": + sb.append("t2.").append(fieldName); + break; + default: + return ""; + } + return sb.toString(); } + + /** + * 为下拉框搜索条件、添加空选项 + * + * @param searchConditionItem + */ + private void addEmptyForSelect(SearchConditionItem searchConditionItem) { + searchConditionItem.setValue("-1"); + if ("-1_hrm_status".equals(searchConditionItem.getDomkey()[0])) { + // 默认赋值 在职状态 + searchConditionItem.setValue("10"); + } + List options = searchConditionItem.getOptions(); + SearchConditionOption searchConditionOption = new SearchConditionOption(); + searchConditionOption.setKey("-1"); + searchConditionOption.setShowname("全部"); + options.add(0, searchConditionOption); + options.forEach(item -> item.setSelected(false)); + } + + /** + * 根据模板示例,组装所有selectKeys + * + * @param searchTemplatePO + * @return + */ + private List getSelectKeys(SearchTemplatePO searchTemplatePO) { + List selectKeys = new ArrayList<>(); + String basicFields = searchTemplatePO.getBasicFields(); + String personalFields = searchTemplatePO.getPersonalFields(); + String workflowFields = searchTemplatePO.getWorkFields(); + if (StringUtils.isNotBlank(basicFields)) { + selectKeys.addAll(Arrays.asList(basicFields.split(","))); + } + if (StringUtils.isNotBlank(personalFields)) { + selectKeys.addAll(Arrays.asList(personalFields.split(","))); + } + if (StringUtils.isNotBlank(workflowFields)) { + selectKeys.addAll(Arrays.asList(workflowFields.split(","))); + } + return selectKeys; + } + } diff --git a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java index 759da7c8..8390babb 100644 --- a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java @@ -1,69 +1,53 @@ package com.engine.organization.service.impl; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; -import com.engine.hrm.entity.FieldSelectOptionBean; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.SelectOptionParam; -import com.engine.organization.entity.commom.RecordInfo; import com.engine.organization.entity.extend.ExtendInfoOperateType; -import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.fieldset.param.FieldTransferParam; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; -import com.engine.organization.entity.jclimport.po.JclImportHistoryPO; import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO; -import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.scheme.po.GradePO; import com.engine.organization.entity.scheme.po.LevelPO; import com.engine.organization.entity.scheme.po.SchemePO; -import com.engine.organization.enums.LogModuleNameEnum; -import com.engine.organization.enums.OperateTypeEnum; import com.engine.organization.enums.OrgImportEnum; -import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtendInfoMapper; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; +import com.engine.organization.mapper.jclimport.ImportMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper; -import com.engine.organization.mapper.jclimport.JclImportHistoryMapper; -import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.scheme.GradeMapper; import com.engine.organization.mapper.scheme.LevelMapper; import com.engine.organization.mapper.scheme.SchemeMapper; import com.engine.organization.service.ImportCommonService; -import com.engine.organization.thread.*; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.excel.ExcelUtil; -import com.engine.organization.util.relation.EcHrmRelationUtil; +import com.engine.organization.util.saveimport.CompanyImport; +import com.engine.organization.util.saveimport.DepartmentImport; +import com.engine.organization.util.saveimport.OrgImportUtil; +import com.engine.organization.util.saveimport.ResourceImport; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import weaver.common.DateUtil; import weaver.file.ImageFileManager; import weaver.general.BaseBean; import weaver.general.GCONST; import weaver.general.Util; -import weaver.hrm.definedfield.HrmFieldManager; import weaver.systeminfo.SystemEnv; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -74,20 +58,11 @@ import java.util.stream.Collectors; * @version: 1.0 */ public class ImportCommonServiceImpl extends Service implements ImportCommonService { - /** - * extend_group - */ - private static final Long COMPANY_TYPE = 1L; - private static final Long DEPARTMENT_TYPE = 2L; - private static final Long JOB_TYPE = 3L; - private static final Long RESOURCE_TYPE = 4L; private static final String RIGHT_NAME = "DataImport:All"; - private static final String HRM_COMPANY = "hrmsubcompany"; - private static final String HRM_DEPARTMENT = "hrmdepartment"; - private static final String HRM_RESOURCE = "hrmresource"; static Map importFieldsMap; + static { importFieldsMap = new HashMap<>(); importFieldsMap.put("方案编号", ExtendInfoPO.builder().tableName("jcl_org_scheme").fieldName("scheme_no").fieldNameDesc("方案编号").isrequired(1).controlType(1).browserType("1").customValue("[\"input\",\"text\",\"100\"]").build()); @@ -101,12 +76,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ importFieldsMap.put("职级说明", ExtendInfoPO.builder().tableName("jcl_org_grade").fieldName("grade_description").fieldNameDesc("职级说明").isrequired(0).controlType(1).browserType("1").customValue("[\"input\",\"text\",\"100\"]").build()); } + private ExtendInfoMapper getExtendInfoMapper() { return MapperProxyFactory.getProxy(ExtendInfoMapper.class); } - private SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); + private ImportMapper getImportMapper() { + return MapperProxyFactory.getProxy(ImportMapper.class); } @Override @@ -115,36 +91,34 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ String tableName = ""; String errorMsg = ""; List excludeFields = new ArrayList<>(); - //List includeFields = new ArrayList<>(); - //List selectedList = new ArrayList<>(); Map returnMaps = new HashMap<>(); if (StringUtils.isNotBlank(importType)) { switch (importType) { case "company": - extendType = "1"; - tableName = "JCL_ORG_COMP"; - excludeFields.add("parent_company"); - excludeFields.add("ec_company"); - break; + excludeFields.add("subcompanydesc"); + excludeFields.add("supsubcomid"); + excludeFields.add("limitUsers"); + excludeFields.add("subshowid"); + return CompanyImport.getImportFields(user, excludeFields); case "department": - extendType = "2"; - tableName = "JCL_ORG_DEPT"; - excludeFields.add("parent_dept"); - excludeFields.add("ec_department"); - break; + excludeFields.add("departmentname"); + excludeFields.add("supdepid"); + excludeFields.add("showid"); + return DepartmentImport.getImportFields(user, excludeFields); case "jobtitle": - extendType = "3"; - tableName = "JCL_ORG_JOB"; - excludeFields.add("parent_job"); - break; case "resource": - extendType = "4"; - tableName = "JCL_ORG_HRMRESOURCE"; - excludeFields.add("scheme_id"); - excludeFields.add("sequence_id"); - excludeFields.add("job_grade"); - excludeFields.add("job_level"); - break; + List resourceExceptedFields = getImportMapper().getResourceExceptedFields(); + if (CollectionUtils.isNotEmpty(resourceExceptedFields)) { + excludeFields.addAll(resourceExceptedFields); + } + excludeFields.add("resourceimageid"); + excludeFields.add("messagerurl"); + excludeFields.add("workyear"); + excludeFields.add("companyworkyear"); + excludeFields.add("textfield1"); + excludeFields.add("textfield2"); + + return ResourceImport.getImportFields(user, excludeFields); case "joblevel": extendType = "0"; tableName = "JCL_ORG_SCHEME"; @@ -161,7 +135,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ return returnMaps; } - if("joblevel".equals(importType)){ + if ("joblevel".equals(importType)) { List fieldDatas = new ArrayList<>(); fieldDatas.add(FieldTransferParam.builder().id("1").name("职级编号").build()); fieldDatas.add(FieldTransferParam.builder().id("2").name("职级名称").build()); @@ -173,13 +147,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ fieldDatas.add(FieldTransferParam.builder().id("8").name("职级说明").build()); fieldDatas.add(FieldTransferParam.builder().id("9").name("职等说明").build()); List selectedKeys = new ArrayList<>(); - for(int i=0;i infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, ExtendInfoOperateType.LIST.getValue(), "1"); List filterList = infoPOList.stream().filter(item -> !excludeFields.contains(item.getFieldName()) && 6 != item.getControlType()).collect(Collectors.toList()); @@ -200,19 +174,19 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ String templatePath = getTemplatePath(importType, columns); switch (importType) { case "company": - returnMap.put("condition", getCompanyImportForm(templatePath)); + returnMap.put("condition", CompanyImport.importForm(user, templatePath)); break; case "department": - returnMap.put("condition", getDepartmentImportForm(templatePath)); + returnMap.put("condition", DepartmentImport.importForm(user, templatePath)); break; case "jobtitle": - returnMap.put("condition", getJobTitleImportForm(templatePath)); - break; + //returnMap.put("condition", getJobTitleImportForm(templatePath)); + //break; case "resource": - returnMap.put("condition", getResourceImportForm(templatePath)); + returnMap.put("condition", ResourceImport.importForm(user, templatePath)); break; case "joblevel": - returnMap.put("condition", getJobTitleImportForm(templatePath)); + returnMap.put("condition", getJobLevelImportForm(templatePath)); break; default: returnMap.put("status", "-1"); @@ -239,38 +213,14 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ if (StringUtils.isNotBlank(importType)) { switch (importType) { case "company": - returnMap.put("pId", companyImport(operateType, excelFile)); + returnMap.put("pId", CompanyImport.saveImport(operateType, excelFile, user)); break; case "department": - returnMap.put("pId", departmentImport(operateType, excelFile)); + returnMap.put("pId", DepartmentImport.saveImport(operateType, excelFile, user)); break; case "jobtitle": - returnMap.put("pId", jobImport(operateType, excelFile)); - break; case "resource": - //Long importHistoryId = saveImportLog("resource", operateType); - //HrmImportAdaptExcelE9 importAdapt = new HrmImportAdaptExcelE9(); - //FileUploadToPath fu = new FileUploadToPath(request); - // - //List errorInfo = importAdapt.creatImportMap(fu); - // - ////如果读取数据和验证模板没有发生错误 - //if (errorInfo.isEmpty()) { - // Map hrMap = importAdapt.getHrmImportMap(); - // - // HrmImportProcessE9 importProcess = new HrmImportProcessE9(); - // importProcess.init(request, importHistoryId); - // - // - // importProcess.processMap(hrMap); - //} else { - // for (String s : errorInfo) { - // MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid(importHistoryId).operateDetail(Util.null2String(s)).status("0").build()); - // } - //} - //returnMap.put("pId", importHistoryId); - - returnMap.put("pId", hrmResourceImport(operateType, excelFile,keyField)); + returnMap.put("pId", ResourceImport.saveImport(operateType, excelFile, user, request)); break; case "joblevel": returnMap.put("pId", jobLevelImport(operateType, excelFile)); @@ -326,136 +276,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ return returnMap; } - - /** - * 分部导入表单 - */ - private List getCompanyImportForm(String templatePath) throws IOException { - - - // 返回导入数据 - List lsGroup = new ArrayList<>(); - Map groupItem = new HashMap<>(); - List itemList = new ArrayList<>(); - - groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); - groupItem.put("defaultshow", true); - - SearchConditionItem searchConditionItem; - ConditionFactory conditionFactory = new ConditionFactory(user); - //导入类型 - List statusOptions = new ArrayList<>(); - statusOptions.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); - statusOptions.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); - searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions); - searchConditionItem.setValue("add"); - itemList.add(searchConditionItem); - - //模板文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); - searchConditionItem.setValue(templatePath); - itemList.add(searchConditionItem); - - //Excel文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); - itemList.add(searchConditionItem); - - groupItem.put("items", itemList); - lsGroup.add(groupItem); - - - itemList = new ArrayList<>(); - groupItem = new HashMap<>(); - groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); - groupItem.put("defaultshow", true); - List lsPromptLabel = new ArrayList<>(); //提示信息 - lsPromptLabel.add(34275); - lsPromptLabel.add(125452); - lsPromptLabel.add(125466); - //lsPromptLabel.add(522355); - //lsPromptLabel.add(522356); - //lsPromptLabel.add(522357); - //lsPromptLabel.add(530411); - - for (int i = 0; i < lsPromptLabel.size(); i++) { - Map item = new HashMap<>(); - item.put("index", (i + 1)); - String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); - if (i == 0) { - value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); - item.put("link", templatePath); - } - item.put("value", value); - itemList.add(item); - } - groupItem.put("items", itemList); - lsGroup.add(groupItem); - return lsGroup; - } - - private List getDepartmentImportForm(String templatePath) throws IOException { - - // 返回导入数据 - List lsGroup = new ArrayList<>(); - Map groupItem = new HashMap<>(); - List itemList = new ArrayList<>(); - - groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); - groupItem.put("defaultshow", true); - - SearchConditionItem searchConditionItem; - ConditionFactory conditionFactory = new ConditionFactory(user); - //导入类型 - List statusOptions = new ArrayList<>(); - statusOptions.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); - statusOptions.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); - searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions); - searchConditionItem.setValue("add"); - itemList.add(searchConditionItem); - - //模板文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); - searchConditionItem.setValue(templatePath); - itemList.add(searchConditionItem); - - //Excel文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); - itemList.add(searchConditionItem); - - groupItem.put("items", itemList); - lsGroup.add(groupItem); - - - itemList = new ArrayList<>(); - groupItem = new HashMap<>(); - groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); - groupItem.put("defaultshow", true); - List lsPromptLabel = new ArrayList<>(); //提示信息 - lsPromptLabel.add(34275); - lsPromptLabel.add(125452); - lsPromptLabel.add(125466); - //lsPromptLabel.add(522355); - //lsPromptLabel.add(522356); - //lsPromptLabel.add(522357); - //lsPromptLabel.add(530411); - - for (int i = 0; i < lsPromptLabel.size(); i++) { - Map item = new HashMap<>(); - item.put("index", (i + 1)); - String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); - if (i == 0) { - value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); - item.put("link", templatePath); - } - item.put("value", value); - itemList.add(item); - } - groupItem.put("items", itemList); - lsGroup.add(groupItem); - return lsGroup; - } - - private List getJobTitleImportForm(String templatePath) throws IOException { + private List getJobLevelImportForm(String templatePath) throws IOException { // 返回导入数据 List lsGroup = new ArrayList<>(); @@ -508,94 +329,21 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ item.put("value", value); itemList.add(item); } + Map item = new HashMap<>(); + item.put("index", 3); + item.put("value", "多个职等之间使用英文状态下逗号”,“隔开"); + itemList.add(item); groupItem.put("items", itemList); lsGroup.add(groupItem); return lsGroup; } - private List getResourceImportForm(String templatePath) throws IOException { - - // 返回导入数据 - List lsGroup = new ArrayList<>(); - Map groupItem = new HashMap<>(); - List itemList = new ArrayList<>(); - - groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); - groupItem.put("defaultshow", true); - - SearchConditionItem searchConditionItem; - ConditionFactory conditionFactory = new ConditionFactory(user); - - //重复验证字段 - List statusOptions = new ArrayList<>(); - statusOptions.add(new SearchConditionOption("last_name", SystemEnv.getHtmlLabelName(413, user.getLanguage()))); - statusOptions.add(new SearchConditionOption("work_code", SystemEnv.getHtmlLabelName(714, user.getLanguage()), true)); - //statusOptions.add(new SearchConditionOption("loginid", SystemEnv.getHtmlLabelName(412, user.getLanguage()))); - searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24638, "keyField", statusOptions); - searchConditionItem.setValue("last_name"); - itemList.add(searchConditionItem); - - //导入类型 - List statusOptions1 = new ArrayList<>(); - statusOptions1.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); - statusOptions1.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); - searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions1); - searchConditionItem.setValue("add"); - itemList.add(searchConditionItem); - - //模板文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); - searchConditionItem.setValue(templatePath); - itemList.add(searchConditionItem); - - //Excel文件 - searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); - itemList.add(searchConditionItem); - - groupItem.put("items", itemList); - lsGroup.add(groupItem); - - - itemList = new ArrayList<>(); - groupItem = new HashMap<>(); - groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); - groupItem.put("defaultshow", true); - List lsPromptLabel = new ArrayList<>(); //提示信息 - lsPromptLabel.add(128520); - lsPromptLabel.add(125868); - lsPromptLabel.add(128365); - //lsPromptLabel.add(81697); - //lsPromptLabel.add(81698); - lsPromptLabel.add(81699); - lsPromptLabel.add(516263); - //lsPromptLabel.add(81701); - //lsPromptLabel.add(388880); - lsPromptLabel.add(81702); - lsPromptLabel.add(81703); - lsPromptLabel.add(125869); - - for (int i = 0; i < lsPromptLabel.size(); i++) { - Map item = new HashMap<>(); - item.put("index", (i + 1)); - String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); - if (i == 0) { - value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); - item.put("link", templatePath); - } - item.put("value", value); - itemList.add(item); - } - groupItem.put("items", itemList); - lsGroup.add(groupItem); - return lsGroup; - } - - /** - * 导入分部 + * 方案职等职级导入 */ - private Long companyImport(String operateType, String excelFile) { - Long importHistoryId = saveImportLog("company", operateType); + private Long jobLevelImport(String operateType, String excelFile) { + + Long importHistoryId = OrgImportUtil.saveImportLog("joblevel", operateType, user); JclImportHistoryDetailPO historyDetailPO; ImageFileManager manager = new ImageFileManager(); @@ -606,1011 +354,127 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ } catch (IOException e) { throw new RuntimeException(e); } - // 当前sheet - XSSFSheet sheetAt = workbook.getSheetAt(0); - int lastRow = sheetAt.getLastRowNum(); - List extendInfoPOS = new ArrayList<>(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); - short lastCellNum = sheetAt.getRow(0).getLastCellNum(); - + int allRow = 0; + for (int s = 0; s < workbook.getNumberOfSheets(); s++) { + // 当前sheet + XSSFSheet sheetAt = workbook.getSheetAt(s); + int lastRow = sheetAt.getLastRowNum(); + allRow = allRow + lastRow; + String relatedName; + switch (s) { + case 0: + relatedName = "方案页"; + break; + case 1: + relatedName = "职等页"; + break; + default: + relatedName = "职级页"; + OrganizationAssert.isTrue(allRow > 0, "导入数据为空"); + break; + } + short lastCellNum = sheetAt.getRow(0).getLastCellNum(); + List extendInfoPOS = new ArrayList<>(); - // 遍历每一行数据 - nextRow: - for (int i = 0; i <= lastRow; i++) { - historyDetailPO = new JclImportHistoryDetailPO(); - historyDetailPO.setPid(importHistoryId); - XSSFRow row = sheetAt.getRow(i); - // 组装待处理数据 - Map map = new HashMap<>(); - Long parentCompanyId = null; - String companyName = ""; + // 遍历每一行数据 + nextRow: + for (int i = 0; i <= lastRow; i++) { + historyDetailPO = new JclImportHistoryDetailPO(); + historyDetailPO.setPid(importHistoryId); + XSSFRow row = sheetAt.getRow(i); + if (null == row) { + continue; + } + // 组装待处理数据 + Map map = new HashMap<>(); + SchemePO schemePO = new SchemePO(); + SchemePO schemeNew; + GradePO gradePO = new GradePO(); + GradePO gradeNew = new GradePO(); + LevelPO levelPO = new LevelPO(); + LevelPO levelNew; - historyDetailPO.setRowNums(String.valueOf(i + 1)); - for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { - XSSFCell cell = row.getCell((short) cellIndex); - String cellValue = getCellValue(cell).trim(); - if (i == 0) { - // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(COMPANY_TYPE, cellValue); - extendInfoPOS.add(extendInfoPO); - } else { - ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); - // 数据校验 - if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } + historyDetailPO.setRowNums(String.valueOf(i + 1)); + for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { + XSSFCell cell = row.getCell((short) cellIndex); + String cellValue = getCellValue(cell).trim(); + if (i == 0) { + // 首行 初始化字段信息 + ExtendInfoPO extendInfoPO = importFieldsMap.get(cellValue); + extendInfoPOS.add(extendInfoPO); + } else { + ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); + // 数据校验 + if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } - Object reallyValue; - try { - reallyValue = getReallyValue(infoPO, cellValue); - } catch (Exception e) { - historyDetailPO.setOperateDetail(cellValue + "转换失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue))) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - map.put(infoPO.getFieldName(), reallyValue); - if ("comp_name".equals(infoPO.getFieldName())) { - historyDetailPO.setRelatedName(cellValue); - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("分部层级不能大于10"); + Object reallyValue; + try { + // 数据格式转换 + reallyValue = OrgImportUtil.getReallyValue(infoPO, cellValue); + } catch (Exception e) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail(cellValue + "转换失败"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName()) && !"ec_department".equals(infoPO.getFieldName())) { + historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + map.put(infoPO.getFieldName(), reallyValue); + // 方案页校验(是否重复) + if ("scheme_no".equals(infoPO.getFieldName()) && s == 0 && "add".equals(operateType)) { + List schemePOS = MapperProxyFactory.getProxy(SchemeMapper.class).listByNo(Util.null2String(reallyValue)); + if (schemePOS.size() > 0) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("方案编号[" + reallyValue + "]与原有编号重复"); historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); continue nextRow; } - for (int index = 0; index < split.length - 1; index++) { - parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId); - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(split[index] + "分部未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - map.put("parent_company", parentCompanyId); - if (null != parentCompanyId) { - map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(parentCompanyId.toString())); } - companyName = split[split.length - 1]; - map.put("comp_name", companyName); - } - } - } - // 校验、数据交互 - if (i == 0) { - continue; - } - String compNo = (String) map.get("comp_no"); - Long companyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(companyName, parentCompanyId == null ? 0 : parentCompanyId); - if ("add".equals(operateType)) { - if (companyId != null) { - historyDetailPO.setOperateDetail("数据已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - // 自动编号 - compNo = CompServiceImpl.repeatDetermine(compNo); - map.put("comp_no", compNo); - map.put("creator", user.getUID()); - map.put("delete_type", 0); - map.put("create_time", new Date()); - // 禁用表示为空,默认启用 - if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) { - map.put("forbidden_tag", 0); - } - String showOrder = Util.null2String(map.get("show_order")); - if (StringUtils.isBlank(showOrder)) { - Integer maxShowOrder = MapperProxyFactory.getProxy(CompMapper.class).getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0; - } - map.put("show_order", maxShowOrder + 1); - } - - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map, false).sync(); - if (isThrowError(syncMap)) { - // 查询UUID - String ecCompanyID = Util.null2String(syncMap.get("id")); - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_COMPANY, ecCompanyID); - map.put("uuid", recordInfo.getUuid()); - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build(); - MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams); - // 刷新组织架构图 - new CompanyTriggerRunnable(infoParams.getId()).run(); - historyDetailPO.setOperateDetail("添加成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else if ("update".equals(operateType)) { - // 查询对应ID - if (StringUtils.isNotBlank(compNo)) { - if (companyId == null) { - historyDetailPO.setOperateDetail("未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - if (checkRepeatNo(compNo, COMPANY_TYPE, companyId)) { - map.put("update_time", new Date()); - map.put("id", companyId); - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map, false).sync(); - if (isThrowError(syncMap)) { - map.remove("id"); - MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(companyId).tableName("JCL_ORG_COMP").params(map).build()); - // 刷新组织架构图 - new CompanyTriggerRunnable(companyId).run(); - historyDetailPO.setOperateDetail("更新成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else { - historyDetailPO.setOperateDetail(compNo + "编号已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } else { - historyDetailPO.setOperateDetail("编号为空,更新失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } - } - return importHistoryId; - } - - /** - * 导入部门 - */ - private Long departmentImport(String operateType, String excelFile) { - Long importHistoryId = saveImportLog("department", operateType); - JclImportHistoryDetailPO historyDetailPO; - - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(Util.getIntValue(excelFile)); - XSSFWorkbook workbook; - try { - workbook = new XSSFWorkbook(manager.getInputStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } - // 当前sheet - XSSFSheet sheetAt = workbook.getSheetAt(0); - int lastRow = sheetAt.getLastRowNum(); - List extendInfoPOS = new ArrayList<>(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); - short lastCellNum = sheetAt.getRow(0).getLastCellNum(); - - - // 遍历每一行数据 - nextRow: - for (int i = 0; i <= lastRow; i++) { - historyDetailPO = new JclImportHistoryDetailPO(); - historyDetailPO.setPid(importHistoryId); - XSSFRow row = sheetAt.getRow(i); - // 组装待处理数据 - Map map = new HashMap<>(); - Long parentCompanyId = null; - Long parentDepartmentId = null; - String departmentName = ""; - - historyDetailPO.setRowNums(String.valueOf(i + 1)); - for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { - XSSFCell cell = row.getCell((short) cellIndex); - String cellValue = getCellValue(cell).trim(); - if (i == 0) { - // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(DEPARTMENT_TYPE, cellValue); - extendInfoPOS.add(extendInfoPO); - } else { - ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); - // 数据校验 - if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - - Object reallyValue; - try { - reallyValue = getReallyValue(infoPO, cellValue); - } catch (Exception e) { - historyDetailPO.setOperateDetail(cellValue + "转换失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName())) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - map.put(infoPO.getFieldName(), reallyValue); - // 上级分部 - if ("ec_company".equals(infoPO.getFieldName())) { - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("分部层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId); - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - } - - if ("dept_name".equals(infoPO.getFieldName())) { - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "所属分部未找到"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - historyDetailPO.setRelatedName(cellValue); - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("部门层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (int index = 0; index < split.length - 1; index++) { - parentDepartmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(split[index], parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); - if (null == parentDepartmentId) { - historyDetailPO.setOperateDetail(split[index] + "部门未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - map.put("parent_comp", parentCompanyId); - map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(parentCompanyId.toString())); - map.put("parent_dept", parentDepartmentId); - if (null != parentDepartmentId) { - map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(parentDepartmentId.toString())); - } - departmentName = split[split.length - 1]; - map.put("dept_name", departmentName); - } - } - } - // 校验、数据交互 - if (i == 0) { - continue; - } - String deptNo = (String) map.get("dept_no"); - Long departmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(departmentName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); - if ("add".equals(operateType)) { - if (departmentId != null) { - historyDetailPO.setOperateDetail("数据已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - // 自动编号 - deptNo = DepartmentServiceImpl.repeatDetermine(deptNo); - map.put("dept_no", deptNo); - map.put("creator", user.getUID()); - map.put("delete_type", 0); - map.put("create_time", new Date()); - // 禁用表示为空,默认启用 - if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) { - map.put("forbidden_tag", 0); - } - String showOrder = Util.null2String(map.get("show_order")); - if (StringUtils.isBlank(showOrder)) { - Integer maxShowOrder = MapperProxyFactory.getProxy(DepartmentMapper.class).getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0; - } - map.put("show_order", maxShowOrder + 1); - } - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map, false).sync(); - if (isThrowError(syncMap)) { - // 查询UUID - String ecDepartmentID = Util.null2String(syncMap.get("id")); - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentID); - map.put("uuid", recordInfo.getUuid()); - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_DEPT").params(map).build(); - MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams); - // 刷新组织架构图 - new DepartmentTriggerRunnable(infoParams.getId()).run(); - map.put("id", infoParams.getId()); - historyDetailPO.setOperateDetail("添加成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else if ("update".equals(operateType)) { - // 查询对应ID - if (StringUtils.isNotBlank(deptNo)) { - if (departmentId == null) { - historyDetailPO.setOperateDetail("未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - if (checkRepeatNo(deptNo, DEPARTMENT_TYPE, departmentId)) { - map.put("update_time", new Date()); - map.put("id", departmentId); - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map, false).sync(); - if (isThrowError(syncMap)) { - map.remove("id"); - MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(departmentId).tableName("JCL_ORG_DEPT").params(map).build()); - // 刷新组织架构图 - new DepartmentTriggerRunnable(departmentId).run(); - historyDetailPO.setOperateDetail("更新成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else { - historyDetailPO.setOperateDetail(deptNo + "编号已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } else { - historyDetailPO.setOperateDetail("编号为空,更新失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } - } - return importHistoryId; - } - - /** - * 岗位导入 - */ - private Long jobImport(String operateType, String excelFile) { - Long importHistoryId = saveImportLog("jobtitle", operateType); - JclImportHistoryDetailPO historyDetailPO; - - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(Util.getIntValue(excelFile)); - XSSFWorkbook workbook; - try { - workbook = new XSSFWorkbook(manager.getInputStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } - // 当前sheet - XSSFSheet sheetAt = workbook.getSheetAt(0); - int lastRow = sheetAt.getLastRowNum(); - List extendInfoPOS = new ArrayList<>(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); - short lastCellNum = sheetAt.getRow(0).getLastCellNum(); - - // 遍历每一行数据 - nextRow: - for (int i = 0; i <= lastRow; i++) { - historyDetailPO = new JclImportHistoryDetailPO(); - historyDetailPO.setPid(importHistoryId); - XSSFRow row = sheetAt.getRow(i); - // 组装待处理数据 - Map map = new HashMap<>(); - Long parentCompanyId = null; - Long parentDepartmentId = null; - Long parentJobId = null; - String jobName = ""; - - historyDetailPO.setRowNums(String.valueOf(i + 1)); - for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { - XSSFCell cell = row.getCell((short) cellIndex); - String cellValue = getCellValue(cell).trim(); - if (i == 0) { - // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(JOB_TYPE, cellValue); - extendInfoPOS.add(extendInfoPO); - } else { - ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); - // 数据校验 - if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - - Object reallyValue; - try { - reallyValue = getReallyValue(infoPO, cellValue); - } catch (Exception e) { - historyDetailPO.setOperateDetail(cellValue + "转换失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName()) && !"ec_department".equals(infoPO.getFieldName())) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - map.put(infoPO.getFieldName(), reallyValue); - // 上级分部 - if ("ec_company".equals(infoPO.getFieldName())) { - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("分部层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId); - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - } - - - if ("ec_department".equals(infoPO.getFieldName())) { - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("部门层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentDepartmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(s, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); - if (null == parentDepartmentId) { - historyDetailPO.setOperateDetail(cellValue + "部门未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - } - - if ("job_name".equals(infoPO.getFieldName())) { - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "所属分部未找到"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - historyDetailPO.setRelatedName(cellValue); - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("岗位层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (int index = 0; index < split.length - 1; index++) { - parentJobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndPid(split[index], parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId, parentJobId == null ? 0 : parentJobId); - if (null == parentJobId) { - historyDetailPO.setOperateDetail(split[index] + "岗位未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - map.put("parent_comp", parentCompanyId); - map.put("parent_dept", parentDepartmentId); - map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentCompanyId))); - if (null != parentDepartmentId) { - map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(Util.null2String(parentDepartmentId))); - } - map.put("parent_job", parentJobId); - jobName = split[split.length - 1]; - map.put("job_name", jobName); - map.put("is_key", StringUtils.isBlank(Util.null2String(map.get("is_key"))) ? 0 : map.get("is_key")); - } - } - } - // 校验、数据交互 - if (i == 0) { - continue; - } - String jobNo = (String) map.get("job_no"); - Long jobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndPid(jobName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId, parentJobId == null ? 0 : parentJobId); - if ("add".equals(operateType)) { - if (jobId != null) { - historyDetailPO.setOperateDetail("数据已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - // 自动编号 - jobNo = JobServiceImpl.repeatDetermine(jobNo); - map.put("job_no", jobNo); - map.put("creator", user.getUID()); - map.put("delete_type", 0); - map.put("create_time", new Date()); - // 禁用表示为空,默认启用 - if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) { - map.put("forbidden_tag", 0); - } - String showOrder = Util.null2String(map.get("show_order")); - if (StringUtils.isBlank(showOrder)) { - Integer maxShowOrder = MapperProxyFactory.getProxy(JobMapper.class).getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0; - } - map.put("show_order", maxShowOrder + 1); - } - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_JOB").params(map).build(); - - map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID); - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, map, false).sync(); - if (isThrowError(syncMap)) { - boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(null, Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name"))); - if (assertNameRepeat) { - map.remove("jobactivityid"); - MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams); - // 更新组织架构图 - new JobTriggerRunnable(infoParams.getId()).run(); - historyDetailPO.setOperateDetail("添加成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail("岗位名称已存在"); - historyDetailPO.setStatus("0"); - } - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else if ("update".equals(operateType)) { - // 查询对应ID - if (StringUtils.isNotBlank(jobNo)) { - if (jobId == null) { - historyDetailPO.setOperateDetail("未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - if (checkRepeatNo(jobNo, JOB_TYPE, jobId)) { - map.put("update_time", new Date()); - map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID); - map.put("id", jobId); - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, map, MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId), false).sync(); - if (isThrowError(syncMap)) { - boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(jobId.toString(), Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name"))); - if (assertNameRepeat) { - map.remove("id"); - map.remove("jobactivityid"); - MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(jobId).tableName("JCL_ORG_JOB").params(map).build()); - // 更新组织架构图 - new JobTriggerRunnable(jobId).run(); - historyDetailPO.setOperateDetail("更新成功"); - historyDetailPO.setStatus("1"); - } else { - historyDetailPO.setOperateDetail("岗位名称已存在"); - historyDetailPO.setStatus("0"); - } - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else { - historyDetailPO.setOperateDetail(jobNo + "编号已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } else { - historyDetailPO.setOperateDetail("编号为空,更新失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - } - } - return importHistoryId; - } - - private Long hrmResourceImport(String operateType, String excelFile, String keyField) { - Long importHistoryId = saveImportLog("resource", operateType); - JclImportHistoryDetailPO historyDetailPO; - - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(Util.getIntValue(excelFile)); - XSSFWorkbook workbook; - try { - workbook = new XSSFWorkbook(manager.getInputStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } - // 当前sheet - XSSFSheet sheetAt = workbook.getSheetAt(0); - int lastRow = sheetAt.getLastRowNum(); - List extendInfoPOS = new ArrayList<>(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); - short lastCellNum = sheetAt.getRow(0).getLastCellNum(); - - // 遍历每一行数据 - nextRow: - for (int i = 0; i <= lastRow; i++) { - historyDetailPO = new JclImportHistoryDetailPO(); - historyDetailPO.setPid(importHistoryId); - XSSFRow row = sheetAt.getRow(i); - // 组装待处理数据 - Map map = new HashMap<>(); - Long parentCompanyId = null; - Long parentDepartmentId = null; - Long parentJobId = null; - - historyDetailPO.setRowNums(String.valueOf(i + 1)); - for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { - XSSFCell cell = row.getCell((short) cellIndex); - String cellValue = getCellValue(cell).trim(); - if (i == 0) { - // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(RESOURCE_TYPE, cellValue); - extendInfoPOS.add(extendInfoPO); - } else { - ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); - // 数据校验 - if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - - Object reallyValue; - try { - reallyValue = getReallyValue(infoPO, cellValue); - } catch (Exception e) { - historyDetailPO.setOperateDetail(cellValue + "转换失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName()) && !"ec_department".equals(infoPO.getFieldName()) && !"job_title".equals(infoPO.getFieldName())) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - map.put(infoPO.getFieldName(), reallyValue); - // 上级分部 - if ("ec_company".equals(infoPO.getFieldName())) { - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("分部层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId); - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - } - - - if ("ec_department".equals(infoPO.getFieldName())) { - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("部门层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentDepartmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(s, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); - if (null == parentDepartmentId) { - historyDetailPO.setOperateDetail(cellValue + "部门未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - } - - if ("job_title".equals(infoPO.getFieldName())) { - if (null == parentCompanyId) { - historyDetailPO.setOperateDetail(cellValue + "所属分部未找到"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - String[] split = cellValue.split(">"); - if (split.length > 0) { - if (split.length > 8) { - historyDetailPO.setOperateDetail("岗位层级不能大于10"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - for (String s : split) { - parentJobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndPid(s, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId, parentJobId == null ? 0 : parentJobId); - if (null == parentJobId) { - historyDetailPO.setOperateDetail(s + "岗位未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - } - map.put("company_id", parentCompanyId); - map.put("department_id", parentDepartmentId); - map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentCompanyId))); - if (null != parentDepartmentId) { - map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(Util.null2String(parentDepartmentId))); - } - map.put("job_title", parentJobId); - } - } - } - // 校验、数据交互 - if (i == 0) { - continue; - } - // 根据岗位获取等级方案、岗位序列、职等、职级 - if (null != parentJobId) { - JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(parentJobId); - map.put("scheme_id", jobById.getSchemeId()); - map.put("sequence_id", jobById.getSequenceId()); - map.put("job_level", jobById.getLevelId()); - map.put("job_grade", jobById.getGradeId()); - } - - String keyFieldValue = Util.null2String(map.get(keyField)); - if(StringUtils.isBlank(keyFieldValue)){ - historyDetailPO.setOperateDetail("所选重复验证字段为空"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - historyDetailPO.setRelatedName(keyFieldValue); - - // 判断当前人员是否存在 - Long resourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getIdByKeyField(keyField, keyFieldValue); - if ("add".equals(operateType)) { - if (resourceId != null) { - historyDetailPO.setOperateDetail(keyFieldValue+"已存在"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - - // 自动编号 - String workCode = Util.null2String(map.get("work_code")); - try { - // 自动编号 - workCode = HrmResourceServiceImpl.repeatDetermine(workCode); - map.put("work_code", workCode); - } catch (Exception e) { - historyDetailPO.setOperateDetail(Util.null2String(e.getMessage())); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - } - map.put("creator", user.getUID()); - map.put("delete_type", 0); - map.put("create_time", new Date()); - - String showOrder = Util.null2String(map.get("show_order")); - if (StringUtils.isBlank(showOrder)) { - Long maxShowOrder = MapperProxyFactory.getProxy(HrmResourceMapper.class).getMaxShowOrder(); - if (null == maxShowOrder) { - maxShowOrder = 0L; - } - map.put("show_order", maxShowOrder + 1); - } - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.ADD, map, false).sync(); - if (isThrowError(syncMap) && StringUtils.isNotBlank(Util.null2String(syncMap.get("id")))) { - String ecResourceId = Util.null2String(syncMap.get("id")); - RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_RESOURCE, ecResourceId); - map.put("uuid", recordInfo.getUuid()); - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_HRMRESOURCE").params(map).build(); - map.remove("id"); - MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams); - // 更新组织架构图 - new HrmResourceTriggerRunnable(infoParams.getId()).run(); - historyDetailPO.setOperateDetail("添加成功"); - historyDetailPO.setStatus("1"); - - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } else if ("update".equals(operateType)) { - // 查询对应ID - if (resourceId == null) { - historyDetailPO.setOperateDetail("未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue; - } - map.put("update_time", new Date()); - map.put("id", resourceId); - Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.UPDATE, map, false).sync(); - if (isThrowError(syncMap)) { - map.remove("id"); - MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(resourceId).tableName("JCL_ORG_HRMRESOURCE").params(map).build()); - // 更新组织架构图 - new HrmResourceTriggerRunnable(resourceId).run(); - historyDetailPO.setOperateDetail("更新成功"); - historyDetailPO.setStatus("1"); - - } else { - historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); - historyDetailPO.setStatus("0"); - } - saveImportDetailLog(historyDetailPO); - } - } - return importHistoryId; - } - - /** - * 方案职等职级导入 - */ - private Long jobLevelImport(String operateType, String excelFile) { - - Long importHistoryId = saveImportLog("joblevel", operateType); - JclImportHistoryDetailPO historyDetailPO; - - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(Util.getIntValue(excelFile)); - XSSFWorkbook workbook; - try { - workbook = new XSSFWorkbook(manager.getInputStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } - for (int s = 0; s < workbook.getNumberOfSheets(); s++) { - // 当前sheet - XSSFSheet sheetAt = workbook.getSheetAt(s); - int lastRow = sheetAt.getLastRowNum(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); - short lastCellNum = sheetAt.getRow(0).getLastCellNum(); - List extendInfoPOS = new ArrayList<>(); - - // 遍历每一行数据 - nextRow: - for (int i = 0; i <= lastRow; i++) { - historyDetailPO = new JclImportHistoryDetailPO(); - historyDetailPO.setPid(importHistoryId); - XSSFRow row = sheetAt.getRow(i); - // 组装待处理数据 - Map map = new HashMap<>(); - SchemePO schemePO = new SchemePO(); - SchemePO schemeNew = new SchemePO(); - ; - GradePO gradePO = new GradePO(); - GradePO gradeNew = new GradePO(); - LevelPO levelPO = new LevelPO(); - LevelPO levelNew = new LevelPO(); - - historyDetailPO.setRowNums(String.valueOf(i + 1)); - for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { - XSSFCell cell = row.getCell((short) cellIndex); - String cellValue = getCellValue(cell).trim(); - if (i == 0) { - // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = importFieldsMap.get(cellValue); - extendInfoPOS.add(extendInfoPO); - } else { - ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); - // 数据校验 - if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - - Object reallyValue; - try { - // 数据格式转换 - reallyValue = getReallyValue(infoPO, cellValue); - } catch (Exception e) { - historyDetailPO.setOperateDetail(cellValue + "转换失败"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName()) && !"ec_department".equals(infoPO.getFieldName())) { - historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - map.put(infoPO.getFieldName(), reallyValue); - // 方案页校验 - if ("scheme_no".equals(infoPO.getFieldName()) && s == 0 && "add".equals(operateType)) { - List schemePOS = MapperProxyFactory.getProxy(SchemeMapper.class).listByNo(Util.null2String(reallyValue)); - if (schemePOS.size() > 0) { - historyDetailPO.setOperateDetail("方案编号[" + reallyValue + "]与原有编号重复"); - historyDetailPO.setRelatedName("方案页导入"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } - // 职等页校验 + // 职等页校验(方案是否存在) if ("scheme_no".equals(infoPO.getFieldName()) && s == 1) { List schemePOS = MapperProxyFactory.getProxy(SchemeMapper.class).listByNo(Util.null2String(reallyValue)); if (schemePOS.size() == 0) { + historyDetailPO.setRelatedName(relatedName); historyDetailPO.setOperateDetail("未找到编号为[" + reallyValue + "]的方案"); - historyDetailPO.setRelatedName("职等页导入"); historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); continue nextRow; } } - // 职级页校验 + // 职级页校验(方案是否存在) if ("scheme_no".equals(infoPO.getFieldName()) && s == 2) { List schemePOS = MapperProxyFactory.getProxy(SchemeMapper.class).listByNo(Util.null2String(reallyValue)); if (schemePOS.size() == 0) { + historyDetailPO.setRelatedName(relatedName); historyDetailPO.setOperateDetail("未找到编号为[" + reallyValue + "]的方案"); - historyDetailPO.setRelatedName("职级页导入"); historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); continue nextRow; } } + // 职级页校验(职等是否存在) if ("level_no".equals(infoPO.getFieldName()) && s == 2) { String[] split = Util.null2String(reallyValue).split(","); if (split.length > 0) { - for (int index = 0; index < split.length - 1; index++) { - List levelPOS = MapperProxyFactory.getProxy(LevelMapper.class).listByNo(split[index]); + for (String value : split) { + List levelPOS = MapperProxyFactory.getProxy(LevelMapper.class).listByNo(value); if (levelPOS.size() == 0) { - historyDetailPO.setOperateDetail("未找到编号为[" + reallyValue + "]的职等"); - historyDetailPO.setRelatedName("职级页导入"); + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + value + "]的职等"); historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); continue nextRow; } } @@ -1632,207 +496,216 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ map.put("forbidden_tag", 0); map.put("is_used", 1); if ("add".equals(operateType)) { - if (s == 0) { - schemePO.setSchemeNo((String) map.get("scheme_no")); - schemePO.setSchemeName((String) map.get("scheme_name")); - schemePO.setSchemeDescription((String) map.get("scheme_description")); - schemePO.setForbiddenTag((int) map.get("forbidden_tag")); - schemePO.setIsUsed(1); - schemePO.setCreator((long) user.getUID()); - schemePO.setDeleteType((int) map.get("delete_type")); - schemePO.setCreateTime((Date) map.get("create_time")); - schemePO.setUpdateTime((Date) map.get("update_time")); - - MapperProxyFactory.getProxy(SchemeMapper.class).insertIgnoreNull(schemePO); - } else if (s == 1) { - String schemeNo = (String) map.get("scheme_no"); - String levelNo = (String) map.get("level_no"); - schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); - if (schemeNew != null) { - levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(levelNo, schemeNew.getId()); - if (levelNew != null) { - historyDetailPO.setRelatedName("职等编号"); - historyDetailPO.setOperateDetail("职等页导入:同一方案" + schemeNo + "下,职等编号不可重复"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; + switch (s) { + case 0: + schemePO.setSchemeNo((String) map.get("scheme_no")); + schemePO.setSchemeName((String) map.get("scheme_name")); + schemePO.setSchemeDescription((String) map.get("scheme_description")); + schemePO.setForbiddenTag((int) map.get("forbidden_tag")); + schemePO.setIsUsed(1); + schemePO.setCreator((long) user.getUID()); + schemePO.setDeleteType((int) map.get("delete_type")); + schemePO.setCreateTime((Date) map.get("create_time")); + schemePO.setUpdateTime((Date) map.get("update_time")); + MapperProxyFactory.getProxy(SchemeMapper.class).insertIgnoreNull(schemePO); + break; + case 1: + String schemeNo = (String) map.get("scheme_no"); + String levelNo = (String) map.get("level_no"); + schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); + if (schemeNew != null) { + levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(levelNo, schemeNew.getId()); + if (levelNew != null) { + historyDetailPO.setRelatedName("职等编号"); + historyDetailPO.setOperateDetail("职等页导入:同一方案" + schemeNo + "下,职等编号不可重复"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } else { + levelPO.setLevelNo(levelNo); + levelPO.setLevelName((String) map.get("level_name")); + levelPO.setDescription((String) map.get("level_description")); + //关联方案id + levelPO.setSchemeId(schemeNew.getId()); + levelPO.setForbiddenTag((int) map.get("forbidden_tag")); + levelPO.setIsUsed(1); + levelPO.setCreator((long) user.getUID()); + levelPO.setDeleteType((int) map.get("delete_type")); + levelPO.setCreateTime((Date) map.get("create_time")); + levelPO.setUpdateTime((Date) map.get("update_time")); + MapperProxyFactory.getProxy(LevelMapper.class).insertIgnoreNull(levelPO); + } } else { - levelPO.setLevelNo(levelNo); - levelPO.setLevelName((String) map.get("level_name")); - levelPO.setDescription((String) map.get("level_description")); - //关联方案id - levelPO.setSchemeId(schemeNew.getId()); - levelPO.setForbiddenTag((int) map.get("forbidden_tag")); - levelPO.setIsUsed(1); - levelPO.setCreator((long) user.getUID()); - levelPO.setDeleteType((int) map.get("delete_type")); - levelPO.setCreateTime((Date) map.get("create_time")); - levelPO.setUpdateTime((Date) map.get("update_time")); - MapperProxyFactory.getProxy(LevelMapper.class).insertIgnoreNull(levelPO); + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } + break; + case 2: + String gradeNo2 = (String) map.get("grade_no"); + String schemeNo2 = (String) map.get("scheme_no"); + String levelNo2 = (String) map.get("level_no"); + + schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo2); + if (schemeNew == null) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo2 + "]的方案"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; } - } else { - historyDetailPO.setRelatedName("职等页导入"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } else if (s == 2) { - String gradeNo = (String) map.get("grade_no"); - String schemeNo = (String) map.get("scheme_no"); - String levelNo = (String) map.get("level_no"); - - schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); - if (schemeNew == null) { - historyDetailPO.setRelatedName("职级页导入"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - gradeNew = MapperProxyFactory.getProxy(GradeMapper.class).getGradeByNoAndSid(gradeNo, schemeNew.getId()); - if (gradeNew == null) { - historyDetailPO.setRelatedName("职级页导入"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的职等"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - gradePO.setGradeNo(gradeNo); - gradePO.setGradeName((String) map.get("grade_name")); - gradePO.setDescription((String) map.get("grade_description")); - // 关联方案id - gradePO.setSchemeId(schemeNew.getId()); - gradePO.setGradeNo((String) map.get("grade_no")); - gradePO.setForbiddenTag((int) map.get("forbidden_tag")); - gradePO.setIsUsed(1); - gradePO.setCreator((long) user.getUID()); - gradePO.setDeleteType((int) map.get("delete_type")); - gradePO.setCreateTime((Date) map.get("create_time")); - gradePO.setUpdateTime((Date) map.get("update_time")); - String[] split = levelNo.split(","); - String levelIds = null; - if (split.length > 0) { - for (int index = 0; index < split.length; index++) { - levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(split[index], schemeNew.getId()); - if (levelIds != null) { - levelIds = levelIds + "," + levelNew.getId(); - } else { - levelIds = String.valueOf(levelNew.getId()); + gradePO.setGradeNo(gradeNo2); + gradePO.setGradeName((String) map.get("grade_name")); + gradePO.setDescription((String) map.get("grade_description")); + // 关联方案id + gradePO.setSchemeId(schemeNew.getId()); + gradePO.setForbiddenTag((int) map.get("forbidden_tag")); + gradePO.setIsUsed(1); + gradePO.setCreator((long) user.getUID()); + gradePO.setDeleteType((int) map.get("delete_type")); + gradePO.setCreateTime((Date) map.get("create_time")); + gradePO.setUpdateTime((Date) map.get("update_time")); + String[] split = levelNo2.split(","); + StringBuilder levelIds = null; + if (split.length > 0) { + for (String value : split) { + levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(value, schemeNew.getId()); + if (levelNew == null) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + value + "]的职等"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + if (levelIds != null) { + levelIds.append(",").append(levelNew.getId()); + } else { + levelIds = new StringBuilder(String.valueOf(levelNew.getId())); + } } } - } - if (gradeNew != null) { - historyDetailPO.setRelatedName("职级页导入"); - historyDetailPO.setOperateDetail("同一方案[" + schemeNo + "]下,职级编号不可重复"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } else { - // 关联职等id - gradePO.setLevelId(levelIds); - MapperProxyFactory.getProxy(GradeMapper.class).insertIgnoreNull(gradePO); - } + gradeNew = MapperProxyFactory.getProxy(GradeMapper.class).getGradeByNoAndSid(gradeNo2, schemeNew.getId()); + if (gradeNew != null) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("同一方案[" + schemeNo2 + "]下,职级编号不可重复"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } else { + // 关联职等id + gradePO.setLevelId(levelIds.toString()); + MapperProxyFactory.getProxy(GradeMapper.class).insertIgnoreNull(gradePO); + } + break; + default: + break; } - historyDetailPO.setOperateDetail("添加成功"); historyDetailPO.setStatus("1"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); } else if ("update".equals(operateType)) { - if (s == 0) { - schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo((String) map.get("scheme_no")); - if (schemeNew != null) { - schemeNew.setSchemeName((String) map.get("scheme_name")); - schemeNew.setSchemeDescription((String) map.get("scheme_description")); - schemeNew.setUpdateTime((Date) map.get("update_time")); - MapperProxyFactory.getProxy(SchemeMapper.class).updateScheme(schemeNew); - } else { - historyDetailPO.setRelatedName("方案更新"); - historyDetailPO.setOperateDetail("未找到编号为[" + map.get("scheme_no") + "]的方案"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } else if (s == 1) { - String schemeNo = (String) map.get("scheme_no"); - String levelNo = (String) map.get("level_no"); - schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); - if (schemeNew != null) { - levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(levelNo, schemeNew.getId()); - if (levelNew != null) { - levelNew.setLevelName((String) map.get("level_name")); - levelNew.setDescription((String) map.get("level_description")); - //关联方案id - levelNew.setSchemeId(schemeNew.getId()); - levelNew.setUpdateTime((Date) map.get("update_time")); - MapperProxyFactory.getProxy(LevelMapper.class).updateLevel(levelNew); + switch (s) { + case 0: + schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo((String) map.get("scheme_no")); + if (schemeNew != null) { + schemeNew.setSchemeName((String) map.get("scheme_name")); + schemeNew.setSchemeDescription((String) map.get("scheme_description")); + schemeNew.setUpdateTime((Date) map.get("update_time")); + MapperProxyFactory.getProxy(SchemeMapper.class).updateScheme(schemeNew); } else { - historyDetailPO.setRelatedName("职等页更新"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + map.get("scheme_no") + "]的方案"); historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; } - } else { - historyDetailPO.setRelatedName("职等页更新"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案,无法更新"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - } else if (s == 2) { - String gradeNo = (String) map.get("grade_no"); - String schemeNo = (String) map.get("scheme_no"); - String levelNo = (String) map.get("level_no"); - schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); - if (schemeNew == null) { - historyDetailPO.setRelatedName("职级页更新"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - gradeNew = MapperProxyFactory.getProxy(GradeMapper.class).getGradeByNoAndSid(gradeNo, schemeNew.getId()); - if (gradeNew == null) { - historyDetailPO.setRelatedName("职级页更新"); - historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的职等"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } - - String[] split = levelNo.split(","); - String levelIds = null; - if (split.length > 0) { - for (int index = 0; index < split.length; index++) { - levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(split[index], schemeNew.getId()); - if (levelIds != null) { - levelIds = levelIds + "," + levelNew.getId(); + break; + case 1: + String schemeNo = (String) map.get("scheme_no"); + String levelNo = (String) map.get("level_no"); + schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo); + if (schemeNew != null) { + levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(levelNo, schemeNew.getId()); + if (levelNew != null) { + levelNew.setLevelName((String) map.get("level_name")); + levelNew.setDescription((String) map.get("level_description")); + //关联方案id + levelNew.setSchemeId(schemeNew.getId()); + levelNew.setUpdateTime((Date) map.get("update_time")); + MapperProxyFactory.getProxy(LevelMapper.class).updateLevel(levelNew); } else { - levelIds = String.valueOf(levelNew.getId()); + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; } + } else { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo + "]的方案,无法更新"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; } - } - if (gradeNew != null) { - gradeNew.setSchemeId(schemeNew.getId()); - gradeNew.setGradeName((String) map.get("grade_name")); - gradeNew.setDescription((String) map.get("grade_description")); - // 关联职等id - gradeNew.setLevelId(levelIds); - gradeNew.setUpdateTime((Date) map.get("update_time")); - MapperProxyFactory.getProxy(GradeMapper.class).updateGrade(gradeNew); - } else { - historyDetailPO.setRelatedName("职级页更新"); - historyDetailPO.setOperateDetail("未找到编号[" + schemeNo + "]的职级,无法更新"); - historyDetailPO.setStatus("0"); - saveImportDetailLog(historyDetailPO); - continue nextRow; - } + break; + case 2: + String schemeNo2 = (String) map.get("scheme_no"); + String levelNo2 = (String) map.get("level_no"); + schemeNew = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByNo(schemeNo2); + if (schemeNew == null) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + schemeNo2 + "]的方案"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } + // 处理职级编号 + String[] split = levelNo2.split(","); + StringBuilder levelIds = null; + if (split.length > 0) { + for (String value : split) { + levelNew = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByNoAndSid(value, schemeNew.getId()); + if (levelNew == null) { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号为[" + value + "]的职等"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + if (levelIds != null) { + levelIds.append(",").append(levelNew.getId()); + } else { + levelIds = new StringBuilder(String.valueOf(levelNew.getId())); + } + } + } + + if (gradeNew != null) { + gradeNew.setSchemeId(schemeNew.getId()); + gradeNew.setGradeName((String) map.get("grade_name")); + gradeNew.setDescription((String) map.get("grade_description")); + // 关联职等id + gradeNew.setLevelId(levelIds.toString()); + gradeNew.setUpdateTime((Date) map.get("update_time")); + MapperProxyFactory.getProxy(GradeMapper.class).updateGrade(gradeNew); + } else { + historyDetailPO.setRelatedName(relatedName); + historyDetailPO.setOperateDetail("未找到编号[" + schemeNo2 + "]的职级,无法更新"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } + + break; + default: + break; } historyDetailPO.setOperateDetail("更新成功"); historyDetailPO.setStatus("1"); - saveImportDetailLog(historyDetailPO); + OrgImportUtil.saveImportDetailLog(historyDetailPO); } } @@ -1845,8 +718,9 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ */ private String getCellValue(XSSFCell cell) { String cellValue = ""; - if (cell == null) + if (cell == null) { return ""; + } switch (cell.getCellType()) { case BOOLEAN: // 得到Boolean对象的方法 cellValue = String.valueOf(cell.getBooleanCellValue()); @@ -1857,8 +731,9 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ cellValue = sft.format(cell.getDateCellValue()); // 读取日期格式 } else { cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 - if (cellValue.endsWith(".0")) + if (cellValue.endsWith(".0")) { cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } } break; case FORMULA: // 读取公式 @@ -1872,105 +747,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ return cellValue; } - /** - * 转换存入数据库的值 - */ - private Object getReallyValue(ExtendInfoPO extendInfo, String cellValue) throws Exception { - if (StringUtils.isBlank(cellValue)) { - return null; - } - Object object = null; - JSONArray jsonArray = JSONObject.parseArray(extendInfo.getCustomValue()); - switch (extendInfo.getControlType()) { - case 1: - String valueType = (String) jsonArray.get(1); - // INPUT - if ("int".equals(valueType)) { - object = Integer.parseInt(cellValue); - } else if ("float".equals(valueType)) { - object = Float.parseFloat(cellValue); - } else { - try { - object = new BigDecimal(cellValue).toPlainString(); - }catch (NumberFormatException ignore){ - object = cellValue; - } - } - break; - case 3: - // BROWSER - org.json.JSONObject jsonObject = new org.json.JSONObject(); - jsonObject.put("fieldhtmltype", extendInfo.getControlType()); - jsonObject.put("type", extendInfo.getBrowserType()); - jsonObject.put("fieldvalue", cellValue); - if ("161".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) { - jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue())); - } else { - jsonObject.put("dmlurl", extendInfo.getBrowserType()); - } - jsonObject.put("fieldid", 0); - object = HrmFieldManager.getReallyFieldvalue(jsonObject); - break; - case 5: - // SELECT - JSONObject o = (JSONObject) jsonArray.get(2); - JSONArray datas = o.getJSONArray("datas"); - List options = datas.toJavaList(FieldSelectOptionBean.class); - Map optionMap = options.stream().collect(Collectors.toMap(FieldSelectOptionBean::getOption, FieldSelectOptionBean::getId, (k1, k2) -> k1)); - object = optionMap.get(cellValue); - break; - case 6: - // FILEUPLOAD - break; - case 4:// CHECKBOX - case 7:// TEXT - case 2:// TEXTAREA - default: - object = cellValue; - break; - } - return object; - } - - /** - * 校验重复编号 - */ - private boolean checkRepeatNo(String no, Long extendType, Long id) { - if (StringUtils.isBlank(no)) { - return true; - } - if (null != extendType) { - switch (extendType.toString()) { - case "1": - return 0 == MapperProxyFactory.getProxy(CompMapper.class).checkRepeatNo(no, id); - case "2": - return 0 == MapperProxyFactory.getProxy(DepartmentMapper.class).checkRepeatNo(no, id); - case "3": - return 0 == MapperProxyFactory.getProxy(JobMapper.class).checkRepeatNo(no, id); - default: - return false; - } - } - return false; - } - - /** - * 生成记录日志 - */ - private Long saveImportLog(String importType, String operateType) { - JclImportHistoryPO historyPO = JclImportHistoryPO.builder().operator((long) user.getUID()).operateTime(DateUtil.getFullDate()).clientAddress(user.getLoginip()).importType(importType).sourceFrom("excel").operateType(operateType).status("importing").build(); - MapperProxyFactory.getProxy(JclImportHistoryMapper.class).insertHistory(historyPO); - return historyPO.getId(); - } - - /** - * 日志导入详细信息日志 - */ - private void saveImportDetailLog(JclImportHistoryDetailPO historyDetailPO) { - String detailMsg = "导入第" + historyDetailPO.getRowNums() + "行数据,[" + historyDetailPO.getRelatedName() + "]" + historyDetailPO.getOperateDetail(); - historyDetailPO.setOperateDetail(detailMsg); - MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(historyDetailPO); - } /** * 生成导入模板文件 @@ -1984,52 +760,73 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ List gradeList = new ArrayList<>(); Object companyColumn = ""; Object departmentColumn = ""; + + String companyFieldName = "所属分部"; + String departmentFieldName = "所属部门"; + switch (importType) { + case "company": + companyFieldName = "简称"; + departmentFieldName = ""; + break; + case "department": + companyFieldName = "所属分部"; + departmentFieldName = "简称"; + break; + case "resource": + companyFieldName = "分部"; + departmentFieldName = "部门"; + break; + default: + break; + } // 排序 /* - 第一列:所属分部 - 第二列:所属部门\上级部门\部门 + 第一列:分部 + 第二列:部门 */ Iterator iterator = columnList.iterator(); while (iterator.hasNext()) { Object column = iterator.next(); - if ("所属分部".equals(column.toString())) { + if (companyFieldName.equals(column.toString())) { companyColumn = column; iterator.remove(); } - if ("所属部门".equals(column) || "上级部门".equals(column)) { + if (departmentFieldName.equals(column)) { departmentColumn = column; iterator.remove(); } - if("方案编号".equals(column)){ - schemeList.add(column); - levelList.add(column); - gradeList.add(column); - } - if("方案名称".equals(column)){ - schemeList.add(column); - } - if("方案说明".equals(column)){ - schemeList.add(column); - } - if("职等编号".equals(column)){ - levelList.add(0,column); - gradeList.add(column); - } - if("职等名称".equals(column)){ - levelList.add(1,column); - } - if("职等说明".equals(column)){ - levelList.add(column); - } - if("职级编号".equals(column)){ - gradeList.add(0,column); - } - if("职级名称".equals(column)){ - gradeList.add(1,column); - } - if("职级说明".equals(column)){ - gradeList.add(column); + if ("joblevel".equals(importType)) { + if ("方案编号".equals(column)) { + schemeList.add(column); + levelList.add(column); + gradeList.add(column); + } + if ("方案名称".equals(column)) { + schemeList.add(column); + } + if ("方案说明".equals(column)) { + schemeList.add(column); + } + if ("职等编号".equals(column)) { + levelList.add(0, column); + gradeList.add(column); + } + if ("职等名称".equals(column)) { + levelList.add(1, column); + } + if ("职等说明".equals(column)) { + levelList.add(column); + } + if ("职级编号".equals(column)) { + gradeList.add(0, column); + } + if ("职级名称".equals(column)) { + gradeList.add(1, column); + } + if ("职级说明".equals(column)) { + gradeList.add(column); + } } } if (StringUtils.isNotBlank(departmentColumn.toString())) { @@ -2047,14 +844,14 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ if ("joblevel".equals(importType)) { excelSheetData.clear(); excelSheetData.add(schemeList); - ExcelUtil.genWorkbookV3(sheets,excelSheetData,0, "方案"); + ExcelUtil.genWorkbookV3(sheets, excelSheetData, 0, "方案"); excelSheetData.clear(); excelSheetData.add(levelList); - ExcelUtil.genWorkbookV3(sheets,excelSheetData,1, "职等"); + ExcelUtil.genWorkbookV3(sheets, excelSheetData, 1, "职等"); excelSheetData.clear(); excelSheetData.add(gradeList); - ExcelUtil.genWorkbookV3(sheets,excelSheetData,2, "职级"); - }else{ + ExcelUtil.genWorkbookV3(sheets, excelSheetData, 2, "职级"); + } else { sheets = ExcelUtil.genWorkbookV2(excelSheetData, importType); } String excelPath = outPutPath + File.separator + importType + ".xls"; @@ -2076,8 +873,4 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ return excelPath; } - private boolean isThrowError(Map resultMap) { - return "1".equals(Util.null2String(resultMap.get("status"))) || "1".equals(Util.null2String(resultMap.get("sign"))); - } - } diff --git a/src/com/engine/organization/service/impl/JclOrgServiceImpl.java b/src/com/engine/organization/service/impl/JclOrgServiceImpl.java new file mode 100644 index 00000000..4a608ae9 --- /dev/null +++ b/src/com/engine/organization/service/impl/JclOrgServiceImpl.java @@ -0,0 +1,60 @@ +package com.engine.organization.service.impl; + +import com.engine.core.impl.Service; +import com.engine.organization.service.JclOrgService; +import com.engine.organization.util.field.StaticFieldName; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; + +/** + * @author:dxfeng + * @createTime: 2022/12/16 + * @version: 1.0 + */ +public class JclOrgServiceImpl extends Service implements JclOrgService { + + @Override + public void supplementResourceInfo(Integer userId) { + // 查询职等职级字段 + RecordSet rs = new RecordSet(); + // 所有字段信息存在,执行业务逻辑 + if (StringUtils.isNoneBlank(StaticFieldName.zdzjFieldName, StaticFieldName.schemeFieldName, StaticFieldName.levelFieldName, StaticFieldName.gradeFieldName, StaticFieldName.sequenceFieldName)) { + String zdzjFieldValue = ""; + String schemeFieldValue = ""; + String levelFieldValue = ""; + String gradeFieldValue = ""; + String sequenceFieldValue = ""; + String sql = "select " + StaticFieldName.zdzjFieldName + " from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id= " + userId; + rs.execute(sql); + if (rs.next()) { + zdzjFieldValue = rs.getString(StaticFieldName.zdzjFieldName); + } + // 职等职级为空时不处理 + if (StringUtils.isBlank(zdzjFieldValue)) { + return; + } + sql = "select xlid, zjid, zdid from v_jcl_zdzjs where fid='" + zdzjFieldValue.substring(zdzjFieldValue.indexOf("_") + 1) + "'"; + rs.execute(sql); + if (rs.next()) { + levelFieldValue = rs.getString("zdid"); + gradeFieldValue = rs.getString("zjid"); + sequenceFieldValue = rs.getString("xlid"); + } + sql = "select scheme_id from jcl_org_sequence where id='" + sequenceFieldValue + "'"; + rs.execute(sql); + if (rs.next()) { + schemeFieldValue = rs.getString("scheme_id"); + } + + // 更新字段信息 + sql = "update cus_fielddata set " + StaticFieldName.sequenceFieldName + " = '" + sequenceFieldValue + "' where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=" + userId; + rs.execute(sql); + sql = "update cus_fielddata set " + StaticFieldName.schemeFieldName + " = '" + schemeFieldValue + "' where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=" + userId; + rs.execute(sql); + sql = "update cus_fielddata set " + StaticFieldName.levelFieldName + " = '" + levelFieldValue + "' where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=" + userId; + rs.execute(sql); + sql = "update cus_fielddata set " + StaticFieldName.gradeFieldName + " = '" + gradeFieldValue + "' where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=" + userId; + rs.execute(sql); + } + } +} diff --git a/src/com/engine/organization/service/impl/JobServiceImpl.java b/src/com/engine/organization/service/impl/JobServiceImpl.java index 892763c4..5fb5b489 100644 --- a/src/com/engine/organization/service/impl/JobServiceImpl.java +++ b/src/com/engine/organization/service/impl/JobServiceImpl.java @@ -14,14 +14,13 @@ import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.browser.po.CustomBrowserBean; import com.engine.organization.entity.codesetting.po.CodeRulePO; -import com.engine.organization.entity.commom.RecordInfo; import com.engine.organization.entity.company.bo.CompBO; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.bo.DepartmentBO; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.employee.vo.EmployeeTableVO; import com.engine.organization.entity.extend.po.ExtendTitlePO; -import com.engine.organization.entity.hrmresource.po.HrmResourcePO; +import com.engine.organization.entity.hrmresource.po.ResourcePO; import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.entity.job.dto.JobListDTO; import com.engine.organization.entity.job.param.JobMergeParam; @@ -30,23 +29,19 @@ import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.scheme.po.GradePO; import com.engine.organization.entity.searchtree.SearchTree; import com.engine.organization.entity.searchtree.SearchTreeParams; -import com.engine.organization.enums.LogModuleNameEnum; -import com.engine.organization.enums.OperateTypeEnum; +import com.engine.organization.enums.DeleteTypeEnum; +import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.mapper.codesetting.CodeRuleMapper; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.extend.ExtDTMapper; import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtendTitleMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.mapper.resource.ResourceMapper; +import com.engine.organization.mapper.resource.HrmResourceMapper; import com.engine.organization.mapper.scheme.GradeMapper; import com.engine.organization.service.ExtService; import com.engine.organization.service.JobService; -import com.engine.organization.thread.HrmResourceTriggerRunnable; -import com.engine.organization.thread.JobTriggerRunnable; -import com.engine.organization.thread.OrganizationSyncEc; import com.engine.organization.util.*; import com.engine.organization.util.coderule.CodeRuleUtil; import com.engine.organization.util.db.MapperProxyFactory; @@ -54,11 +49,9 @@ import com.engine.organization.util.detach.DetachUtil; import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; -import com.engine.organization.util.relation.EcHrmRelationUtil; import com.engine.organization.util.tree.SearchTreeUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; -import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; import weaver.hrm.User; @@ -106,8 +99,6 @@ public class JobServiceImpl extends Service implements JobService { private static final String RIGHT_NAME = "Job:All"; - public static final String JOB_ACTIVITY_ID; - /** * 岗位主表title指定ID */ @@ -129,20 +120,15 @@ public class JobServiceImpl extends Service implements JobService { return MapperProxyFactory.getProxy(ExtendTitleMapper.class); } - private ResourceMapper getResourceMapper() { - return MapperProxyFactory.getProxy(ResourceMapper.class); - } - private ExtService getExtService(User user) { return ServiceUtil.getService(ExtServiceImpl.class, user); } - - static { - RecordInfo hrmJobActivity = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmObjectByUUID("hrmjobactivities", "3a2efce3-95de-4ec2-afe1-347783817bdb"); - JOB_ACTIVITY_ID = hrmJobActivity.getId(); + private HrmResourceMapper getHrmResourceMapper() { + return MapperProxyFactory.getProxy(HrmResourceMapper.class); } + @Override public Map getSearchTree(SearchTreeParams params) { String keyword = params.getKeyword(); @@ -163,14 +149,14 @@ public class JobServiceImpl extends Service implements JobService { JobPO jobPO = JobBO.convertParamsToPO(param, user.getUID()); boolean filter = isFilter(jobPO); PageInfo pageInfos; - String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams()); + String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " show_order "); List allList = getJobMapper().listNoFilter(orderSql); - new DetachUtil(user.getUID()).filterJobDTOList(allList); + new DetachUtil(user).filterJobDTOList(allList); // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 List filterJobPOs = getJobMapper().listByFilter(jobPO, orderSql); - new DetachUtil(user.getUID()).filterJobDTOList(allList); + new DetachUtil(user).filterJobDTOList(allList); // 添加父级元素 List jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs); List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS); @@ -204,7 +190,20 @@ public class JobServiceImpl extends Service implements JobService { @Override public Map> getHasRight() { - return MenuBtn.getDatasHasCopy(); + Map> btnDatas = new HashMap<>(); + ArrayList topMenuList = new ArrayList<>(); + ArrayList rightMenuList = new ArrayList<>(); + // 批量删除 + topMenuList.add(MenuBtn.topMenu_batchDelete()); + topMenuList.add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("refresh").menuIcon("icon-coms-Refresh").menuName("刷新").type("BTN_REFRESH").build()); + topMenuList.add(MenuBtn.topMenu_addNew()); + btnDatas.put("topMenu", topMenuList); + // 日志 + rightMenuList.add(MenuBtn.rightMenu_btnLog()); + rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("refresh").menuIcon("icon-coms-Refresh").menuName("刷新").type("BTN_REFRESH").build()); + rightMenuList.add(MenuBtn.rightMenu_addNew()); + btnDatas.put("rightMenu", rightMenuList); + return btnDatas; } @Override @@ -215,23 +214,11 @@ public class JobServiceImpl extends Service implements JobService { // 编号 SearchConditionItem jobNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "jobNo"); // 名称 - SearchConditionItem jobNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "jobName"); + SearchConditionItem jobTitleNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "jobTitleName"); // 所属分部 - SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "ecCompany", ""); + SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "subcompanyid1", ""); // 所属部门 - SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属部门", "4", "ecDepartment", ""); - // 岗位序列 - SearchConditionItem sequenceBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "岗位序列", "161", "sequenceId", "sequenceBrowser"); - // 等级方案 - SearchConditionItem schemeBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "等级方案", "161", "schemeId", "schemeBrowser"); - // 上级岗位 - SearchConditionItem parentJobBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级岗位", "666", "parentJob", ""); - BrowserBean browserBean = parentJobBrowserItem.getBrowserConditionParam(); - String s = JSONObject.toJSONString(browserBean); - CustomBrowserBean customBrowserBean = JSONObject.parseObject(s, CustomBrowserBean.class); - customBrowserBean.setHasLeftTree(true); - customBrowserBean.setLeftToSearchKey("treeKey"); - parentJobBrowserItem.setBrowserConditionParam(customBrowserBean); + SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属部门", "4", "departmentid", ""); // 是否关键岗 List isKeyOptions = new ArrayList<>(); SearchConditionOption yesOption = new SearchConditionOption("0", "否"); @@ -242,23 +229,20 @@ public class JobServiceImpl extends Service implements JobService { // 工作地点 SearchConditionItem workplaceItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "工作地点", "workplace"); // 禁用标记 - List selectOptions = new ArrayList<>(); - SearchConditionOption enableOption = new SearchConditionOption("true", "启用"); - SearchConditionOption disableOption = new SearchConditionOption("false", "禁用"); - selectOptions.add(enableOption); - selectOptions.add(disableOption); - SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag"); + //List selectOptions = new ArrayList<>(); + //SearchConditionOption enableOption = new SearchConditionOption("true", "启用"); + //SearchConditionOption disableOption = new SearchConditionOption("false", "封存"); + //selectOptions.add(enableOption); + //selectOptions.add(disableOption); + //SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "封存", "forbiddenTag"); conditionItems.add(jobNoItem); - conditionItems.add(jobNameItem); + conditionItems.add(jobTitleNameItem); conditionItems.add(parentCompBrowserItem); conditionItems.add(parentDeptBrowserItem); - conditionItems.add(sequenceBrowserItem); - conditionItems.add(schemeBrowserItem); - conditionItems.add(parentJobBrowserItem); conditionItems.add(isKeyItem); conditionItems.add(workplaceItem); - conditionItems.add(forbiddenTagItem); + //conditionItems.add(forbiddenTagItem); addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems)); apiDatas.put("conditions", addGroups); @@ -278,7 +262,7 @@ public class JobServiceImpl extends Service implements JobService { CompPO compPO = getCompMapper().listById(param.getSubcompanyid1()); if (null != compPO) { params.put("parent_comp", compPO.getId()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(compPO.getId().toString())); + params.put("ec_company", compPO.getId()); } } // 部门 @@ -286,9 +270,9 @@ public class JobServiceImpl extends Service implements JobService { DepartmentPO deptById = getDepartmentMapper().getDeptById(param.getDepartmentid()); if (null != deptById) { params.put("parent_dept", deptById.getId()); - params.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(deptById.getId().toString())); - params.put("parent_comp", deptById.getParentComp()); - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(deptById.getParentComp().toString())); + params.put("ec_department", deptById.getId()); + params.put("parent_comp", deptById.getSubCompanyId1()); + params.put("ec_company", deptById.getSubCompanyId1()); } } for (ExtendTitlePO extendTitle : extendTitles) { @@ -322,7 +306,7 @@ public class JobServiceImpl extends Service implements JobService { List extendTitles = getExtendTitleMapper().getTitlesByGroupID(Long.parseLong(groupId), "1"); if (CollectionUtils.isNotEmpty(extendTitles)) { for (ExtendTitlePO extendTitle : extendTitles) { - List items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_JOB : JCL_ORG_JOBEXT, viewAttr, id, extendTitle.getId().toString(), "scheme_id", "parent_comp"); + List items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_JOB : JCL_ORG_JOBEXT, viewAttr, id, extendTitle.getId().toString(), "ec_jobTitle", "ec_department", "ec_company"); if (CollectionUtils.isNotEmpty(items)) { addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items)); } @@ -358,26 +342,20 @@ public class JobServiceImpl extends Service implements JobService { public Long saveBaseForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class); - assertNameRepeat(null, searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName()); - String jobNo = (String) params.get("job_no"); - // 判断是否开启自动编号 - jobNo = repeatDetermine(jobNo); - params.put("job_no", jobNo); + //String jobNo = (String) params.get("job_no"); + //// 判断是否开启自动编号 + //jobNo = repeatDetermine(jobNo); + //params.put("job_no", jobNo); params.put("is_key", null == searchParam.getIsKey() ? 0 : searchParam.getIsKey()); if (null != searchParam.getParentJob()) { JobPO parentJob = getJobMapper().getJobById(searchParam.getParentJob()); - params.put("parent_dept", parentJob.getParentDept()); - params.put("parent_comp", parentJob.getParentComp()); params.put("ec_company", parentJob.getEcCompany()); params.put("ec_department", parentJob.getEcDepartment()); } else { - Long ecDepartment = searchParam.getEcDepartment(); - DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecDepartment)); - params.put("parent_dept", jclDepartment.getId()); - params.put("parent_comp", jclDepartment.getParentComp()); - if (null != jclDepartment.getParentComp()) { - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartment.getParentComp()))); - } + Integer ecDepartment = searchParam.getEcDepartment(); + DepartmentPO jclDepartment = getDepartmentMapper().getDeptById(ecDepartment); + params.put("ec_department", jclDepartment.getId()); + params.put("ec_company", jclDepartment.getSubCompanyId1()); } if (StringUtils.isBlank(params.get("show_order").toString())) { @@ -387,8 +365,17 @@ public class JobServiceImpl extends Service implements JobService { } params.put("show_order", maxShowOrder + 1); } - params.put("jobactivityid", JOB_ACTIVITY_ID); - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, params).sync(); + // 判断岗位是否重复 + ResourcePO build = ResourcePO.builder().subcompanyid1(Integer.parseInt(Util.null2String(params.get("ec_company")))).departmentid(Integer.parseInt(Util.null2String(params.get("ec_department")))).jobtitle(Integer.parseInt(Util.null2String(params.get("ec_jobTitle")))).build(); + int count = getJobMapper().selectByConditions(build); + OrganizationAssert.isTrue(count <= 0, "已存在相同维度岗位,请勿重复添加"); + + String jobNo = (String) params.get("job_no"); + // 判断是否开启自动编号 + jobNo = repeatDetermine(jobNo); + params.put("job_no", jobNo); + //params.put("jobactivityid", JOB_ACTIVITY_ID); + //new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, params).sync(); return getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOB, params, "", null); } @@ -396,7 +383,6 @@ public class JobServiceImpl extends Service implements JobService { public Long updateForm(Map params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class); - assertNameRepeat(searchParam.getId(), searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName()); String groupId = (String) params.get("viewCondition"); searchParam.setIsKey(null == searchParam.getIsKey() ? 0 : searchParam.getIsKey()); // 上级岗位不能选择本身 @@ -404,45 +390,33 @@ public class JobServiceImpl extends Service implements JobService { if (StringUtils.isNotBlank(parent_job)) { OrganizationAssert.isFalse(parent_job.equals(searchParam.getId().toString()), "上级岗位不能选择本身"); } - if ("0".equals(groupId)) { - groupId = GROUP_ID.toString(); - } - JobPO oldJobPO = getJobMapper().getJobById(searchParam.getId()); - String oldJobNo = oldJobPO.getJobNo(); - String jobNo = searchParam.getJobNo(); - if (!jobNo.equals(oldJobNo)) { - jobNo = repeatDetermine(jobNo); - params.put("job_no", jobNo); - } + if ("0".equals(groupId) || GROUP_ID.toString().equals(groupId)) { + JobPO oldJobPO = getJobMapper().getJobById(searchParam.getId()); + String oldJobNo = oldJobPO.getJobNo(); + String jobNo = searchParam.getJobNo(); + if (!jobNo.equals(oldJobNo)) { + jobNo = repeatDetermine(jobNo); + params.put("job_no", jobNo); + } - // 更新主表数据 - params.put("is_key", searchParam.getIsKey()); - if (null != searchParam.getParentJob()) { - JobPO parentJob = getJobMapper().getJobById(searchParam.getParentJob()); - params.put("parent_dept", parentJob.getParentDept()); - params.put("parent_comp", parentJob.getParentComp()); - params.put("ec_company", parentJob.getEcCompany()); - params.put("ec_department", parentJob.getEcDepartment()); - } else { - Long ecDepartment = searchParam.getEcDepartment(); - DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecDepartment)); - params.put("parent_dept", jclDepartment.getId()); - params.put("parent_comp", jclDepartment.getParentComp()); - if (null != jclDepartment.getParentComp()) { - params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartment.getParentComp()))); + // 更新主表数据 + params.put("is_key", searchParam.getIsKey()); + if (null != searchParam.getParentJob()) { + JobPO parentJob = getJobMapper().getJobById(searchParam.getParentJob()); + params.put("ec_company", parentJob.getEcCompany()); + params.put("ec_department", parentJob.getEcDepartment()); + } else { + Integer ecDepartment = searchParam.getEcDepartment(); + DepartmentPO jclDepartment = getDepartmentMapper().getDeptById(ecDepartment); + params.put("ec_department", jclDepartment.getId()); + params.put("ec_company", jclDepartment.getSubCompanyId1()); } + getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOB, params, "", searchParam.getId()); } - params.put("jobactivityid", JOB_ACTIVITY_ID); - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, oldJobPO).sync(); - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOB, params, "", searchParam.getId()); // 更新主表拓展表 - getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOBEXT, params, groupId, searchParam.getId()); + getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOBEXT, params, "", searchParam.getId()); // 更新明细表 getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_JOBEXT_DT1, params, searchParam.getId()); - JobPO jobById = getJobMapper().getJobById(searchParam.getId()); - new JobTriggerRunnable(oldJobPO, jobById).run(); - // 更新人员关联字段 - updateResourceJob(jobById); return searchParam.getId(); } @@ -461,21 +435,18 @@ public class JobServiceImpl extends Service implements JobService { // 处理自动编号 jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), System.currentTimeMillis())); // 部门赋值 - jobById.setEcDepartment(Long.parseLong(department)); - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(department); + jobById.setEcDepartment(Integer.parseInt(department)); + DepartmentPO jclDepartmentId = getDepartmentMapper().getDeptById(jobById.getEcDepartment()); if (null != jclDepartmentId) { - jobById.setParentDept(jclDepartmentId.getId()); //分部赋值 - jobById.setEcCompany(jclDepartmentId.getEcCompany()); - jobById.setParentComp(jclDepartmentId.getParentComp()); + jobById.setEcCompany(jclDepartmentId.getSubCompanyId1()); } // 清空上级岗位 jobById.setParentJob(null); jobById.setShowOrder(orderNum); - assertNameRepeat(null, jobById.getEcDepartment(), jobById.getParentJob(), jobById.getJobName()); insertCount += getJobMapper().insertIgnoreNull(jobById); // 更新组织架构图 - new JobTriggerRunnable(jobById.getId()).run(); + //TODO new JobTriggerRunnable(jobById.getId()).run(); } return insertCount; @@ -485,11 +456,11 @@ public class JobServiceImpl extends Service implements JobService { public int updateForbiddenTagById(JobSearchParam params) { HasRightUtil.hasRight(user, RIGHT_NAME, false); JobPO jobById = getJobMapper().getJobById(params.getId()); - JobPO jobPO = JobPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).jobName(jobById.getJobName()).build(); + JobPO jobPO = JobPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build(); if (params.getForbiddenTag()) { // 启用:判断上级部门是否启用,上级部门启用,岗位才可启用 - DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(jobById.getParentDept()); - OrganizationAssert.isTrue(0 == parentDepartment.getForbiddenTag(), "该岗位不能解封,请先解封上级部门"); + DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(jobById.getEcDepartment()); + OrganizationAssert.isTrue(0 == parentDepartment.getCanceled(), "该岗位不能解封,请先解封上级部门"); // 启用:判断上级岗位是否启用,上级岗位启用,岗位才可启用 if (null != jobById.getParentJob()) { @@ -498,10 +469,11 @@ public class JobServiceImpl extends Service implements JobService { } } else { //禁用:判断当前岗位下是否有人员,如有人员则不能禁用 - int hasResource = getJobMapper().isHasResource(params.getId()); - OrganizationAssert.isTrue(hasResource == 0, "该岗位存在人员,不能封存"); + // int hasResource = getJobMapper().isHasResource(params.getId()); + // OrganizationAssert.isTrue(hasResource == 0, "该岗位存在人员,不能封存"); + throw new OrganizationRunTimeException("该岗位不能封存"); } - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobPO).sync(); + //new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobPO).sync(); return getJobMapper().updateForbiddenTagById(jobPO.getId(), jobPO.getForbiddenTag()); } @@ -511,11 +483,15 @@ public class JobServiceImpl extends Service implements JobService { OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); List jobsByIds = getJobMapper().getJobsByIds(ids); for (JobPO jobsById : jobsByIds) { - jobsById.setForbiddenTag(1); - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobsById).sync(); + // 判断是否可以删除 + List allowDelete = getJobMapper().isAllowDelete(jobsById.getId()); + OrganizationAssert.isTrue(CollectionUtils.isEmpty(allowDelete), "该岗位存在引用,不允许删除"); + + // jobsById.setForbiddenTag(1); + //new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobsById).sync(); // 删除拓展表、明细表 MapperProxyFactory.getProxy(ExtMapper.class).deleteByID("jcl_org_jobext", jobsById.getId()); - MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_jobext_dt1", jobsById.getId()); + MapperProxyFactory.getProxy(ExtDTMapper.class).deleteByMainID("jcl_org_jobext_dt1", jobsById.getId(), null); } return getJobMapper().deleteByIds(ids); } @@ -523,7 +499,16 @@ public class JobServiceImpl extends Service implements JobService { @Override public Map getHrmListByJobId(Long jobId) { OrganizationWeaTable table = new OrganizationWeaTable<>(user, EmployeeTableVO.class); - table.setSqlwhere(" where job_title = '" + jobId + "' and status<4"); + String sqlWhere = " where 1=1 "; + JobPO ecJobTitleByJobId = JobBO.getEcJobTitleByJobId(jobId); + if (null != ecJobTitleByJobId) { + sqlWhere += " AND t.subcompanyid1 = '" + ecJobTitleByJobId.getEcCompany() + "'"; + sqlWhere += " AND t.departmentid = '" + ecJobTitleByJobId.getEcDepartment() + "'"; + sqlWhere += " AND t.jobtitle = '" + ecJobTitleByJobId.getEcJobTitle() + "'"; + } else { + sqlWhere = " where 1 = 2 "; + } + table.setSqlwhere(sqlWhere + " and status<4"); WeaResultMsg result = new WeaResultMsg(false); result.putAll(table.makeDataResult()); result.success(); @@ -544,11 +529,6 @@ public class JobServiceImpl extends Service implements JobService { deptBrowserItem.setBrowserConditionParam(customBrowserBean); SearchConditionItem mergeNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "合并后名称", "mergeName"); mergeNameItem.setRules("required|string"); - JobPO jobById = getJobMapper().getJobById(id); - if (null != jobById) { - String jobName = jobById.getJobName(); - mergeNameItem.setValue(jobName); - } condition.add(deptBrowserItem); condition.add(mergeNameItem); addGroups.add(new SearchConditionGroup("", true, condition)); @@ -577,45 +557,68 @@ public class JobServiceImpl extends Service implements JobService { // 待合并的部门 JobPO jobById = getJobMapper().getJobById(mergeParam.getId()); - assertNameRepeat(targetJob.getId(), targetJob.getEcDepartment(), targetJob.getParentJob(), mergeParam.getMergeName()); // 递归处理子岗位所属分部、所部部门、上级岗位 - recursionMergeJob(jobs, targetJob.getParentComp(), targetJob.getEcCompany(), targetJob.getParentDept(), targetJob.getEcDepartment(), targetJob.getId()); + recursionMergeJob(jobs, targetJob.getEcCompany(), targetJob.getEcDepartment(), targetJob.getId()); // 人员信息变动,更新分部、部门、岗位 - updateResourceJob(jobById, targetJob); + // updateResourceJob(jobById, targetJob); // 更新合并后的岗位,更新组织架构图 - updateEcJob(targetJob, mergeParam.getMergeName()); + // updateEcJob(targetJob, mergeParam.getMergeName()); - targetJob.setJobName(mergeParam.getMergeName()); + // TODO targetJob.setJobName(mergeParam.getMergeName()); getJobMapper().updateBaseJob(targetJob); - new JobTriggerRunnable(jobById.getId(),targetJob.getId()).run(); + //TODO new JobTriggerRunnable(jobById.getId(), targetJob.getId()).run(); // 原岗位删除 - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobById).sync(); + //new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobById).sync(); getJobMapper().deleteByIds(Collections.singletonList(jobById.getId())); // 更新组织架构图 - new JobTriggerRunnable(jobById).run(); + //TODO new JobTriggerRunnable(jobById).run(); return updateCount; } + @Override + public void refresh() { + //1.人员表查询 + List resourcePOS = getHrmResourceMapper().selectFilterDatas(); + //2.数据过滤 + //3.数据插入 + resourcePOS.forEach(resourcePO -> { + if (Objects.nonNull(resourcePO) && null != resourcePO.getJobtitle() && resourcePO.getJobtitle() > 0) { + int count = getJobMapper().selectByConditions(resourcePO); + if (count == 0) { + JobPO jobPO = JobPO.builder() + .ecCompany(resourcePO.getSubcompanyid1()) + .ecDepartment(resourcePO.getDepartmentid()) + .ecJobTitle(resourcePO.getJobtitle()) + .isKey(0) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .build(); + getJobMapper().insertIgnoreNull(jobPO); + } + } + }); + + } + - void recursionMergeJob(List jobs, Long parentCompany, Long ecCompany, Long parentDepartment, Long ecDepartment, Long parentJob) { + void recursionMergeJob(List jobs, Integer ecCompany, Integer ecDepartment, Long parentJob) { for (JobPO job : jobs) { - job.setParentComp(parentCompany); job.setEcCompany(ecCompany); - job.setParentDept(parentDepartment); job.setEcDepartment(ecDepartment); job.setParentJob(parentJob); getJobMapper().updateBaseJob(job); // 更新人员信息 - updateResourceJob(job); + // updateResourceJob(job); // 更新组织架构图 - new JobTriggerRunnable(job.getId()).run(); + //TODO new JobTriggerRunnable(job.getId()).run(); // 递归处理子级元素 List jobsByPid = getJobMapper().getJobsByPid(job.getId()); - recursionMergeJob(jobsByPid, parentCompany, ecCompany, parentDepartment, ecDepartment, parentJob); + recursionMergeJob(jobsByPid, ecCompany, ecDepartment, parentJob); } } @@ -627,11 +630,11 @@ public class JobServiceImpl extends Service implements JobService { */ private void buildParentDepts(DepartmentPO departmentPO, Set builderDeparts) { builderDeparts.add(departmentPO); - if (SearchTreeUtil.isTop(departmentPO.getParentDept())) { + if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) { return; } - DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept()); - if (null != parentDept && 0 == parentDept.getForbiddenTag()) { + DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getSupDepId()); + if (null != parentDept && (null == parentDept.getCanceled() || 0 == parentDept.getCanceled())) { buildParentDepts(parentDept, builderDeparts); } } @@ -642,11 +645,11 @@ public class JobServiceImpl extends Service implements JobService { * @param compPO * @param builderComps */ - private void buildParentComps(CompPO compPO, Set builderComps,Map allMaps) { + private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { builderComps.add(compPO); - CompPO parentComp = allMaps.get(compPO.getParentCompany()); - if (null != parentComp && 0 == parentComp.getForbiddenTag()) { - buildParentComps(parentComp, builderComps,allMaps); + CompPO parentComp = allMaps.get(compPO.getSupSubComId()); + if (null != parentComp && (null == parentComp.getCanceled() || 0 == parentComp.getCanceled())) { + buildParentComps(parentComp, builderComps, allMaps); } } @@ -662,14 +665,14 @@ public class JobServiceImpl extends Service implements JobService { List searchTree = new ArrayList<>(); // 通过分部、公司 组装数据 if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) { - Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id); - DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).forbiddenTag(0).build(); - CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).forbiddenTag(0).build(); + Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); + DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(parentCompId).canceled(0).build(); + CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build(); searchTree = buildTreeByCompAndDept(departmentBuild, compBuild); } else if (TYPE_DEPT.equals(type)) { // // 查询部门信息 - List filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).forbiddenTag(0).parentDept(Long.parseLong(id)).build(), "show_order"); + List filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().departmentName(keyword).canceled(0).supDepId(Integer.parseInt(id)).build(), "showorder"); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { buildParentDepts(departmentPO, builderDeparts); @@ -688,11 +691,11 @@ public class JobServiceImpl extends Service implements JobService { * @return */ private List buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild) { - List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "show_order"); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts); + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + new DetachUtil(user).filterDepartmentList(filterDeparts); // 查询分部信息 - List filterComps = getCompMapper().listByFilter(compBuild, "show_order"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); + new DetachUtil(user).filterCompanyList(filterComps); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { buildParentDepts(departmentPO, builderDeparts); @@ -706,12 +709,12 @@ public class JobServiceImpl extends Service implements JobService { filterComps.addAll(compsByIds); } } - List allCompanys = getCompMapper().list("show_order"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); - Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); + List allCompanys = getCompMapper().listAll("showorder"); + new DetachUtil(user).filterCompanyList(allCompanys); + Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); Set builderComps = new HashSet<>(); for (CompPO compPO : filterComps) { - buildParentComps(compPO, builderComps,allMaps); + buildParentComps(compPO, builderComps, allMaps); } return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees); } @@ -725,13 +728,11 @@ public class JobServiceImpl extends Service implements JobService { */ private boolean isFilter(JobPO jobPO) { return !(StringUtil.isEmpty(jobPO.getJobNo()) - && StringUtil.isEmpty(jobPO.getJobName()) + && StringUtil.isEmpty(jobPO.getJobTitleName()) && StringUtil.isEmpty(jobPO.getWorkplace()) && StringUtil.isEmpty(jobPO.getDescription()) && StringUtil.isEmpty(jobPO.getWorkDuty()) && StringUtil.isEmpty(jobPO.getWorkAuthority()) - && null == jobPO.getParentComp() - && null == jobPO.getParentDept() && null == jobPO.getParentJob() && null == jobPO.getSequenceId() && null == jobPO.getSchemeId() @@ -739,6 +740,7 @@ public class JobServiceImpl extends Service implements JobService { && null == jobPO.getForbiddenTag() && null == jobPO.getEcCompany() && null == jobPO.getEcDepartment() + && null == jobPO.getEcJobTitle() ); } @@ -754,9 +756,8 @@ public class JobServiceImpl extends Service implements JobService { List list = getJobMapper().listByNo(Util.null2String(jobNo)); OrganizationAssert.isEmpty(list, "编号不允许重复"); } else { - if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) { - jobNo = autoCreateCompanyNo(); - } + OrganizationAssert.isTrue(null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable()), "编号不允许为空"); + jobNo = autoCreateCompanyNo(); } return jobNo; } @@ -775,30 +776,6 @@ public class JobServiceImpl extends Service implements JobService { return generateCode; } - /** - * 获取所有子部门id - * - * @param parentComp - * @param parentDept - * @param jobList - */ - void forbiddenChildTag(Long parentComp, Long parentDept, Long parentJob, List jobList) { - if (CollectionUtils.isNotEmpty(jobList)) { - for (JobPO job : jobList) { - job.setParentComp(parentComp); - job.setParentDept(parentDept); - job.setParentJob(parentJob); - job.setForbiddenTag(1); - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, job).sync(); - getJobMapper().updateBaseJob(job); - // 更新组织架构图 - new JobTriggerRunnable(job.getId()).run(); - List childJobs = getJobMapper().getJobsByPid(job.getId()); - forbiddenChildTag(parentComp, parentDept, job.getId(), childJobs); - } - } - } - /** * 添加子元素ID * @@ -813,95 +790,19 @@ public class JobServiceImpl extends Service implements JobService { } } - /** - * 更新EC岗位 - * - * @param jobPO - */ - private void updateEcJob(JobPO jobPO, String newName) { - Map params = new HashMap<>(); - params.put("job_name", newName); - params.put("jobactivityid", JOB_ACTIVITY_ID); - params.put("work_duty", jobPO.getWorkDuty()); - params.put("work_authority", jobPO.getWorkAuthority()); - params.put("description", jobPO.getDescription()); - params.put("job_no", jobPO.getJobNo()); - new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, jobPO).sync(); - } - - - /** - * 判断相同层级下有无同名岗位 - */ - public static void assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName) { - assertNameRepeat(jobId, departmentId, parentJobId, jobName, true); - } - - /** - * 判断相同层级下有无同名岗位 - */ - public static boolean assertNameRepeat(String jobId, String departmentId, String parentJobId, String jobName) { - return assertNameRepeat(StringUtils.isBlank(jobId) ? null : Long.parseLong(jobId), StringUtils.isBlank(departmentId) ? null : Long.parseLong(departmentId), StringUtils.isBlank(parentJobId) ? null : Long.parseLong(parentJobId), jobName, false); - } - - /** - * 判断相同层级下有无同名岗位 - * - * @param jobId - * @param departmentId - * @param parentJobId - * @param jobName - * @param throwException - * @return - */ - public static boolean assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName, boolean throwException) { - int count = 0; - // 有上级岗位、判断相同层级下有无相同名称岗位 - if (null != jobId) { - count = getJobMapper().countRepeatNameByPid(jobName, jobId, parentJobId, departmentId); - } else { - // 无上级岗位,判断当前部门下,有无同名岗位 - count = getJobMapper().countRepeatNameByPid(jobName, jobId, null, departmentId); - } - if (throwException) { - OrganizationAssert.isTrue(count == 0, "岗位名称已存在"); - } - return count == 0; - } - - - /** - * 更新人员岗位信息 - * - * @param originalJob - * @param targetJob - */ - private void updateResourceJob(JobPO originalJob, JobPO targetJob) { - // 更新岗位下的人员 - Long originalJobId = originalJob.getId(); - Long targetJobId = targetJob.getId(); - Long parentComp = targetJob.getParentComp(); - Long parentDept = targetJob.getParentDept(); - Long ecCompany = targetJob.getEcCompany(); - Long ecDepartment = targetJob.getEcDepartment(); - List resourceList = getResourceMapper().getResourceListByJobId(originalJobId); - getResourceMapper().updateResourceJob(originalJobId, targetJobId, parentComp, parentDept, ecCompany, ecDepartment); - - // 更新Ec人员分部、部门、岗位 - for (HrmResourcePO hrmResourcePO : resourceList) { - new RecordSet().executeUpdate("UPDATE HRMRESOURCE SET SUBCOMPANYID1 = ? , DEPARTMENTID = ? WHERE UUID =? ", ecCompany, ecDepartment, hrmResourcePO.getUuid()); - // 更新人员Map表信息 - new HrmResourceTriggerRunnable(hrmResourcePO.getId()).run(); - } - } - - - /** - * 更新人员岗位信息 - * - * @param job - */ - private void updateResourceJob(JobPO job) { - updateResourceJob(job, job); - } + ///** + // * 更新EC岗位 + // * + // * @param jobPO + // */ + //private void updateEcJob(JobPO jobPO, String newName) { + // Map params = new HashMap<>(); + // params.put("job_name", newName); + // params.put("jobactivityid", JOB_ACTIVITY_ID); + // params.put("work_duty", jobPO.getWorkDuty()); + // params.put("work_authority", jobPO.getWorkAuthority()); + // params.put("description", jobPO.getDescription()); + // params.put("job_no", jobPO.getJobNo()); + // new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, jobPO).sync(); + //} } diff --git a/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java b/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java index 36b3b456..717e9c8f 100644 --- a/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java +++ b/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java @@ -13,14 +13,13 @@ import com.engine.organization.entity.detach.po.ManagerDetachPO; import com.engine.organization.entity.detach.vo.ManagerDetachVO; import com.engine.organization.mapper.detach.ManagerDetachMapper; import com.engine.organization.mapper.employee.EmployeeMapper; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; +import com.engine.organization.mapper.resource.ResourceMapper; import com.engine.organization.service.ManagerDetachService; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.OrganizationFormItemUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.relation.EcHrmRelationUtil; import com.weaver.file.ConfigOperator; import com.weaver.general.BaseBean; import org.apache.commons.collections.CollectionUtils; @@ -46,8 +45,8 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe return MapperProxyFactory.getProxy(ManagerDetachMapper.class); } - public HrmResourceMapper getHrmResourceMapper() { - return MapperProxyFactory.getProxy(HrmResourceMapper.class); + public ResourceMapper getResourceMapper() { + return MapperProxyFactory.getProxy(ResourceMapper.class); } public EmployeeMapper getEmployeeMapper() { @@ -123,9 +122,9 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe ManagerDetachPO managerDetachPO = ManagerDetachPO.builder() .managerType(0) .ecManager(param.getEcManager()) - .jclManager(getHrmResourceMapper().getJclResourceId(String.valueOf(param.getEcManager())).intValue()) + .jclManager(param.getEcManager()) .ecRolelevel(param.getEcRolelevel()) - .jclRolelevel(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel())) : null) + .jclRolelevel(param.getEcRolelevel()) .manageModule("组织管理") .creator((long)user.getUID()) .deleteType(0) @@ -141,9 +140,9 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe ManagerDetachPO managerDetachPO = ManagerDetachPO.builder() .id(param.getId()) .ecManager(param.getEcManager()) - .jclManager(getHrmResourceMapper().getJclResourceId(String.valueOf(param.getEcManager())).intValue()) .ecRolelevel(param.getEcRolelevel()) - .jclRolelevel(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel())) : null) + .jclManager(param.getEcManager()) + .jclRolelevel(param.getEcRolelevel()) .build(); return getMangeDetachMapper().updateDetach(managerDetachPO); } @@ -177,12 +176,12 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe * @param uId * @return */ - public static List getJclRoleLevels(Integer uId) { - List ecRoleLevels = new ArrayList<>(); + public static List getJclRoleLevels(Integer uId) { + List ecRoleLevels = new ArrayList<>(); ManagerDetachMapper mangeDetachMapper = MapperProxyFactory.getProxy(ManagerDetachMapper.class); List detachListById = mangeDetachMapper.getDetachListById(uId); for (ManagerDetachPO managerDetachPO : detachListById) { - List ids = Stream.of(managerDetachPO.getJclRolelevel().split(",")).map(Long::parseLong).collect(Collectors.toList()); + List ids = Stream.of(managerDetachPO.getJclRolelevel().split(",")).map(Integer::parseInt).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(ids)) { ecRoleLevels.addAll(ids); } diff --git a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java index 0a39f75d..6f7d7e97 100644 --- a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java @@ -3,90 +3,128 @@ package com.engine.organization.service.impl; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; import com.engine.core.impl.Service; +import com.engine.organization.entity.chart.CompanyTreePO; +import com.engine.organization.entity.map.JclOrgMap; import com.engine.organization.entity.scheme.po.GradePO; import com.engine.organization.entity.scheme.po.LevelPO; +import com.engine.organization.mapper.jclorgmap.JclOrgMapper; import com.engine.organization.mapper.scheme.GradeMapper; import com.engine.organization.mapper.scheme.LevelMapper; import com.engine.organization.service.OrgChartService; import com.engine.organization.util.HasRightUtil; +import com.engine.organization.util.OrganizationDateUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; import org.apache.commons.lang3.StringUtils; +import tebie.applib.api.O; import weaver.conn.RecordSet; import weaver.general.Util; import weaver.hrm.User; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -/** - * @className: OrgChartServiceImpl - * @author: dengjp - * @date: 2022/7/7 - * @description: 组织架构图ServiceImpl - **/ + public class OrgChartServiceImpl extends Service implements OrgChartService { private RecordSet grs = new RecordSet(); private static final String COMPANY_RIGHT = "OrgChart:All"; private static final String USER_RIGHT = "OrgPerspective:All"; + private final String level = getFieldName("职等"); + private final String grade = getFieldName("职级"); @Override public Map getOptionCondition(Map request2Map, User user) { Map result = new HashMap<>(); RecordSet rs = new RecordSet(); - - rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id"); - List> fclasslist = new ArrayList<>(); Map defaultItem = new HashMap<>(); + rs.executeQuery("select companyname from hrmcompany"); + rs.next(); + int fkey = 0; + defaultItem.put("key", fkey++); defaultItem.put("id", "0"); - defaultItem.put("companyname", "行政维度"); + defaultItem.put("companyname", Util.null2String(rs.getString("companyname"))); + rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id"); + List> fclasslist = new ArrayList<>(); fclasslist.add(defaultItem); while (rs.next()) { Map item = new HashMap<>(); + item.put("key", fkey++); item.put("id", rs.getString("id")); item.put("companyname", rs.getString("companyname")); fclasslist.add(item); } - String sql = "select distinct id, fnumber, fname, ftype from jcl_org_map where ftype in (0, 1) order by ftype , id,fdateend desc "; + String sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype in (0, 1) "; // 分部分权过滤 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { String jclRoleLevels = detachUtil.getJclRoleLevels(); if (StringUtils.isNotBlank(jclRoleLevels)) { - sql = "select distinct id, fnumber, fname, ftype from jcl_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) order by ftype , id,fdateend desc"; + sql = "select id, fnumber, fname, ftype from jcl_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) "; } else { - sql = "select distinct id, fnumber, fname, ftype from jcl_org_map where ftype = 0 order by ftype , id,fdateend desc"; + sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype = 0 "; } } - rs.executeQuery(sql); + rs.executeQuery(sql + " and fdateend > " + DBType.get(new RecordSet().getDBType()).currentDate() + " order by ftype , id,fdateend desc "); Set companySet = new HashSet<>(); + int ckey = 0; while (rs.next()) { OrgSelectItem item = new OrgSelectItem(); + item.setKey(ckey++); item.setId(rs.getString("id")); item.setFnumber(rs.getString("fnumber")); item.setFname(rs.getString("fname")); companySet.add(item); } + + List companyTree = new ArrayList<>(); + sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '0'"; + rs.executeQuery(sql); + while (rs.next()) { + companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).build()); + } result.put("api_status", true); result.put("fclasslist", fclasslist); result.put("companylist", companySet); + result.put("companyTree", companyTree); + return result; + } + + @Override + public Map getSubCompanyTree(Map params) { + Map result = new HashMap<>(2); + + RecordSet rs = new RecordSet(); + List companyTree = new ArrayList<>(); + String subcompany = Util.null2String(params.get("subcompany")); + if (StringUtils.isBlank(subcompany)) { + subcompany = "0"; + } + String fclass = Util.null2String(params.get("fclass")); + String sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '" + subcompany + "'"; + if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) { + sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '" + subcompany + "' and companyid = '" + fclass + "'"; + } + rs.executeQuery(sql); + while (rs.next()) { + companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).build()); + } + result.put("companyTree", companyTree); return result; } private String companyDateWhereSql(Map request2Map) { - String date = (String) request2Map.get("date"); // 数据日期 + String date = (String) request2Map.get("date"); if (StringUtils.isBlank(date)) { date = DateUtil.format(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, 1), "yyyy-MM-dd"); } - - String fclass = (String) request2Map.get("fclass"); // 维度 - - - String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织 + String fclass = (String) request2Map.get("fclass"); + String fisvitual = (String) request2Map.get("fisvitual"); if (StringUtils.isBlank(fisvitual)) { fisvitual = "0"; } @@ -118,15 +156,15 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { return result; } - String root = (String) request2Map.get("root"); // 根节点 - String level = (String) request2Map.get("level"); // 显示层级 + String root = (String) request2Map.get("root"); + String level = (String) request2Map.get("level"); if (StringUtils.isBlank(level)) { level = "3"; } String whereSql = companyDateWhereSql(request2Map); String whereItemSql = " "; - if ("0".equals(root)) { // 集团的情况 + if ("0".equals(root)) { whereItemSql += " and ftype = 0 "; } else { whereItemSql += " and id = '" + root + "' "; @@ -134,7 +172,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { // 获取根节点 RecordSet rs = new RecordSet(); - rs.executeQuery("select id, fname, ftype, fparentid, fnumber, fobjid, fisvitual from jcl_org_map " + whereSql + whereItemSql); + String sql = "select id, fname, ftype, fparentid, fnumber, fobjid, fisvitual from jcl_org_map " + whereSql + whereItemSql; + rs.executeQuery(sql); List> list = new ArrayList<>(); String id = null; if (rs.next()) { @@ -165,7 +204,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { private void findCompanyItemByParantId(String id, int currentLevel, String level, RecordSet rs, List> list, String whereSql, boolean expand) { String sql = "select id, fname, ftype, fparentid,fobjid,fecid,fnumber,fisvitual from jcl_org_map " + whereSql; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if ("0".equals(id)) { sql += " and ftype = 1 and fobjid in(" + detachUtil.getJclRoleLevels() + ")"; @@ -205,14 +244,14 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { } private String userWhereSql(Map request2Map) { - String date = (String) request2Map.get("date"); // 数据日期 + String date = (String) request2Map.get("date"); if (StringUtils.isBlank(date)) { date = DateUtil.format(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, 1), "yyyy-MM-dd"); } - String fclass = (String) request2Map.get("fclass"); // 维度 + String fclass = (String) request2Map.get("fclass"); - String fisvitual = (String) request2Map.get("fisvitual"); // 是否显示虚拟组织 + String fisvitual = (String) request2Map.get("fisvitual"); if (StringUtils.isBlank(fisvitual)) { fisvitual = "0"; } @@ -241,8 +280,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { if (!hasRight) { return result; } - String root = (String) request2Map.get("root"); // 根节点 - String level = (String) request2Map.get("level"); // 显示层级 + String root = (String) request2Map.get("root"); + String level = (String) request2Map.get("level"); if (StringUtils.isBlank(level)) { level = "3"; } @@ -250,7 +289,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { String whereSql = userWhereSql(request2Map); String whereItemSql = " "; - if ("0".equals(root)) { // 集团的情况 + if ("0".equals(root)) { whereItemSql += " and t.ftype = 0 "; } else { whereItemSql += " and t.id = '" + root + "' "; @@ -319,16 +358,26 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { item.put("fname", rs.getString("fname")); item.put("ftype", rs.getString("ftype")); item.put("parentId", rs.getString("fparentid")); - item.put("fleadername", rs.getString("fleadername")); - item.put("fleaderimg", rs.getString("fleaderimg")); - item.put("fleaderjob", rs.getString("fleaderjob")); item.put("fplan", rs.getString("fplan")); item.put("fonjob", rs.getString("fonjob")); item.put("fnumber", rs.getString("fnumber")); item.put("hasChildren", hasChildren(rs.getString("id"), false)); - item.put("fleader", rs.getString("fleader")); - item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); - item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + if (rs.getString("ftype").equals("2")) { + JclOrgMap jclOrgMap = getBmfzrInfo(rs.getString("fleader")); + item.put("fleader", jclOrgMap.getFLeader() == null ? "" : String.valueOf(jclOrgMap.getFLeader())); + item.put("fleaderimg", jclOrgMap.getFLeaderImg()); + item.put("fleadername", jclOrgMap.getFLeaderName() == null ? "" : jclOrgMap.getFLeaderName()); + item.put("fleaderjob", jclOrgMap.getFLeaderJob()); + item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); + item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + } else { + item.put("fleader", rs.getString("fleader")); + item.put("fleaderimg", rs.getString("fleaderimg")); + item.put("fleadername", rs.getString("fleadername")); + item.put("fleaderjob", rs.getString("fleaderjob")); + item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); + item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + } item.put("fobjid", rs.getString("fobjid")); item.put("fisvitual", rs.getString("fisvitual")); currentList.add(item); @@ -370,10 +419,22 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { return result; } + //处理多个部门负责人 + private JclOrgMap getBmfzrInfo(String bmfzr) { + JclOrgMap jclOrgMap = new JclOrgMap(); + if (StringUtils.isNotBlank(bmfzr)) { + String[] split = bmfzr.split(","); + for (String s : split) { + jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getResInfo(level, grade, s); + break; + } + } + return jclOrgMap; + } private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List> list, String whereSql, boolean expand) { String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from jcl_org_map t " + whereSql; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if ("0".equals(id)) { sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getJclRoleLevels() + ")"; @@ -392,18 +453,28 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { item.put("ftype", rs.getString("ftype")); item.put("parentId", rs.getString("fparentid")); item.put("fobjparentId", rs.getString("fobjparentid")); - item.put("fleadername", rs.getString("fleadername")); - item.put("fleaderimg", rs.getString("fleaderimg")); - item.put("fleaderjob", rs.getString("fleaderjob")); item.put("fplan", rs.getString("fplan")); item.put("fonjob", rs.getString("fonjob")); item.put("fnumber", rs.getString("fnumber")); item.put("expand", expand ? "1" : "0"); item.put("fobjid", rs.getString("fobjid")); item.put("fecid", rs.getString("fecid")); - item.put("fleader", rs.getString("fleader")); - item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); - item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + if (rs.getString("ftype").equals("2")) { + JclOrgMap jclOrgMap = getBmfzrInfo(rs.getString("fleader")); + item.put("fleader", jclOrgMap.getFLeader() == null ? "" : String.valueOf(jclOrgMap.getFLeader())); + item.put("fleaderimg", jclOrgMap.getFLeaderImg()); + item.put("fleadername", jclOrgMap.getFLeaderName() == null ? "" : jclOrgMap.getFLeaderName()); + item.put("fleaderjob", jclOrgMap.getFLeaderJob()); + item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); + item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + } else { + item.put("fleader", rs.getString("fleader")); + item.put("fleaderimg", rs.getString("fleaderimg")); + item.put("fleadername", rs.getString("fleadername")); + item.put("fleaderjob", rs.getString("fleaderjob")); + item.put("fleaderlv", convertLevel(rs.getString("fleaderlv"))); + item.put("fleaderst", convertGrade(rs.getString("fleaderst"))); + } item.put("fisvitual", rs.getString("fisvitual")); item.put("hasChildren", hasChildren(rs.getString("id"), false)); currentList.add(item); @@ -497,11 +568,118 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { }); } + private JclOrgMapper getJclOrgMapMapper() { + return MapperProxyFactory.getProxy(JclOrgMapper.class); + } + + @Override + public String synchronousData(Map request2Map, User user) { + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()); + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + Calendar calendar = weaver.common.DateUtil.addDay(cal, -1); + java.sql.Date time = new java.sql.Date(calendar.getTime().getTime()); + // 自下向上刷新 + getJclOrgMapMapper().deleteAllMap(date); + getJclOrgMapMapper().updateAllMap(date, time); + //同步人员信息 + getJclOrgMapMapper().insertResToMap(level, grade); + //同步岗位信息 + getJclOrgMapMapper().insertJobToMap(); + //同步部门信息 + getJclOrgMapMapper().insertDeptToMap(level, grade); + //同步分部信息 + getJclOrgMapMapper().insertSubComToMap(); + //同步集团信息 + getJclOrgMapMapper().insertComToMap(); + //清除部门合并、转移造成的脏数据 + getJclOrgMapMapper().deleteJobNull(date); + //刷新在岗数、编制数(从岗位向上刷,岗位不需处理) + List jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType("3", date); + for (JclOrgMap jclOrgMap : jclOrgMaps) { + int id = jclOrgMap.getId(); + countJobAndPlans("3", id, currentDate); + } + return "同步成功"; + } + + @Override + public void insertChartVersion(Integer fclass, String description) { + RecordSet rs = new RecordSet(); + String recordDate = OrganizationDateUtil.getFormatLocalDateTime(LocalDateTime.now()); + String createDate = OrganizationDateUtil.getFormatLocalDate(LocalDate.now()); + rs.executeQuery("select id from JCL_ORG_CHARTVERSION where fclass = ? and createdate = ?",fclass,createDate); + rs.next(); + String id = Util.null2String(rs.getString("id")); + if(StringUtils.isNotEmpty(id)){ + rs.executeUpdate("update JCL_ORG_CHARTVERSION set recorddate = ?,description = ?,creator = ? where fclass = ? and createdate = ?",recordDate,description,user.getUID(),fclass,createDate); + }else { + rs.executeUpdate("insert into JCL_ORG_CHARTVERSION (recorddate,description,creator,deletetype,createdate,fclass) values(?,?,?,?,?,?)",recordDate,description,user.getUID(),0,createDate,fclass); + } + + } + + /** + * 刷新在岗、编制数 + */ + void countJobAndPlans(String type, int id, String currentDate) { + java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()); + RecordSet rs = new RecordSet(); + //处理上级 + String sql = "select fparentid from jcl_org_map where ftype=" + type + " and id=" + id + " "; + String whereSql = ""; + if (DBType.isOracle()) { + whereSql += " and ((fdatebegin <= to_date('" + currentDate + "','yyyy-MM-DD') and fdateend >= to_date('" + currentDate + "','yyyy-MM-DD')) or (fdatebegin <= to_date('" + currentDate + "','yyyy-MM-DD') and fdateend is null )) "; + } else { + whereSql += " and ((fdatebegin <= '" + currentDate + "' and fdateend >= '" + currentDate + "') or (fdatebegin <= '" + currentDate + "' and fdateend is null )) "; + } + + rs.executeQuery(sql + whereSql); + String fparentid = null; + String ftype = null; + if (rs.next()) { + fparentid = rs.getString("fparentid"); + String typeSql = "select ftype from jcl_org_map where id=" + fparentid + whereSql; + rs.executeQuery(typeSql + whereSql); + if (rs.next()) { + ftype = rs.getString("ftype"); + } + } + JclOrgMap jclOrgMap = getJclOrgMapMapper().getSumPlanAndJobByFParentId(date, fparentid); + if (fparentid != null) { + getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), date); + if (!"-1".equals(fparentid)) { + countJobAndPlans(ftype, Integer.parseInt(fparentid), String.valueOf(currentDate)); + } + } + + } + + private String getFieldName(String fieldabel) { + RecordSet recordSet = new RecordSet(); + String fieldname = null; + recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel + "'"); + if (recordSet.next()) { + fieldname = recordSet.getString("fieldname"); + } + return fieldname; + } + static class OrgSelectItem { + private Integer key; private String id; private String fnumber; private String fname; + public Integer getKey() { + return key; + } + + public void setKey(Integer key) { + this.key = key; + } + public String getId() { return id; } diff --git a/src/com/engine/organization/service/impl/OrgVirtualServiceImpl.java b/src/com/engine/organization/service/impl/OrgVirtualServiceImpl.java new file mode 100644 index 00000000..9cdbfa1c --- /dev/null +++ b/src/com/engine/organization/service/impl/OrgVirtualServiceImpl.java @@ -0,0 +1,20 @@ +package com.engine.organization.service.impl; + +import com.engine.core.impl.Service; +import com.engine.organization.service.OrgVirtualService; + +import java.util.Map; + +/** + * @Author liang.cheng + * @Date 2023/6/27 3:45 PM + * @Description: TODO + * @Version 1.0 + */ +public class OrgVirtualServiceImpl extends Service implements OrgVirtualService { + + @Override + public Map listPage(Map params) { + return null; + } +} diff --git a/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java b/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java new file mode 100644 index 00000000..4a271a4e --- /dev/null +++ b/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java @@ -0,0 +1,762 @@ +package com.engine.organization.service.impl; + +import com.api.browser.bean.SearchConditionItem; +import com.engine.core.impl.Service; +import com.engine.organization.entity.DeleteParam; +import com.engine.organization.entity.company.bo.CompBO; +import com.engine.organization.entity.company.po.CompPO; +import com.engine.organization.entity.department.bo.DepartmentBO; +import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.hrmresource.bo.ResourceBO; +import com.engine.organization.entity.hrmresource.po.ResourcePO; +import com.engine.organization.entity.job.bo.JobBO; +import com.engine.organization.entity.job.po.JobPO; +import com.engine.organization.entity.resume.po.HrmFamilyInfoPO; +import com.engine.organization.entity.resume.po.PersonnelResumeColumn; +import com.engine.organization.entity.resume.po.PersonnelResumePO; +import com.engine.organization.entity.resume.po.PersonnelResumeTable; +import com.engine.organization.entity.searchtree.SearchTree; +import com.engine.organization.entity.searchtree.SearchTreeParams; +import com.engine.organization.enums.ModuleTypeEnum; +import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.job.JobMapper; +import com.engine.organization.mapper.resource.HrmResourceMapper; +import com.engine.organization.service.PersonnelResumeService; +import com.engine.organization.util.MenuBtn; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.OrganizationFormItemUtil; +import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.detach.DetachUtil; +import com.engine.organization.util.page.PageUtil; +import com.engine.organization.util.tree.SearchTreeUtil; +import com.engine.organization.util.word.CustomXWPFDocument; +import com.engine.organization.util.word.WordUtil; +import org.apache.commons.collections.CollectionUtils; +import org.apache.poi.xwpf.usermodel.Document; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFPictureData; +import org.apache.xmlbeans.XmlOptions; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; +import weaver.general.GCONST; +import weaver.general.StringUtil; +import weaver.general.Util; + + +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +public class PersonnelResumeServiceImpl extends Service implements PersonnelResumeService { + + + private DepartmentMapper getDepartmentMapper() { + return MapperProxyFactory.getProxy(DepartmentMapper.class); + } + + private CompMapper getCompMapper() { + return MapperProxyFactory.getProxy(CompMapper.class); + } + + private JobMapper getJobMapper() { + return MapperProxyFactory.getProxy(JobMapper.class); + } + + private HrmResourceMapper getHrmResourceMapper() { + return MapperProxyFactory.getProxy(HrmResourceMapper.class); + } + + @Override + public Map getSearchTree(SearchTreeParams params) { + // 查询所有满足条件的人员ID、根据人员向上查找对应的组织架构 + List resourcePOList = null; + if (CollectionUtils.isNotEmpty(params.getSubcompanyid1()) || CollectionUtils.isNotEmpty(params.getDepartmentid()) || CollectionUtils.isNotEmpty(params.getJobId()) || CollectionUtils.isNotEmpty(params.getResourceId())) { + params.setPersonnelScreening(true); + // 人员筛选 + resourcePOList = getHrmResourceMapper().getPersonnelScreening(params.getSubcompanyid1(), params.getDepartmentid(), params.getJobId(), params.getResourceId()); + resourcePOList.removeIf(item->!item.getLastName().contains(params.getKeyword())); + } + List treeList = getFilterDatas(params, resourcePOList); + return SearchTreeUtil.getSearchTree(Util.null2String(params.getType()), treeList); + } + + @Override + public Map getResumeList(Integer uId) { + Map resultMap = new HashMap<>(); + // 根据ID查询用户信息 + PersonnelResumePO personnelResumePO = getHrmResourceMapper().getPersonnelResumeById(uId); + OrganizationAssert.notNull(personnelResumePO, "未找到对应人员"); + resultMap.put("lastName", Util.null2String(personnelResumePO.getLastName())); + resultMap.put("sex", Util.null2String(personnelResumePO.getSex())); + resultMap.put("birthday", Util.null2String(personnelResumePO.getBirthday())); + resultMap.put("image", Util.null2String(personnelResumePO.getImage())); + resultMap.put("native", Util.null2String(personnelResumePO.getNativePlace())); + resultMap.put("politics", Util.null2String(personnelResumePO.getPolitics())); + resultMap.put("department", Util.null2String(personnelResumePO.getDepartment())); + resultMap.put("marriage", Util.null2String(personnelResumePO.getMarriage())); + resultMap.put("jobtitle", Util.null2String(personnelResumePO.getJobTitle())); + resultMap.put("companystartdate", Util.null2String(personnelResumePO.getCompanyStartDate())); + resultMap.put("workstartdate", Util.null2String(personnelResumePO.getWorkStartDate())); + resultMap.put("idCard", Util.null2String(personnelResumePO.getIdCard())); + resultMap.put("address", Util.null2String(personnelResumePO.getAddress())); + resultMap.put("telephone", Util.null2String(personnelResumePO.getTelephone())); + resultMap.put("email", Util.null2String(personnelResumePO.getEmail())); + resultMap.put("selfStatement", ""); + + // 简历相关表格,待拓展 + resultMap.put("tables", getPersonnelResumeTable(uId)); + + return resultMap; + } + + @Override + public Map hasRight() { + Map resultMap = new HashMap<>(); + resultMap.put("hasRight", true); + ArrayList topMenuList = new ArrayList<>(); + ArrayList rightMenuList = new ArrayList<>(); + // 新增 + topMenuList.add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("screening").menuIcon("icon-coms-man").menuName("人员筛选").type("BTN_Screening").build()); + topMenuList.add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("currentExport").menuIcon("icon-coms-export").menuName("导出当前").type("BTN_CurrentExport").build()); + topMenuList.add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("mergeExport").menuIcon("icon-coms02-coms2-Batch-export").menuName("全部导出(合并)").type("BTN_MergeExport").build()); + topMenuList.add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("allExport").menuIcon("icon-coms02-coms2-export").menuName("全部导出").type("BTN_AllExport").build()); + + resultMap.put("topMenu", topMenuList); + // 新增 + rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("screening").menuIcon("icon-coms-man").menuName("人员筛选").type("BTN_Screening").build()); + rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("currentExport").menuIcon("icon-coms-export").menuName("导出当前").type("BTN_CurrentExport").build()); + rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("mergeExport").menuIcon("icon-coms02-coms2-Batch-export").menuName("全部导出(合并)").type("BTN_MergeExport").build()); + rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("allExport").menuIcon("icon-coms02-coms2-export").menuName("全部导出").type("BTN_AllExport").build()); + + resultMap.put("rightMenu", rightMenuList); + return resultMap; + } + + @Override + public String downloadPerResume(Integer type, HttpServletResponse response) throws Exception { + + //首先定义一个XWPFDocument 集合 这个对象可以进行word 解析 合并 还有下载都离不开这个对象 + List xwpfDocuments = new ArrayList<>(); + //模板地址 + String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "template" + File.separator; + String filePath = outPutPath + "PerResume.docx"; + //创建压缩包位置 + File fileZip = new File(outPutPath + "wordZip"); + if (!fileZip.exists()) { + fileZip.mkdirs(); + } + // 处理赋值的数据 + List> dataMapList = getAllResumeList(); +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); + String filesPath = outPutPath + "wordZip" + File.separator + "全部简历"; + String fileAllWordPath = outPutPath + "wordZip"; + String wordName = "全体人员简历(合并)"; + File files = new File(filesPath); + if (!files.exists()) { + files.mkdirs(); + } else { + delFolder(files.getPath()); + files.mkdirs(); + } + //处理所有数据 + for (int count = 0; count < dataMapList.size(); count++) { + //处理单人数据 + Map paramMap = dataMapList.get(count); + WordUtil wordUtil = new WordUtil(); + //返回一个新的xwpfDocument对象 + File file = new File(filePath); + CustomXWPFDocument doc = null; + InputStream is = new FileInputStream(file); + + doc = new CustomXWPFDocument(is); + wordUtil.replaceInPara(doc, paramMap); + wordUtil.replaceInTable(doc, paramMap); + xwpfDocuments.add(doc); + is.close(); + + String fileName = paramMap.get("${lastName}") + ".docx"; + System.out.println(fileName); + FileOutputStream os = null; + os = new FileOutputStream(filesPath + File.separator + new File(fileName)); + doc.write(os); + } + + if (xwpfDocuments.size() > 0) { + //这样第一步将所有word内容替换之后生成多个 xwpfDocument + //现在将多个xwpfDocument 进行合并 追加 生成word文件 + CustomXWPFDocument xwpfDocument = xwpfDocuments.get(0); + for (int i = 0; i < xwpfDocuments.size(); i++) { + //每次的追加为了避免样式和格式混乱 加上分页符 + //当是只有一条数据的时候 直接输出 + if (i == 0) { + xwpfDocument = xwpfDocuments.get(0); + xwpfDocument.write(new FileOutputStream(fileAllWordPath + File.separator + new File(wordName + ".docx"))); + continue; + } else { + //当存在多条时候 + xwpfDocument = mergeWord(xwpfDocument, xwpfDocuments.get(i)); + xwpfDocument.write(new FileOutputStream(fileAllWordPath + File.separator + new File(wordName + ".docx"))); + } + } + } + String resPath = fileAllWordPath + File.separator + new File(wordName + ".docx"); + if (type == 1) { + compressFileToZip(filesPath); + resPath = filesPath + ".zip"; + } + return resPath; + } + + // 简历相关表格,待拓展(数据先写死) + public List getPersonnelResumeTable(Integer uId){ + List tables = new ArrayList<>(); + List insurancesTitles = new ArrayList<>(); + List familyInfoTitles = new ArrayList<>(); + + List insuranceDatas = new ArrayList<>(); + List> datas = new ArrayList<>(); + insurancesTitles.add(PersonnelResumeColumn.builder().name("首次参保时间").colspans(2).rowspans(1).build()); + insurancesTitles.add(PersonnelResumeColumn.builder().name("养老保险").colspans(1).rowspans(1).build()); + insurancesTitles.add(PersonnelResumeColumn.builder().name("医疗保险").colspans(1).rowspans(1).build()); + insurancesTitles.add(PersonnelResumeColumn.builder().name("失业保险").colspans(1).rowspans(1).build()); + insurancesTitles.add(PersonnelResumeColumn.builder().name("住房公积金").colspans(1).rowspans(1).build()); + insurancesTitles.add(PersonnelResumeColumn.builder().name("企业年金").colspans(1).rowspans(1).build()); + + insuranceDatas.add(PersonnelResumeColumn.builder().value("2022-10-02").colspans(2).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("80").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("36").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("360").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("180").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("20000").colspans(1).rowspans(1).build()); + datas.add(insuranceDatas); + insuranceDatas = new ArrayList<>(); + insuranceDatas.add(PersonnelResumeColumn.builder().value("2022-11-02").colspans(2).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("90").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("46").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("361").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("181").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("20001").colspans(1).rowspans(1).build()); + datas.add(insuranceDatas); + insuranceDatas = new ArrayList<>(); + insuranceDatas.add(PersonnelResumeColumn.builder().value("2022-12-02").colspans(2).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("100").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("56").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("362").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("180").colspans(1).rowspans(1).build()); + insuranceDatas.add(PersonnelResumeColumn.builder().value("20000").colspans(1).rowspans(1).build()); + datas.add(insuranceDatas); + tables.add(PersonnelResumeTable.builder().title("二、社会保险及住房公积金缴纳情况(单位/元)").columns(insurancesTitles).datas(datas).build()); + + // 家庭情况 + familyInfoTitles.add(PersonnelResumeColumn.builder().name("关系").colspans(1).rowspans(1).build()); + familyInfoTitles.add(PersonnelResumeColumn.builder().name("姓名").colspans(1).rowspans(1).build()); + familyInfoTitles.add(PersonnelResumeColumn.builder().name("工作单位").colspans(2).rowspans(1).build()); + familyInfoTitles.add(PersonnelResumeColumn.builder().name("职务").colspans(1).rowspans(1).build()); + familyInfoTitles.add(PersonnelResumeColumn.builder().name("住址").colspans(2).rowspans(1).build()); + + + List hrmFamilyInfoByUser = getHrmResourceMapper().getHrmFamilyInfoByUser(uId); + if (CollectionUtils.isEmpty(hrmFamilyInfoByUser)) { + hrmFamilyInfoByUser.add(new HrmFamilyInfoPO()); + } + List> objects = new ArrayList<>(); + for (HrmFamilyInfoPO hrmFamilyInfoPO : hrmFamilyInfoByUser) { + List familyInfoDatas = new ArrayList<>(); + familyInfoDatas.add(PersonnelResumeColumn.builder().value(hrmFamilyInfoPO.getTitle()).colspans(1).rowspans(1).build()); + familyInfoDatas.add(PersonnelResumeColumn.builder().value(hrmFamilyInfoPO.getMember()).colspans(1).rowspans(1).build()); + familyInfoDatas.add(PersonnelResumeColumn.builder().value(hrmFamilyInfoPO.getCompany()).colspans(2).rowspans(1).build()); + familyInfoDatas.add(PersonnelResumeColumn.builder().value(hrmFamilyInfoPO.getJobTitle()).colspans(1).rowspans(1).build()); + familyInfoDatas.add(PersonnelResumeColumn.builder().value(hrmFamilyInfoPO.getAddress()).colspans(2).rowspans(1).build()); + objects.add(familyInfoDatas); + } + tables.add(PersonnelResumeTable.builder().title("三、家庭成员信息(包括父母、配偶、子女)").columns(familyInfoTitles).datas(objects).build()); + return tables; + } + + public List> getAllResumeList() { + List personnelResumeList = getHrmResourceMapper().getPersonnelResumeList(); + OrganizationAssert.notNull(personnelResumeList, "未找到对应人员"); + List> dataMapList = new ArrayList<>(); + for (PersonnelResumePO personnelResumePO : personnelResumeList) { + Map resultMap = new HashMap<>(); + resultMap.put("${lastName}", Util.null2String(personnelResumePO.getLastName())); + resultMap.put("${sex}", Util.null2String(personnelResumePO.getSex())); + resultMap.put("${birthday}", Util.null2String(personnelResumePO.getBirthday())); + resultMap.put("${@image}", Util.null2String(personnelResumePO.getImageId())); + resultMap.put("${native}", Util.null2String(personnelResumePO.getNativePlace())); + resultMap.put("${politics}", Util.null2String(personnelResumePO.getPolitics())); + resultMap.put("${department}", Util.null2String(personnelResumePO.getDepartment())); + resultMap.put("${marriage}", Util.null2String(personnelResumePO.getMarriage())); + resultMap.put("${jobtitle}", Util.null2String(personnelResumePO.getJobTitle())); + resultMap.put("${companystartdate}", Util.null2String(personnelResumePO.getCompanyStartDate())); + resultMap.put("${workstartdate}", Util.null2String(personnelResumePO.getWorkStartDate())); + resultMap.put("${idCard}", Util.null2String(personnelResumePO.getIdCard())); + resultMap.put("${address}", Util.null2String(personnelResumePO.getAddress())); + resultMap.put("${telephone}", Util.null2String(personnelResumePO.getTelephone())); + resultMap.put("${email}", Util.null2String(personnelResumePO.getEmail())); + resultMap.put("${selfStatement}", ""); + List tables = getPersonnelResumeTable(personnelResumePO.getId()); + for (int t = 0; t < tables.size(); t++) { + PersonnelResumeTable personnelResumeTable = tables.get(t); + int length = personnelResumeTable.getColumns().size(); + if (personnelResumeTable.getDatas().size() > 0) { + List> datas = personnelResumeTable.getDatas(); + if (datas.size() > 0) { + for (int d = 0;d dataList = datas.get(d); + for (int i = 0; i < length; i++) {//i表示列 + //社保9行开始,家庭成员10行开始 + int row = 100 + i + d; + resultMap.put("${c" + t + i + row + "}", Util.null2String(dataList.get(i).getValue())); + } + } + } + } + } + resultMap.put("sbDataCounts",tables.get(0).getDatas().size()); + resultMap.put("jtDataCounts",tables.get(1).getDatas().size()); + dataMapList.add(resultMap); + } + + return dataMapList; + } + + //两个对象进行追加 + public CustomXWPFDocument mergeWord(CustomXWPFDocument document, CustomXWPFDocument doucDocument2) throws Exception { + CustomXWPFDocument src1Document = document; + XWPFParagraph p = src1Document.createParagraph(); + //设置分页符 + p.setPageBreak(true); + CTBody src1Body = src1Document.getDocument().getBody(); + CustomXWPFDocument src2Document = doucDocument2; + CTBody src2Body = src2Document.getDocument().getBody(); + XWPFParagraph p2 = src2Document.createParagraph(); + + //处理合并后文档图片冲突 + List allPictures = src2Document.getAllPictures(); + Map map = new HashMap(); + for (XWPFPictureData picture : allPictures) { + String before = src2Document.getRelationId(picture); + //将原文档中的图片加入到目标文档中 + String after = src1Document.addPictureData(picture.getData(), Document.PICTURE_TYPE_JPEG); + map.put(before, after); + } + + XmlOptions optionsOuter = new XmlOptions(); + optionsOuter.setSaveOuter(); + String appendString = src2Body.xmlText(optionsOuter); + String srcString = src1Body.xmlText(); + String prefix = srcString.substring(0, srcString.indexOf(">") + 1); + String mainPart = srcString.substring(srcString.indexOf(">") + 1, srcString.lastIndexOf("<")); + String sufix = srcString.substring(srcString.lastIndexOf("<")); + String addPart = appendString.substring(appendString.indexOf(">") + 1, appendString.lastIndexOf("<")); + if (map != null && !map.isEmpty()) { + ListIterator> i = new ArrayList<>(map.entrySet()).listIterator(map.size()); + LinkedHashMap linkedHashMap = new LinkedHashMap(); + while (i.hasPrevious()) { + Map.Entry entry = i.previous(); + linkedHashMap.put(entry.getKey(), entry.getValue()); + } + Iterator it1 = linkedHashMap.entrySet().iterator(); + while (it1.hasNext()) { + Map.Entry entry = (Map.Entry) it1.next(); + addPart = addPart.replace(" personnelScreening() { + List items = new ArrayList<>(); + // 所属分部 + SearchConditionItem companyItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "分部", "194", "subcompanyid1", ""); + // 所属部门 + SearchConditionItem departmentItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门", "57", "departmentid", ""); + + SearchConditionItem jobItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "岗位", "666", "jobId", ""); + + SearchConditionItem resourceItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "人员", "17", "resourceId", ""); + items.add(companyItem); + items.add(departmentItem); + items.add(jobItem); + items.add(resourceItem); + return items; + } + + public List getFilterDatas(SearchTreeParams params, List resourcePOList) { + String keyword = params.getKeyword(); + String id = params.getId(); + String type = Util.null2String(params.getType()); + + List searchTree = new ArrayList<>(); + // 通过分部、公司 组装数据 + if (StringUtil.isEmpty(id) || ModuleTypeEnum.subcompanyfielddefined.getValue().toString().equals(type)) { + Integer subCompanyId1 = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); + if (params.isPersonnelScreening()) { + new DetachUtil(user).filterResourceList(resourcePOList); + if (null != subCompanyId1) { + resourcePOList.removeIf(item -> !subCompanyId1.equals(item.getSubcompanyid1())); + } + } + DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(subCompanyId1).canceled(0).build(); + CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(subCompanyId1).canceled(0).build(); + // 所属分部下的岗位 + JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecCompany(subCompanyId1).forbiddenTag(0).build(); + ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).subcompanyid1(subCompanyId1).build(); + searchTree = buildTreeByCompAndDept(params, resourcePOList, departmentBuild, compBuild, jobBuild, resourcePO); + } else if (ModuleTypeEnum.departmentfielddefined.getValue().toString().equals(type)) { + Integer departmentId = Integer.parseInt(id); + if (null != resourcePOList) { + new DetachUtil(user).filterResourceList(resourcePOList); + resourcePOList.removeIf(item -> !departmentId.equals(item.getDepartmentid())); + } + DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).supDepId(departmentId).canceled(0).build(); + // 所属分部下的岗位 + JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecDepartment(departmentId).forbiddenTag(0).build(); + ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).departmentid(departmentId).build(); + + searchTree = buildTreeByDeptAndJob(params, resourcePOList, departmentBuild, jobBuild, resourcePO); + + } else if (ModuleTypeEnum.jobfielddefined.getValue().toString().equals(type)) { + Long jobId = Long.parseLong(id); + JobPO jobById = getJobMapper().getJobById(jobId); + if (null != resourcePOList) { + new DetachUtil(user).filterResourceList(resourcePOList); + resourcePOList.removeIf(item -> !(jobById.getEcCompany().equals(item.getSubcompanyid1()) && jobById.getEcDepartment().equals(item.getDepartmentid())) && jobById.getEcJobTitle().equals(item.getJobtitle())); + return SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOList)); + } + ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).subcompanyid1(jobById.getEcCompany()).departmentid(jobById.getEcDepartment()).jobtitle(jobById.getEcJobTitle()).build(); + List resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + searchTree = SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOS)); + } + return searchTree; + } + + /** + * 分部、部门 组装左侧树 + * + * @param departmentBuild + * @param compBuild + * @param jobBuild + * @return + */ + private List buildTreeByCompAndDept(SearchTreeParams params, List resourcePOList, DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild, ResourcePO resourcePO) { + // 查询人员数据 + List resourcePOS; + if (params.isPersonnelScreening()) { + resourcePOS = resourcePOList; + } else { + resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + } + Set builderJobs = new HashSet<>(); + + // 补充人员所有岗位,关联人员及聚才林岗位 + for (ResourcePO resource : resourcePOS) { + JobPO jobByResource = getJobMapper().getJobByResource(resource); + if (null != jobByResource) { + resource.setJobId(jobByResource.getId()); + builderJobs.add(jobByResource); + } + } + List resourceTrees = SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOS)); + + + List jobPOS = getJobMapper().listPOsByFilter(jobBuild); + if (params.isPersonnelScreening()) { + jobPOS.removeIf(item -> !params.getJobId().contains(item.getId())); + } + + new DetachUtil(user).filterJobList(jobPOS); + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterDeparts.removeIf(item -> !params.getDepartmentid().contains(item.getId())); + } + new DetachUtil(user).filterDepartmentList(filterDeparts); + // 添加父级岗位 + builderJobs.addAll(jobPOS); + // 添加岗位的上级部门或分部 + List jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs), resourceTrees); + String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(",")); + if (!StringUtil.isEmpty(parentDeptS)) { + // 兼容SQLServer每次最多in,2100条数据 + List ids = DeleteParam.builder().ids(parentDeptS).build().getIds(); + int ceilCount = (int) Math.ceil((double) ids.size() / 1000); + List departmentsByIds = new ArrayList<>(); + for (int i = 1; i < ceilCount + 1; i++) { + List longs = PageUtil.subList(i, 1000, ids); + List departmentsById = getDepartmentMapper().getDeptsByIds(longs); + if (CollectionUtils.isNotEmpty(departmentsById)) { + departmentsByIds.addAll(departmentsById); + } + } + + if (CollectionUtils.isNotEmpty(departmentsByIds)) { + departmentsByIds.removeIf(item -> item.getCanceled() != null && item.getCanceled() != 0); + filterDeparts.addAll(departmentsByIds); + } + } + + // 查询分部信息 + List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterComps.removeIf(item -> !params.getSubcompanyid1().contains(item.getId())); + } + + new DetachUtil(user).filterCompanyList(filterComps); + Set builderDeparts = new HashSet<>(); + for (DepartmentPO departmentPO : filterDeparts) { + buildParentDepts(departmentPO, builderDeparts); + } + List departmentList = DepartmentBO.buildSetToSearchTree(builderDeparts); + List deptTrees = SearchTreeUtil.builderTreeMode(departmentList); + List searchTrees = SearchTreeUtil.builderTreeMode(departmentList, jobTrees); + // 添加部门的上级分部 + String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(",")); + if (!StringUtil.isEmpty(parentCompS)) { + List compsByIds = getCompMapper().getCompsByIds(DeleteParam.builder().ids(parentCompS).build().getIds()); + if (CollectionUtils.isNotEmpty(compsByIds)) { + filterComps.addAll(compsByIds); + } + } + List allCompanys = getCompMapper().listAll("showorder"); + new DetachUtil(user).filterCompanyList(allCompanys); + Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); + Set builderComps = new HashSet<>(); + for (CompPO compPO : filterComps) { + buildParentComps(compPO, builderComps, allMaps); + } + return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees); + } + + private List buildTreeByDeptAndJob(SearchTreeParams params, List resourcePOList, DepartmentPO departmentBuild, JobPO jobBuild, ResourcePO resourcePO) { + // 查询人员数据 + List resourcePOS; + if (params.isPersonnelScreening()) { + resourcePOS = resourcePOList; + } else { + resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + } + Set builderJobs = new HashSet<>(); + + // 补充人员所有岗位,关联人员及聚才林岗位 + for (ResourcePO resource : resourcePOS) { + JobPO jobByResource = getJobMapper().getJobByResource(resource); + if (null != jobByResource) { + resource.setJobId(jobByResource.getId()); + builderJobs.add(jobByResource); + } + } + List resourceTrees = SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOS)); + + List jobPOS = getJobMapper().listPOsByFilter(jobBuild); + if (params.isPersonnelScreening()) { + jobPOS.removeIf(item -> !params.getJobId().contains(item.getId())); + } + + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterDeparts.removeIf(item -> !params.getDepartmentid().contains(item.getId())); + } + // 添加父级岗位 + builderJobs.addAll(jobPOS); + // 添加岗位的上级部门或分部 + List jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs), resourceTrees); + String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(",")); + if (!StringUtil.isEmpty(parentDeptS)) { + // 兼容SQLServer每次最多in,2100条数据 + List ids = DeleteParam.builder().ids(parentDeptS).build().getIds(); + int ceilCount = (int) Math.ceil((double) ids.size() / 1000); + List departmentsByIds = new ArrayList<>(); + for (int i = 0; i < ceilCount - 1; i++) { + List departmentsById = getDepartmentMapper().getDeptsByIds(PageUtil.subList(i, 1000, ids)); + if (CollectionUtils.isNotEmpty(departmentsById)) { + departmentsByIds.addAll(departmentsById); + } + } + + if (CollectionUtils.isNotEmpty(departmentsByIds)) { + departmentsByIds.removeIf(item -> item.getCanceled() != null && item.getCanceled() != 0); + filterDeparts.addAll(departmentsByIds); + } + } + + // 查询分部信息 + Set builderDeparts = new HashSet<>(); + for (DepartmentPO departmentPO : filterDeparts) { + buildParentDepts(departmentPO, builderDeparts); + } + return SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts), jobTrees); + } + + + /** + * 添加查询元素的父级元素 + * + * @param departmentPO + * @param builderDeparts + */ + private void buildParentDepts(DepartmentPO departmentPO, Set builderDeparts) { + builderDeparts.add(departmentPO); + if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) { + return; + } + DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getSupDepId()); + if (null != parentDept) { + buildParentDepts(parentDept, builderDeparts); + } + } + + /** + * 添加查询元素的父级元素 + * + * @param compPO + * @param builderComps + */ + private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { + if (null != compPO.getCanceled() && 0 != compPO.getCanceled()) { + return; + } + builderComps.add(compPO); + CompPO parentComp = allMaps.get(compPO.getSupSubComId()); + if (null != parentComp) { + buildParentComps(parentComp, builderComps, allMaps); + } + } +} diff --git a/src/com/engine/organization/service/impl/PostInfoServiceImpl.java b/src/com/engine/organization/service/impl/PostInfoServiceImpl.java index 0fd60b62..604a2a8e 100644 --- a/src/com/engine/organization/service/impl/PostInfoServiceImpl.java +++ b/src/com/engine/organization/service/impl/PostInfoServiceImpl.java @@ -17,10 +17,17 @@ import com.engine.organization.service.PostInfoService; import com.engine.organization.util.*; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.excel.ExcelUtil; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.GCONST; import weaver.general.Util; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.*; @@ -41,6 +48,39 @@ public class PostInfoServiceImpl extends Service implements PostInfoService { private PostMapper getPostMapper() { return MapperProxyFactory.getProxy(PostMapper.class); } + // 判断编制导入模板是否存在,不存在则创建该文件 + static { + try { + String outPutPath = GCONST.getRootPath() + File.separator + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + "postinfo.xls"; + File excelPathFile = new File(outPutPath); + if (!excelPathFile.exists()) { + String columns = "编号,名称,职务分类,权限,责任,资格,描述说明"; + String[] split = columns.split(","); + List columnList = new ArrayList<>(Arrays.asList(split)); + // 创建导入模板 + List> excelSheetData = new ArrayList<>(); + excelSheetData.add(columnList); + XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, "postinfo"); + File excelFile = new File(outPutPath); + if (!excelFile.exists()) { + String substring = outPutPath.substring(0, outPutPath.lastIndexOf(File.separator)); + File file = new File(substring); + if (file.mkdirs()) { + boolean newFile = excelPathFile.createNewFile(); + if (!newFile) { + throw new IOException(outPutPath + "文件创建失败"); + } + } + } + FileOutputStream out = new FileOutputStream(excelPathFile); + sheets.write(out); + out.flush(); + } + } catch (IOException e) { + new BaseBean().writeLog(e); + throw new RuntimeException(e); + } + } @Override public Map listPage(Map params) { diff --git a/src/com/engine/organization/service/impl/PostServiceImpl.java b/src/com/engine/organization/service/impl/PostServiceImpl.java index 96671931..8b19fd67 100644 --- a/src/com/engine/organization/service/impl/PostServiceImpl.java +++ b/src/com/engine/organization/service/impl/PostServiceImpl.java @@ -34,8 +34,8 @@ public class PostServiceImpl extends Service implements PostService { @Override public int savePost(PostPO postPO) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - // List list = getPostMapper().listByNo(Util.null2String(postPO.getPostNo())); - // OrganizationAssert.isEmpty(list, "编号不允许重复"); + List list = getPostMapper().listByName(Util.null2String(postPO.getPostName())); + OrganizationAssert.isEmpty(list, "名称不允许重复"); return getPostMapper().insertIgnoreNull(PostDTO.convertPO(postPO, user.getUID())); } diff --git a/src/com/engine/organization/service/impl/StaffPlanServiceImpl.java b/src/com/engine/organization/service/impl/StaffPlanServiceImpl.java index 2775b5fe..0a4accc1 100644 --- a/src/com/engine/organization/service/impl/StaffPlanServiceImpl.java +++ b/src/com/engine/organization/service/impl/StaffPlanServiceImpl.java @@ -6,19 +6,16 @@ import com.api.browser.bean.SearchConditionOption; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; -import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.staff.bo.StaffPlanBO; import com.engine.organization.entity.staff.param.StaffPlanSearchParam; import com.engine.organization.entity.staff.po.StaffPlanPO; import com.engine.organization.entity.staff.vo.StaffPlanTableVO; -import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.staff.StaffPlanMapper; import com.engine.organization.service.StaffPlanService; import com.engine.organization.util.*; import com.engine.organization.util.browser.OrganizationBrowserUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.relation.EcHrmRelationUtil; import org.apache.commons.lang3.StringUtils; import weaver.common.DateUtil; import weaver.conn.RecordSet; @@ -40,11 +37,7 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService { private StaffPlanMapper getStaffPlanMapper() { return MapperProxyFactory.getProxy(StaffPlanMapper.class); } - - private CompMapper getCompMapper() { - return MapperProxyFactory.getProxy(CompMapper.class); - } - + @Override public Map listPage(StaffPlanSearchParam params) { Map resultMap = new HashMap<>(); @@ -74,7 +67,7 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService { // 结束时间大于开始时间 StaffPlanPO staffPlanPO = StaffPlanBO.convertParamToPO(param, (long) user.getUID()); // 多选赋值 - staffPlanPO.setCompanyId(getJclCompanyIdsByEcIds(staffPlanPO.getEcCompany())); + staffPlanPO.setCompanyId(staffPlanPO.getEcCompany()); String timeStart = param.getTimeStart(); String timeEnd = param.getTimeEnd(); Date startDate = DateUtil.parseToDate(timeStart); @@ -100,7 +93,7 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService { Date endDate = DateUtil.parseToDate(timeEnd); OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后"); // 多选赋值 - staffPlanPO.setCompanyId(getJclCompanyIdsByEcIds(staffPlanPO.getEcCompany())); + staffPlanPO.setCompanyId(staffPlanPO.getEcCompany()); return getStaffPlanMapper().updateStaffPlan(staffPlanPO); } @@ -285,18 +278,4 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService { } return sqlWhere; } - - private String getJclCompanyIdsByEcIds(String ecIds) { - List jclCompanyIds = new ArrayList<>(); - String[] split = ecIds.split(","); - for (String s : split) { - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(s); - if (null != jclCompanyId) { - jclCompanyIds.add(jclCompanyId.getId().toString()); - } - } - return StringUtils.join(jclCompanyIds, ","); - } - - } diff --git a/src/com/engine/organization/service/impl/StaffServiceImpl.java b/src/com/engine/organization/service/impl/StaffServiceImpl.java index 408ab7e1..4e31de95 100644 --- a/src/com/engine/organization/service/impl/StaffServiceImpl.java +++ b/src/com/engine/organization/service/impl/StaffServiceImpl.java @@ -10,28 +10,25 @@ import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.browser.po.CustomBrowserBean; -import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.staff.bo.StaffBO; import com.engine.organization.entity.staff.param.StaffSearchParam; import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.entity.staff.po.StaffPlanPO; import com.engine.organization.entity.staff.po.StaffsPO; import com.engine.organization.entity.staff.vo.StaffTableVO; -import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffPlanMapper; import com.engine.organization.mapper.staff.StaffsMapper; import com.engine.organization.service.StaffService; -import com.engine.organization.thread.StaffTriggerRunnable; import com.engine.organization.util.*; import com.engine.organization.util.browser.OrganizationBrowserUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.excel.ExcelUtil; -import com.engine.organization.util.relation.EcHrmRelationUtil; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.conn.RecordSet; @@ -63,18 +60,14 @@ public class StaffServiceImpl extends Service implements StaffService { return MapperProxyFactory.getProxy(StaffPlanMapper.class); } - private CompMapper getCompMapper() { - return MapperProxyFactory.getProxy(CompMapper.class); + private JobMapper getJobMapper() { + return MapperProxyFactory.getProxy(JobMapper.class); } private DepartmentMapper getDepartmentMapper() { return MapperProxyFactory.getProxy(DepartmentMapper.class); } - private JobMapper getJobMapper() { - return MapperProxyFactory.getProxy(JobMapper.class); - } - // 判断编制导入模板是否存在,不存在则创建该文件 static { try { @@ -135,19 +128,12 @@ public class StaffServiceImpl extends Service implements StaffService { HasRightUtil.hasRight(user, RIGHT_NAME, false); StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID()); OrganizationAssert.isFalse(staffPO.getStaffNum() < 0, "编制数不可小于0,请更正"); + checkRequired(staffPO); - // 赋值 - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(staffPO.getEcCompany())); - if (null != jclCompanyId) { - staffPO.setCompId(jclCompanyId.getId()); - } - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(staffPO.getEcDepartment())); - if (null != jclDepartmentId) { - staffPO.setDeptId(jclDepartmentId.getId()); - } + int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO); // 同步组织架构图编制信息 - new StaffTriggerRunnable(staffPO).run(); + //new StaffTriggerRunnable(staffPO).run(); return ignoreNull; } @@ -158,16 +144,9 @@ public class StaffServiceImpl extends Service implements StaffService { StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID()); staffPO.setPermanentNum(staffByID.getPermanentNum()); staffPO.setFreezeNum(staffByID.getFreezeNum()); + checkRequired(staffPO); - // 赋值 - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(staffPO.getEcCompany())); - if (null != jclCompanyId) { - staffPO.setCompId(jclCompanyId.getId()); - } - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(staffPO.getEcDepartment())); - if (null != jclDepartmentId) { - staffPO.setDeptId(jclDepartmentId.getId()); - } + Integer changeNum = param.getChangeNum(); if (null == changeNum) { // 插入明细表数据 @@ -186,7 +165,7 @@ public class StaffServiceImpl extends Service implements StaffService { // 更新主表 int updateStaff = getStaffMapper().updateStaff(staffPO); // 同步组织架构图编制信息 - new StaffTriggerRunnable(staffPO).run(); + //new StaffTriggerRunnable(staffPO).run(); return updateStaff; } @@ -197,9 +176,9 @@ public class StaffServiceImpl extends Service implements StaffService { OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); List staffsByIds = getStaffMapper().getStaffsByIds(ids); int deleteByIds = getStaffMapper().deleteByIds(ids); - for (StaffPO staffsById : staffsByIds) { - new StaffTriggerRunnable(staffsById).run(); - } + //for (StaffPO staffsById : staffsByIds) { + // new StaffTriggerRunnable(staffsById).run(); + //} return deleteByIds; } @@ -386,19 +365,19 @@ public class StaffServiceImpl extends Service implements StaffService { } else { sqlWhere = " where 1 = 2 "; } - Long compId = param.getCompId(); + Integer compId = param.getCompId(); if (null != compId) { sqlWhere += " AND t.comp_id = '" + compId + "'"; } - Long deptId = param.getDeptId(); + Integer deptId = param.getDeptId(); if (null != deptId) { sqlWhere += " AND t.dept_id = '" + deptId + "'"; } - Long ecCompany = param.getEcCompany(); + Integer ecCompany = param.getEcCompany(); if (null != ecCompany) { sqlWhere += " AND t.ec_company = '" + ecCompany + "'"; } - Long ecDepartment = param.getEcDepartment(); + Integer ecDepartment = param.getEcDepartment(); if (null != ecDepartment) { sqlWhere += " AND t.ec_department = '" + ecDepartment + "'"; } @@ -453,15 +432,26 @@ public class StaffServiceImpl extends Service implements StaffService { switch (staffPlanByID.getControlDimension()) { case "1":// 分部 OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择分部时,分部必填!"); + staffPO.setCompId(staffPO.getEcCompany()); break; case "2":// 部门 - OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择部门时,分部必填!"); OrganizationAssert.notNull(staffPO.getEcDepartment(), "编制维度选择部门时,部门必填!"); + DepartmentPO jclDepartmentId = getDepartmentMapper().getDeptById(staffPO.getEcDepartment()); + if (null != jclDepartmentId) { + staffPO.setDeptId(jclDepartmentId.getId()); + staffPO.setCompId(jclDepartmentId.getSubCompanyId1()); + staffPO.setEcCompany(jclDepartmentId.getSubCompanyId1()); + } break; case "3": // 岗位 - OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择岗位时,分部必填!"); - OrganizationAssert.notNull(staffPO.getEcDepartment(), "编制维度选择岗位时,部门必填!"); OrganizationAssert.notNull(staffPO.getJobId(), "编制维度选择岗位时,岗位必填!"); + JobPO jobById = getJobMapper().getJobById(staffPO.getJobId()); + if (null != jobById) { + staffPO.setDeptId(jobById.getEcDepartment()); + staffPO.setEcDepartment(jobById.getEcDepartment()); + staffPO.setCompId(jobById.getEcCompany()); + staffPO.setEcCompany(jobById.getEcCompany()); + } break; default: break; diff --git a/src/com/engine/organization/service/impl/VersionManageServiceImpl.java b/src/com/engine/organization/service/impl/VersionManageServiceImpl.java new file mode 100644 index 00000000..aef2652f --- /dev/null +++ b/src/com/engine/organization/service/impl/VersionManageServiceImpl.java @@ -0,0 +1,453 @@ +package com.engine.organization.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.engine.core.impl.Service; +import com.engine.organization.entity.hrmresource.po.HrmResourcePO; +import com.engine.organization.entity.map.JclOrgMap; +import com.engine.organization.entity.version.*; +import com.engine.organization.enums.ModuleTypeEnum; +import com.engine.organization.mapper.jclorgmap.JclOrgMapper; +import com.engine.organization.mapper.resource.ResourceMapper; +import com.engine.organization.mapper.version.CompanyVersionMapper; +import com.engine.organization.service.VersionManageService; +import com.engine.organization.util.OrganizationDateUtil; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import org.docx4j.wml.U; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; + +import java.sql.Date; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/8 + * @Version V1.0 + **/ +public class VersionManageServiceImpl extends Service implements VersionManageService { + + + private CompanyVersionMapper getCompanyVersionMapper() { + return MapperProxyFactory.getProxy(CompanyVersionMapper.class); + } + + private JclOrgMapper getJclOrgMapMapper() { + return MapperProxyFactory.getProxy(JclOrgMapper.class); + } + + @Override + public void save(ModuleTypeEnum moduleTypeEnum, Map params, User user) { + String id = (String) params.get("id"); + JSONObject paramMap = null; + + switch (moduleTypeEnum.getValue()) { + case 1: + HrmSubCompanyDto hrmSubComp = getCompanyVersionMapper().getHrmSubComp(id); + saveSubComToVersion(hrmSubComp, user); +// saveSubComToMap(paramMap); + break; + case 2: + HrmDepartmentDto hrmDepartmentDto = getCompanyVersionMapper().getHrmDepartment(id); + saveDeptToVersion(hrmDepartmentDto, user); +// saveDeptToMap(paramMap); + break; + case 4: + HrmResourceDto hrmResourceDto = getCompanyVersionMapper().getHrmResource(id); + saveHrmToVersion(hrmResourceDto, user); +// saveHrmToMap(paramMap); + break; + } + + } + + @Override + public Map getVersion(ModuleTypeEnum moduleTypeEnum, Map params, User user) { + String operateName = ""; + String id = (String) params.get("id"); + String version = (String) params.get("version"); + String operateTime = ""; + Map resultMap = new HashMap<>(); + List versions = new ArrayList<>(); + List datas = new ArrayList<>(); + switch (moduleTypeEnum.getValue()) { + case 1: + List list = getCompanyVersionMapper().getSubComVersionList(id, null); + + int size = list.size(); + if (size < 1) { + break; + } + for (HrmSubCompanyVersion hrmSubCompanyVersion : list) { + Map map = new HashMap<>(); + map.put("value", String.format("%.1f", hrmSubCompanyVersion.getVersion())); + versions.add(map); + } + if (version.equals("1.0")) { + version = "1"; + } + list = getCompanyVersionMapper().getSubComVersionList(id, version); + for (HrmSubCompanyVersion hrmSubCompanyVersion : list) { + datas.add(VersionData.builder().fieldId("分部简称").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyName())).build()); + datas.add(VersionData.builder().fieldId("分部全称").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyDesc())).build()); + datas.add(VersionData.builder().fieldId("上级分部").fieldValue(Util.null2String(hrmSubCompanyVersion.getSupSubComName())).build()); + datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmSubCompanyVersion.getVersion()))).build()); + datas.add(VersionData.builder().fieldId("分部编号").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyCode())).build()); + datas.add(VersionData.builder().fieldId("排序").fieldValue(Util.null2String(hrmSubCompanyVersion.getShowOrder())).build()); + operateName = hrmSubCompanyVersion.getOperator(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + operateTime = sdf.format(hrmSubCompanyVersion.getOperateTime()); + } + break; + case 2: + List deptVersionList = getCompanyVersionMapper().getDeptVersionList(id, null); + int deptSize = deptVersionList.size(); + if (deptSize < 1) { + break; + } + for (HrmDepartmentVersion hrmDepartmentVersion : deptVersionList) { + Map map = new HashMap<>(); + map.put("value", String.format("%.1f", hrmDepartmentVersion.getVersion())); + versions.add(map); + } + if (version.equals("1.0")) { + version = "1"; + } + deptVersionList = getCompanyVersionMapper().getDeptVersionList(id, version); + for (HrmDepartmentVersion hrmDepartmentVersion : deptVersionList) { + datas.add(VersionData.builder().fieldId("部门编号").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentCode())).build()); + datas.add(VersionData.builder().fieldId("部门简称").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentName())).build()); + datas.add(VersionData.builder().fieldId("部门全称").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentMark())).build()); + datas.add(VersionData.builder().fieldId("所属分部").fieldValue(Util.null2String(hrmDepartmentVersion.getSubcompanyname())).build()); + datas.add(VersionData.builder().fieldId("上级部门").fieldValue(Util.null2String(hrmDepartmentVersion.getSupDepName())).build()); + datas.add(VersionData.builder().fieldId("部门负责人").fieldValue(Util.null2String(hrmDepartmentVersion.getBmfzrName())).build()); + datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmDepartmentVersion.getVersion()))).build()); + datas.add(VersionData.builder().fieldId("排序").fieldValue(Util.null2String(hrmDepartmentVersion.getShowOrder())).build()); + operateName = hrmDepartmentVersion.getOperator(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + operateTime = sdf.format(hrmDepartmentVersion.getOperateTime()); + } + break; + case 4: + List resVersionList = getCompanyVersionMapper().getResourceVersionList(id, null); + int resSize = resVersionList.size(); + if (resSize < 1) { + break; + } + for (HrmResourceVersion hrmResourceVersion : resVersionList) { + Map map = new HashMap<>(); + map.put("value", String.format("%.1f", hrmResourceVersion.getVersion())); + versions.add(map); + } + if (version.equals("1.0")) { + version = "1"; + } + resVersionList = getCompanyVersionMapper().getResourceVersionList(id, version); + for (HrmResourceVersion hrmResourceVersion : resVersionList) { + datas.add(VersionData.builder().fieldId("姓名").fieldValue(Util.null2String(hrmResourceVersion.getLastname())).build()); + datas.add(VersionData.builder().fieldId("部门").fieldValue(Util.null2String(hrmResourceVersion.getDepartmentname())).build()); + datas.add(VersionData.builder().fieldId("岗位").fieldValue(Util.null2String(hrmResourceVersion.getJobtitlename())).build()); + datas.add(VersionData.builder().fieldId("分部").fieldValue(Util.null2String(hrmResourceVersion.getSubcompanyname())).build()); + datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmResourceVersion.getVersion()))).build()); + operateName = hrmResourceVersion.getOperator(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + operateTime = sdf.format(hrmResourceVersion.getOperateTime()); + } + break; + default: + break; + } + + resultMap.put("operateName", operateName); + resultMap.put("operateTime", operateTime); + resultMap.put("versions", versions); + resultMap.put("datas", datas); + if (versions.size() < 1) { + return null; + } + return resultMap; + } + + /** + * 分部保存至map表 + */ + void saveSubComToMap(JSONObject params) { + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + String id = params.getString("id"); + + JclOrgMap jclOrgMap = new JclOrgMap(); + jclOrgMap.setId(Integer.parseInt(id)); + jclOrgMap.setFType(1); + jclOrgMap.setFObjId(Integer.parseInt(id)); + jclOrgMap.setFClass(0); + jclOrgMap.setFClassName("行政维度"); + jclOrgMap.setFName(params.getString("subcompanyname")); + String supSubComId = params.getString("supsubcomid"); + jclOrgMap.setFParentId(StringUtils.isNotBlank(supSubComId) ? Integer.parseInt(supSubComId) : null); + jclOrgMap.setFIsVitual(0); + jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime())); + + JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), Util.null2String(jclOrgMap.getId())); + if (jclOrgMapByFParentId != null) { + jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan()); + jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob()); + } else { + jclOrgMap.setFPlan(0); + jclOrgMap.setFOnJob(0); + } + + Calendar cal = Calendar.getInstance(); + cal.setTime(jclOrgMap.getFDateBegin()); + Calendar calendar = DateUtil.addDay(cal, -1); + Date time = new Date(calendar.getTime().getTime()); + + getJclOrgMapMapper().deleteMap("1", id, jclOrgMap.getFDateBegin()); + getJclOrgMapMapper().updateMap("1", id, jclOrgMap.getFDateBegin(), time); + if (!params.getString("canceled").equals("1")) { + getJclOrgMapMapper().insertMap(jclOrgMap); + } + } + + /** + * 部门保存到map表 + */ + void saveDeptToMap(JSONObject params) { + String id = params.getString("id"); + int st = 100000000; + + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + + JclOrgMap jclOrgMap = new JclOrgMap(); + jclOrgMap.setId(st + Integer.parseInt(id)); + jclOrgMap.setFType(2); + jclOrgMap.setFObjId(Integer.parseInt(id)); + jclOrgMap.setFClass(0); + jclOrgMap.setFClassName("行政维度"); + String bmfzr = params.getString("bmfzr"); + if (StringUtils.isNotBlank(bmfzr)) { + jclOrgMap.setFLeader(Integer.parseInt(bmfzr)); + HrmResourcePO hrmResourcePO = MapperProxyFactory.getProxy(ResourceMapper.class).getResourceById(bmfzr); + jclOrgMap.setFLeaderImg(hrmResourcePO.getResourceImageId()); + jclOrgMap.setFLeaderName(hrmResourcePO.getLastName()); + jclOrgMap.setFLeaderJobId(Math.toIntExact(hrmResourcePO.getJobTitle())); + } + jclOrgMap.setFName(params.getString("departmentname")); + String subCompanyId1 = params.getString("subcompanyid1"); + String supdepid = params.getString("supdepid"); + if (supdepid != null) { + jclOrgMap.setFParentId(st + Integer.parseInt(supdepid)); + } + if ("0".equals(supdepid)) { + jclOrgMap.setFParentId(Integer.parseInt(subCompanyId1)); + } + jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime())); + jclOrgMap.setFIsVitual(0); + + JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), String.valueOf(jclOrgMap.getId())); + if (null != jclOrgMapByFParentId) { + jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan()); + jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob()); + } else { + jclOrgMap.setFPlan(0); + jclOrgMap.setFOnJob(0); + } + Calendar cal = Calendar.getInstance(); + cal.setTime(jclOrgMap.getFDateBegin()); + Calendar calendar = DateUtil.addDay(cal, -1); + Date time = new Date(calendar.getTime().getTime()); + + getJclOrgMapMapper().deleteMap("2", id, jclOrgMap.getFDateBegin()); + getJclOrgMapMapper().updateMap("2", id, jclOrgMap.getFDateBegin(), time); + if (!params.getString("canceled").equals("1")) { + getJclOrgMapMapper().insertMap(jclOrgMap); + } + } + + + /** + * 人员保存至map + */ + void saveHrmToMap(JSONObject params) { + String id = params.getString("id"); + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + int sk = 300000000; + RecordSet rs = new RecordSet(); + + JclOrgMap jclOrgMap = new JclOrgMap(); + jclOrgMap.setId(sk + Integer.parseInt(id)); + jclOrgMap.setFType(4); + jclOrgMap.setFObjId(Integer.parseInt(id)); + jclOrgMap.setFClass(0); + jclOrgMap.setFClassName("行政维度"); + jclOrgMap.setFName(params.getString("lastname")); + if (StringUtils.isNotBlank(id)) { + rs.executeQuery("select messagerurl, lastname, jobtitle from hrmresource where id=" + id + ";"); + if (rs.next()) { + jclOrgMap.setFLeaderImg(Util.null2String(rs.getString("messagerurl"))); + jclOrgMap.setFLeaderName(Util.null2String(rs.getString("lastname"))); + jclOrgMap.setFLeaderJobId(Integer.valueOf(rs.getString("jobtitle"))); + } + } + String jobtitle = params.getString("jobtitle"); + jclOrgMap.setFParentId(StringUtils.isNotBlank(jobtitle) ? sk + Integer.parseInt(jobtitle) : null); + + jclOrgMap.setFPlan(0); + jclOrgMap.setFOnJob(0); + jclOrgMap.setFIsVitual(0); + jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime())); + + Calendar cal = Calendar.getInstance(); + cal.setTime(jclOrgMap.getFDateBegin()); + Calendar calendar = DateUtil.addDay(cal, -1); + Date time = new Date(calendar.getTime().getTime()); + + getJclOrgMapMapper().deleteMap("4", id, jclOrgMap.getFDateBegin()); + getJclOrgMapMapper().updateMap("4", id, jclOrgMap.getFDateBegin(), time); + + if (!params.getString("canceled").equals("1")) { + getJclOrgMapMapper().insertMap(jclOrgMap); + } + + } + + + /** + * 分部保存至版本表 + */ + void saveSubComToVersion(HrmSubCompanyDto hrmSubComp, User user) { + String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date()); + int id = hrmSubComp.getId(); + HrmSubCompanyVersion hrmSubCompanyVersion = new HrmSubCompanyVersion(); + hrmSubCompanyVersion.setSubComId(id); + hrmSubCompanyVersion.setSubCompanyDesc(hrmSubComp.getSubcompanydesc()); + hrmSubCompanyVersion.setSubCompanyCode(hrmSubComp.getSubcompanycode()); + hrmSubCompanyVersion.setSubCompanyName(hrmSubComp.getSubcompanyname()); + String supSubComId = hrmSubComp.getSupsubcomid(); + hrmSubCompanyVersion.setSupSubComId(StringUtils.isNotBlank(supSubComId) ? Integer.parseInt(supSubComId) : null); + String showOrder = hrmSubComp.getShoworder(); + if (showOrder != null && !showOrder.equals("0")) { + int length = showOrder.indexOf("."); + if (length>0){ + showOrder = showOrder.substring(0, length); + } + } + hrmSubCompanyVersion.setShowOrder(null == showOrder ? null : Integer.parseInt(showOrder)); + String canceled = hrmSubComp.getCanceled(); + ; + hrmSubCompanyVersion.setCanceled(StringUtils.isNotBlank(canceled) ? Integer.parseInt(canceled) : null); + hrmSubCompanyVersion.setDescription(null); + hrmSubCompanyVersion.setOperator(user.getUsername()); + hrmSubCompanyVersion.setVersion(genVersionId(1, Util.null2String(id))); + hrmSubCompanyVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime())); + getCompanyVersionMapper().insertHrmSubComVersion(hrmSubCompanyVersion); + } + + /** + * 部门保存至版本 + */ + void saveDeptToVersion(HrmDepartmentDto hrmDepartmentDto, User user) { + int id = hrmDepartmentDto.getId(); + String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date()); + + HrmDepartmentVersion hrmDepartmentVersion = new HrmDepartmentVersion(); + hrmDepartmentVersion.setDepartmentId(id); + hrmDepartmentVersion.setDepartmentMark(hrmDepartmentDto.getDepartmentmark()); + hrmDepartmentVersion.setDepartmentCode(hrmDepartmentDto.getDepartmentcode()); + hrmDepartmentVersion.setDepartmentName(hrmDepartmentDto.getDepartmentname()); + String subCompanyId1 = hrmDepartmentDto.getSubcompanyid1(); + hrmDepartmentVersion.setSubCompanyId1(StringUtils.isNotBlank(subCompanyId1) ? Integer.parseInt(subCompanyId1) : null); + String supDepId = hrmDepartmentDto.getSupdepid(); + if (supDepId != null) { + hrmDepartmentVersion.setSupDepId(Integer.parseInt(supDepId)); + } + String bmfzr = hrmDepartmentDto.getBmfzr(); + if (!"".equals(bmfzr) && bmfzr != null) { + hrmDepartmentVersion.setBmfzr(bmfzr); + } + String showOrder = hrmDepartmentDto.getShoworder(); + if (showOrder != null && !showOrder.equals("0")) { + int length = showOrder.indexOf("."); + if (length>0){ + showOrder = showOrder.substring(0, length); + } + } + hrmDepartmentVersion.setShowOrder(null == showOrder ? null : Integer.parseInt(showOrder)); + String canceled = hrmDepartmentDto.getCanceled(); + hrmDepartmentVersion.setCanceled(StringUtils.isNotBlank(canceled) ? Integer.parseInt(canceled) : null); + hrmDepartmentVersion.setDescription(null); + hrmDepartmentVersion.setOperator(user.getLastname()); + hrmDepartmentVersion.setVersion(genVersionId(2, Util.null2String(id))); + hrmDepartmentVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime())); + + getCompanyVersionMapper().insertHrmDeptVersion(hrmDepartmentVersion); + } + + /** + * 人员保存至版本 + */ + void saveHrmToVersion(HrmResourceDto hrmResourceDto, User user) { + Integer id = hrmResourceDto.getId(); + String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date()); + + HrmResourceVersion hrmResourceVersion = new HrmResourceVersion(); + hrmResourceVersion.setResourceid(id); +/* hrmResourceVersion.setCompanystartdate(new Date(OrganizationDateUtil.stringToDate((String) params.get("companystartdate")).getTime())); + hrmResourceVersion.setCompanyworkyear(Integer.parseInt((String) params.get("companyworkyear"))); + hrmResourceVersion.setWorkstartdate(new Date(OrganizationDateUtil.stringToDate((String) params.get("workstartdate")).getTime()));*/ + + hrmResourceVersion.setDepartmentid(hrmResourceDto.getDepartmentid()); + hrmResourceVersion.setDsporder(Double.valueOf(hrmResourceDto.getDsporder()).intValue()); + hrmResourceVersion.setSubcompanyid1(hrmResourceDto.getSubcompanyid1()); + hrmResourceVersion.setJobtitle(hrmResourceDto.getJobtitle()); + hrmResourceVersion.setMobile(hrmResourceDto.getMobile()); + hrmResourceVersion.setTelephone(hrmResourceDto.getTelephone()); + String managerid = hrmResourceDto.getManagerid(); + hrmResourceVersion.setManagerid(StringUtils.isNotBlank(managerid) ? Integer.parseInt(managerid) : null); + hrmResourceVersion.setLastname(hrmResourceDto.getLastname()); + hrmResourceVersion.setOperator(user.getLastname()); + hrmResourceVersion.setVersion(genVersionId(4, String.valueOf(id))); + hrmResourceVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime())); + + getCompanyVersionMapper().insertHrmResourceVersion(hrmResourceVersion); + + } + + /** + * 版本号生成 + */ + private Double genVersionId(int fType, String sid) { + // 版本V1.0 + 0.1 (默认字段) + double id = 1.0; + switch (fType) { + case 1: + HrmSubCompanyVersion hrmSubCompanyVersion = getCompanyVersionMapper().getMaxVersion(sid); + if (null != hrmSubCompanyVersion) { + id = 0.1 + hrmSubCompanyVersion.getVersion(); + } + break; + case 2: + HrmDepartmentVersion hrmDepartmentVersion = getCompanyVersionMapper().getMaxDeptVersion(sid); + if (null != hrmDepartmentVersion) { + id = 0.1 + hrmDepartmentVersion.getVersion(); + } + break; + case 4: + HrmResourceVersion hrmResourceVersion = getCompanyVersionMapper().getMaxHrmVersion(sid); + if (null != hrmResourceVersion) { + id = 0.1 + hrmResourceVersion.getVersion(); + } + break; + } + return id; + } + + +} diff --git a/src/com/engine/organization/thread/CompanyTriggerRunnable.java b/src/com/engine/organization/thread/CompanyTriggerRunnable.java index 278ba515..5c094f08 100644 --- a/src/com/engine/organization/thread/CompanyTriggerRunnable.java +++ b/src/com/engine/organization/thread/CompanyTriggerRunnable.java @@ -1,159 +1,140 @@ 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 * @createTime: 2022/08/30 * @version: 1.0 */ -public class CompanyTriggerRunnable implements Runnable { - - private final CompPO oldCompany; - private final CompPO newCompany; - - private CompTriggerMapper getCompTriggerMapper() { - return MapperProxyFactory.getProxy(CompTriggerMapper.class); - } - - public CompanyTriggerRunnable(CompPO oldCompany, CompPO newCompany) { - this.oldCompany = oldCompany; - this.newCompany = newCompany; - } - - public CompanyTriggerRunnable(Long companyId) { - this.oldCompany = new CompPO(); - this.newCompany = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId); - } - - public CompanyTriggerRunnable(CompPO newCompany) { - this.oldCompany = new CompPO(); - this.newCompany = newCompany; - this.newCompany.setDeleteType(1); - } - - @Override - public void run() { - // 判断 - JclOrgMap jclMap = new JclOrgMap(); - - jclMap.setFType(1); - // 更新逻辑 - jclMap.setFObjId(newCompany.getId().intValue()); - jclMap.setId(newCompany.getId().intValue()); - jclMap.setUuid(newCompany.getUuid()); - jclMap.setFNumber(newCompany.getCompNo()); - jclMap.setFName(newCompany.getCompName()); - jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue()); - jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue()); - jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid())); - - - jclMap.setFClass(0); - jclMap.setFClassName("行政维度"); - - Integer ecResourceId = newCompany.getCompPrincipal(); - HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId); - if (null != hrmResourcePO) { - jclMap.setFLeader(hrmResourcePO.getId().intValue()); - jclMap.setFLeaderName(hrmResourcePO.getLastName()); - jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue()); - jclMap.setFLeaderSt(hrmResourcePO.getJobGrade()); - jclMap.setFLeaderLv(hrmResourcePO.getJobLevel()); - String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage(); - jclMap.setFLeaderImg(image); - if (null != hrmResourcePO.getJobTitle()) { - JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle()); - if (null != jobById) { - jclMap.setFLeaderJob(jobById.getJobName()); - } - } - } - - - String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); - jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).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); - JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString()); - if (null != jclOrgMapByObjID) { - jclMap.setFPlan(jclOrgMapByObjID.getFPlan()); - jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); - } else { - jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - jclMap.setFOnJob(0); - } - jclMap.setFIsVitual(0); - - Calendar cal = Calendar.getInstance(); - cal.setTime(jclMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); - getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); - - if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) { - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); - } - if (null != jclOrgMapByObjID) { - if (null != jclOrgMapByObjID.getFParentId()) { - updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); - } - } - if (null != oldCompany) { - if (null != oldCompany.getId()) { - updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString()); - } - } - } - - /** - * 更新上级部门在编、在岗数 - */ - void updateParentPlanAndJob(Date currentDate, String parentId) { - JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); - if (null != parentJclOrgMap) { - // 上级部门当前在编、在岗数 - JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); - StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(), parentId, null, null); - if (null != jclOrgMapSum) { - parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); - parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); - } else { - parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - parentJclOrgMap.setFOnJob(0); - } - parentJclOrgMap.setFDateBegin(currentDate); - parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - - Calendar cal = Calendar.getInstance(); - cal.setTime(parentJclOrgMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); - getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); - if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { - updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); - } - } - } -} +//public class CompanyTriggerRunnable implements Runnable { +// +// private final CompPO oldCompany; +// private final CompPO newCompany; +// +// private CompTriggerMapper getCompTriggerMapper() { +// return MapperProxyFactory.getProxy(CompTriggerMapper.class); +// } +// +// public CompanyTriggerRunnable(CompPO oldCompany, CompPO newCompany) { +// this.oldCompany = oldCompany; +// this.newCompany = newCompany; +// } +// +// public CompanyTriggerRunnable(Long companyId) { +// this.oldCompany = new CompPO(); +// this.newCompany = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId); +// } +// +// public CompanyTriggerRunnable(CompPO newCompany) { +// this.oldCompany = new CompPO(); +// this.newCompany = newCompany; +// this.newCompany.setDeleteType(1); +// } +// +// @Override +// public void run() { +// // 判断 +// JclOrgMap jclMap = new JclOrgMap(); +// +// jclMap.setFType(1); +// // 更新逻辑 +// jclMap.setFObjId(newCompany.getId().intValue()); +// jclMap.setId(newCompany.getId().intValue()); +// jclMap.setUuid(newCompany.getUuid()); +// jclMap.setFNumber(newCompany.getCompNo()); +// jclMap.setFName(newCompany.getCompName()); +// jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue()); +// jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue()); +// jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid())); +// +// +// jclMap.setFClass(0); +// jclMap.setFClassName("行政维度"); +// +// Integer ecResourceId = newCompany.getCompPrincipal(); +// HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId); +// if (null != hrmResourcePO) { +// jclMap.setFLeader(hrmResourcePO.getId().intValue()); +// jclMap.setFLeaderName(hrmResourcePO.getLastName()); +// jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue()); +// jclMap.setFLeaderSt(hrmResourcePO.getJobGrade()); +// jclMap.setFLeaderLv(hrmResourcePO.getJobLevel()); +// String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage(); +// jclMap.setFLeaderImg(image); +// if (null != hrmResourcePO.getJobTitle()) { +// JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle()); +// if (null != jobById) { +// jclMap.setFLeaderJob(jobById.getJobName()); +// } +// } +// } +// +// +// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); +// jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).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); +// JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString()); +// if (null != jclOrgMapByObjID) { +// jclMap.setFPlan(jclOrgMapByObjID.getFPlan()); +// jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); +// } else { +// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// jclMap.setFOnJob(0); +// } +// jclMap.setFIsVitual(0); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(jclMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); +// +// if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) { +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); +// } +// if (null != jclOrgMapByObjID) { +// if (null != jclOrgMapByObjID.getFParentId()) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); +// } +// } +// if (null != oldCompany) { +// if (null != oldCompany.getId()) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString()); +// } +// } +// } +// +// /** +// * 更新上级部门在编、在岗数 +// */ +// void updateParentPlanAndJob(Date currentDate, String parentId) { +// JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); +// if (null != parentJclOrgMap) { +// // 上级部门当前在编、在岗数 +// JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); +// StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(), parentId, null, null); +// if (null != jclOrgMapSum) { +// parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); +// parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); +// } else { +// parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// parentJclOrgMap.setFOnJob(0); +// } +// parentJclOrgMap.setFDateBegin(currentDate); +// parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(parentJclOrgMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); +// if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { +// updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); +// } +// } +// } +//} diff --git a/src/com/engine/organization/thread/DepartmentTriggerRunnable.java b/src/com/engine/organization/thread/DepartmentTriggerRunnable.java index 402833c0..e23a530c 100644 --- a/src/com/engine/organization/thread/DepartmentTriggerRunnable.java +++ b/src/com/engine/organization/thread/DepartmentTriggerRunnable.java @@ -1,227 +1,203 @@ package com.engine.organization.thread; -import com.engine.organization.entity.department.po.DepartmentPO; -import com.engine.organization.entity.hrmresource.po.HrmResourcePO; -import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.entity.logview.bo.FieldBaseEquator; -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.department.DepartmentMapper; -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.mapper.trigger.DepartmentTriggerMapper; -import com.engine.organization.util.OrganizationDateUtil; -import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.collections.CollectionUtils; -import weaver.common.DateUtil; -import weaver.general.Util; - -import java.sql.Date; -import java.util.Calendar; -import java.util.List; - /** * @author:dxfeng * @createTime: 2022/08/30 * @version: 1.0 */ -public class DepartmentTriggerRunnable implements Runnable { - - private DepartmentPO oldDepartment; - private final DepartmentPO newDepartment; - private String oldFparentId; - private String moveTarget; - private Boolean forbiddenTag = false; - - private CompTriggerMapper getCompTriggerMapper() { - return MapperProxyFactory.getProxy(CompTriggerMapper.class); - } - - private DepartmentTriggerMapper getDepartmentTriggerMapper() { - return MapperProxyFactory.getProxy(DepartmentTriggerMapper.class); - } - - public DepartmentTriggerRunnable(DepartmentPO oldDepartment, DepartmentPO newDepartment) { - this.oldDepartment = oldDepartment; - this.newDepartment = newDepartment; - } - - public DepartmentTriggerRunnable(Boolean forbiddenTag,DepartmentPO oldDepartment, DepartmentPO newDepartment) { - this.oldDepartment = oldDepartment; - this.newDepartment = newDepartment; - this.forbiddenTag = forbiddenTag; - } - - public DepartmentTriggerRunnable(Long departmentId) { - this.oldDepartment = new DepartmentPO(); - this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId); - } - - public DepartmentTriggerRunnable(String moveTarget,DepartmentPO newDepartment) { - this.oldDepartment = new DepartmentPO(); - this.newDepartment = newDepartment; - this.moveTarget = moveTarget; - } - - public DepartmentTriggerRunnable(Integer oldFparentId, Long departmentId) { - this.oldFparentId = null == oldFparentId ? null : oldFparentId.toString(); - this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId); - } - - public DepartmentTriggerRunnable(DepartmentPO newDepartment) { - this.oldDepartment = new DepartmentPO(); - this.newDepartment = newDepartment; - this.newDepartment.setDeleteType(1); - } - - @Override - public void run() { - FieldBaseEquator fieldBaseEquator = new FieldBaseEquator(); - List diffFields = fieldBaseEquator.getDiffFieldList(oldDepartment, newDepartment); - if (CollectionUtils.isEmpty(diffFields)) { - return; - } - - // 判断 - if (diffFields.contains("deptName") || diffFields.contains("deptPrincipal") || diffFields.contains("parentComp") || diffFields.contains("parentDept") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) { - JclOrgMap jclMap = new JclOrgMap(); - jclMap.setFType(2); - int st = 100000000; - - // 更新逻辑 - jclMap.setFObjId(newDepartment.getId().intValue()); - jclMap.setId(newDepartment.getId().intValue() + st); - jclMap.setUuid(newDepartment.getUuid()); - jclMap.setFNumber(newDepartment.getDeptNo()); - jclMap.setFName(newDepartment.getDeptName()); - jclMap.setFParentId(null == newDepartment.getParentDept() ? newDepartment.getParentComp().intValue() : newDepartment.getParentDept().intValue() + st); - jclMap.setFObjParentId(null == newDepartment.getParentDept() ? newDepartment.getParentComp().intValue() : newDepartment.getParentDept().intValue()); - - jclMap.setFEcId(getDepartmentTriggerMapper().getEcDepartmentIdByUuid(jclMap.getUuid())); - - jclMap.setFClass(0); - jclMap.setFClassName("行政维度"); - Integer ecResourceId = null == newDepartment.getDeptPrincipal() ? null : newDepartment.getDeptPrincipal().intValue(); - HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId); - if (null != hrmResourcePO) { - jclMap.setFLeader(hrmResourcePO.getId().intValue()); - jclMap.setFLeaderName(hrmResourcePO.getLastName()); - jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue()); - jclMap.setFLeaderSt(hrmResourcePO.getJobGrade()); - jclMap.setFLeaderLv(hrmResourcePO.getJobLevel()); - String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage(); - jclMap.setFLeaderImg(image); - if (null != hrmResourcePO.getJobTitle()) { - JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle()); - if (null != jobById) { - jclMap.setFLeaderJob(jobById.getJobName()); - } - } - } - - String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); - jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); - jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - - // 获取当前生效的本部门map记录 - JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.departmentfielddefined.getValue().toString(), Util.null2String(jclMap.getFObjId())); - StaffPO staffPO = new StaffPO(); - switch (jclMap.getFType()) { - // 分部 - case 1: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1,jclMap.getFObjId().toString(), null, null); - break; - // 部门 - case 2: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2,null, jclMap.getFObjId().toString(), null); - break; - } - // 取出以该部门为上级部门的在编、在岗数,转移无需计算 - JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(jclMap.getFDateBegin(), jclMap.getId().toString()); - if (null != moveTarget) { - jclOrgMap = null; - } - if (null != jclOrgMapByObjID) { - if (null != jclOrgMap) { - jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); - jclMap.setFOnJob(jclOrgMap.getFOnJob()); - } else { - jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); - } - } else { - jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - jclMap.setFOnJob(0); - } - jclMap.setFIsVitual(0); - - Calendar cal = Calendar.getInstance(); - cal.setTime(jclMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); - getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); - - if (1 != newDepartment.getDeleteType() && 1 != newDepartment.getForbiddenTag()) { - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); - } - if(null != jclOrgMapByObjID) { - updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); - } - // 部门启用,刷新上级数据 - if(forbiddenTag){ - updateParentPlanAndJob(jclMap.getFDateBegin(), jclMap.getFParentId().toString()); - } - if(null != moveTarget){ - updateParentPlanAndJob(jclMap.getFDateBegin(), moveTarget); - } - if (null != oldFparentId) { - updateParentPlanAndJob(jclMap.getFDateBegin(), oldFparentId); - } - } - } - - private void updateParentPlanAndJob(Date currentDate, String parentId) { - // 获取上级部门 - JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); - if (null != parentJclOrgMap) { - // 上级部门当前在编、在岗数 - JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); - StaffPO staffPO = new StaffPO(); - switch (parentJclOrgMap.getFType()) { - case 1: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1,Util.null2String(parentJclOrgMap.getFObjId()), null, null); - break; - // 部门 - case 2: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, Util.null2String(parentJclOrgMap.getFObjId()), null); - break; - } - // 编制表jcl_org_staff中的编制数+下级编制数,工具类判断 - if(null != jclOrgMapSum){ - parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); - parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); - }else{ - parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - parentJclOrgMap.setFOnJob(0); - } - parentJclOrgMap.setFDateBegin(currentDate); - parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - - Calendar cal = Calendar.getInstance(); - cal.setTime(parentJclOrgMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); - getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); - if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { - updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); - } - } - } -} \ No newline at end of file +//public class DepartmentTriggerRunnable implements Runnable { +// +// private DepartmentPO oldDepartment; +// private final DepartmentPO newDepartment; +// private String oldFparentId; +// private String moveTarget; +// private Boolean forbiddenTag = false; +// +// private CompTriggerMapper getCompTriggerMapper() { +// return MapperProxyFactory.getProxy(CompTriggerMapper.class); +// } +// +// private DepartmentTriggerMapper getDepartmentTriggerMapper() { +// return MapperProxyFactory.getProxy(DepartmentTriggerMapper.class); +// } +// +// public DepartmentTriggerRunnable(DepartmentPO oldDepartment, DepartmentPO newDepartment) { +// this.oldDepartment = oldDepartment; +// this.newDepartment = newDepartment; +// } +// +// public DepartmentTriggerRunnable(Boolean forbiddenTag,DepartmentPO oldDepartment, DepartmentPO newDepartment) { +// this.oldDepartment = oldDepartment; +// this.newDepartment = newDepartment; +// this.forbiddenTag = forbiddenTag; +// } +// +// public DepartmentTriggerRunnable(Long departmentId) { +// this.oldDepartment = new DepartmentPO(); +// this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId); +// } +// +// public DepartmentTriggerRunnable(String moveTarget,DepartmentPO newDepartment) { +// this.oldDepartment = new DepartmentPO(); +// this.newDepartment = newDepartment; +// this.moveTarget = moveTarget; +// } +// +// public DepartmentTriggerRunnable(Integer oldFparentId, Long departmentId) { +// this.oldFparentId = null == oldFparentId ? null : oldFparentId.toString(); +// this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId); +// } +// +// public DepartmentTriggerRunnable(DepartmentPO newDepartment) { +// this.oldDepartment = new DepartmentPO(); +// this.newDepartment = newDepartment; +// this.newDepartment.setDeleteType(1); +// } +// +// @Override +// public void run() { +// FieldBaseEquator fieldBaseEquator = new FieldBaseEquator(); +// List diffFields = fieldBaseEquator.getDiffFieldList(oldDepartment, newDepartment); +// if (CollectionUtils.isEmpty(diffFields)) { +// return; +// } +// +// // 判断 +// if (diffFields.contains("deptName") || diffFields.contains("deptPrincipal") || diffFields.contains("parentComp") || diffFields.contains("parentDept") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) { +// JclOrgMap jclMap = new JclOrgMap(); +// jclMap.setFType(2); +// int st = 100000000; +// +// // 更新逻辑 +// jclMap.setFObjId(newDepartment.getId().intValue()); +// jclMap.setId(newDepartment.getId().intValue() + st); +// jclMap.setUuid(newDepartment.getUuid()); +// jclMap.setFNumber(newDepartment.getDeptNo()); +// jclMap.setFName(newDepartment.getDeptName()); +// jclMap.setFParentId(null == newDepartment.getParentDept() ? newDepartment.getParentComp().intValue() : newDepartment.getParentDept().intValue() + st); +// jclMap.setFObjParentId(null == newDepartment.getParentDept() ? newDepartment.getParentComp().intValue() : newDepartment.getParentDept().intValue()); +// +// jclMap.setFEcId(getDepartmentTriggerMapper().getEcDepartmentIdByUuid(jclMap.getUuid())); +// +// jclMap.setFClass(0); +// jclMap.setFClassName("行政维度"); +// Integer ecResourceId = null == newDepartment.getDeptPrincipal() ? null : newDepartment.getDeptPrincipal().intValue(); +// HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId); +// if (null != hrmResourcePO) { +// jclMap.setFLeader(hrmResourcePO.getId().intValue()); +// jclMap.setFLeaderName(hrmResourcePO.getLastName()); +// jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue()); +// jclMap.setFLeaderSt(hrmResourcePO.getJobGrade()); +// jclMap.setFLeaderLv(hrmResourcePO.getJobLevel()); +// String image = UserCard.builder().image(hrmResourcePO.getResourceImageId()).build().getImage(); +// jclMap.setFLeaderImg(image); +// if (null != hrmResourcePO.getJobTitle()) { +// JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle()); +// if (null != jobById) { +// jclMap.setFLeaderJob(jobById.getJobName()); +// } +// } +// } +// +// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); +// jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); +// jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// +// // 获取当前生效的本部门map记录 +// JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.departmentfielddefined.getValue().toString(), Util.null2String(jclMap.getFObjId())); +// StaffPO staffPO = new StaffPO(); +// switch (jclMap.getFType()) { +// // 分部 +// case 1: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1,jclMap.getFObjId().toString(), null, null); +// break; +// // 部门 +// case 2: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2,null, jclMap.getFObjId().toString(), null); +// break; +// } +// // 取出以该部门为上级部门的在编、在岗数,转移无需计算 +// JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(jclMap.getFDateBegin(), jclMap.getId().toString()); +// if (null != moveTarget) { +// jclOrgMap = null; +// } +// if (null != jclOrgMapByObjID) { +// if (null != jclOrgMap) { +// jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); +// jclMap.setFOnJob(jclOrgMap.getFOnJob()); +// } else { +// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); +// } +// } else { +// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// jclMap.setFOnJob(0); +// } +// jclMap.setFIsVitual(0); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(jclMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); +// +// if (1 != newDepartment.getDeleteType() && 1 != newDepartment.getForbiddenTag()) { +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); +// } +// if(null != jclOrgMapByObjID) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); +// } +// // 部门启用,刷新上级数据 +// if(forbiddenTag){ +// updateParentPlanAndJob(jclMap.getFDateBegin(), jclMap.getFParentId().toString()); +// } +// if(null != moveTarget){ +// updateParentPlanAndJob(jclMap.getFDateBegin(), moveTarget); +// } +// if (null != oldFparentId) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), oldFparentId); +// } +// } +// } +// +// private void updateParentPlanAndJob(Date currentDate, String parentId) { +// // 获取上级部门 +// JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); +// if (null != parentJclOrgMap) { +// // 上级部门当前在编、在岗数 +// JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); +// StaffPO staffPO = new StaffPO(); +// switch (parentJclOrgMap.getFType()) { +// case 1: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1,Util.null2String(parentJclOrgMap.getFObjId()), null, null); +// break; +// // 部门 +// case 2: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, Util.null2String(parentJclOrgMap.getFObjId()), null); +// break; +// } +// // 编制表jcl_org_staff中的编制数+下级编制数,工具类判断 +// if(null != jclOrgMapSum){ +// parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); +// parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); +// }else{ +// parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// parentJclOrgMap.setFOnJob(0); +// } +// parentJclOrgMap.setFDateBegin(currentDate); +// parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(parentJclOrgMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); +// if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { +// updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); +// } +// } +// } +//} \ No newline at end of file diff --git a/src/com/engine/organization/thread/GroupTriggerRunnable.java b/src/com/engine/organization/thread/GroupTriggerRunnable.java index 0473c948..343605cf 100644 --- a/src/com/engine/organization/thread/GroupTriggerRunnable.java +++ b/src/com/engine/organization/thread/GroupTriggerRunnable.java @@ -1,98 +1,98 @@ -package com.engine.organization.thread; - -import com.engine.organization.entity.hrmresource.po.HrmResourcePO; -import com.engine.organization.entity.map.JclOrgMap; -import com.engine.organization.mapper.jclorgmap.JclOrgMapper; -import com.engine.organization.mapper.trigger.CompTriggerMapper; -import com.engine.organization.mapper.trigger.GroupTriggerMapper; -import com.engine.organization.util.OrganizationDateUtil; -import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.lang3.StringUtils; -import weaver.common.DateUtil; -import weaver.general.Util; -import weaver.hrm.passwordprotection.domain.HrmResource; - -import java.sql.Date; -import java.util.Calendar; -import java.util.Map; - -/** - * @author:dxfeng - * @createTime: 2022/08/30 - * @version: 1.0 - */ -public class GroupTriggerRunnable implements Runnable { - Map params; - - private CompTriggerMapper getCompTriggerMapper() { - return MapperProxyFactory.getProxy(CompTriggerMapper.class); - } - - private GroupTriggerMapper getGroupTriggerMapper() { - return MapperProxyFactory.getProxy(GroupTriggerMapper.class); - } - - public GroupTriggerRunnable(Map params) { - this.params = params; - } - - - @Override - public void run() { - JclOrgMap jclOrgMap = new JclOrgMap(); - //id = 0; - jclOrgMap.setId(0); - //ftype = 0; - jclOrgMap.setFType(0); - jclOrgMap.setFObjId(0); - jclOrgMap.setFEcId(parseString2Int(params.get("id"))); - jclOrgMap.setUuid(Util.null2String(params.get("uuid"))); - jclOrgMap.setFNumber("00"); - jclOrgMap.setFName(Util.null2String(params.get("companyname"))); - jclOrgMap.setFClass(0); - jclOrgMap.setFClassName("行政维度"); - jclOrgMap.setFLeader(getGroupTriggerMapper().getInfoValue(1)); - HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(jclOrgMap.getFLeader()); - if (null != hrmResourceById) { - jclOrgMap.setFLeaderImg(hrmResourceById.getMessagerurl()); - jclOrgMap.setFLeaderName(hrmResourceById.getLastname()); - jclOrgMap.setFLeaderJobId(hrmResourceById.getJobtitle()); - } - jclOrgMap.setFLeaderJob(getCompTriggerMapper().getJobTitleMarkById(jclOrgMap.getFLeaderJobId())); - HrmResourcePO resourceByEcId = getCompTriggerMapper().getResourceByEcId(jclOrgMap.getFLeader()); - if (null != resourceByEcId) { - jclOrgMap.setFLeaderSt(resourceByEcId.getJobGrade()); - jclOrgMap.setFLeaderLv(resourceByEcId.getJobLevel()); - } - jclOrgMap.setFParentId(-1); - jclOrgMap.setFObjParentId(0); - String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); - jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); - jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclOrgMap.getFDateBegin(), "0", jclOrgMap.getFObjId().toString()); - if (null != jclOrgMapByObjID) { - jclOrgMap.setFPlan(jclOrgMapByObjID.getFPlan()); - jclOrgMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); - } else { - jclOrgMap.setFPlan(0); - jclOrgMap.setFOnJob(0); - } - jclOrgMap.setFIsVitual(0); - Calendar cal = Calendar.getInstance(); - cal.setTime(jclOrgMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getGroupTriggerMapper().deleteMap(0, jclOrgMap.getFDateBegin()); - getGroupTriggerMapper().updateMap(0, jclOrgMap.getFDateBegin(), time); - - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclOrgMap); - } - - private Integer parseString2Int(Object args) { - String s = Util.null2String(args); - if (StringUtils.isBlank(s)) { - return null; - } - return Integer.parseInt(s); - } -} +//package com.engine.organization.thread; +// +//import com.engine.organization.entity.hrmresource.po.HrmResourcePO; +//import com.engine.organization.entity.map.JclOrgMap; +//import com.engine.organization.mapper.jclorgmap.JclOrgMapper; +//import com.engine.organization.mapper.trigger.CompTriggerMapper; +//import com.engine.organization.mapper.trigger.GroupTriggerMapper; +//import com.engine.organization.util.OrganizationDateUtil; +//import com.engine.organization.util.db.MapperProxyFactory; +//import org.apache.commons.lang3.StringUtils; +//import weaver.common.DateUtil; +//import weaver.general.Util; +//import weaver.hrm.passwordprotection.domain.HrmResource; +// +//import java.sql.Date; +//import java.util.Calendar; +//import java.util.Map; +// +///** +// * @author:dxfeng +// * @createTime: 2022/08/30 +// * @version: 1.0 +// */ +//public class GroupTriggerRunnable implements Runnable { +// Map params; +// +// private CompTriggerMapper getCompTriggerMapper() { +// return MapperProxyFactory.getProxy(CompTriggerMapper.class); +// } +// +// private GroupTriggerMapper getGroupTriggerMapper() { +// return MapperProxyFactory.getProxy(GroupTriggerMapper.class); +// } +// +// public GroupTriggerRunnable(Map params) { +// this.params = params; +// } +// +// +// @Override +// public void run() { +// JclOrgMap jclOrgMap = new JclOrgMap(); +// //id = 0; +// jclOrgMap.setId(0); +// //ftype = 0; +// jclOrgMap.setFType(0); +// jclOrgMap.setFObjId(0); +// jclOrgMap.setFEcId(parseString2Int(params.get("id"))); +// jclOrgMap.setUuid(Util.null2String(params.get("uuid"))); +// jclOrgMap.setFNumber("00"); +// jclOrgMap.setFName(Util.null2String(params.get("companyname"))); +// jclOrgMap.setFClass(0); +// jclOrgMap.setFClassName("行政维度"); +// jclOrgMap.setFLeader(getGroupTriggerMapper().getInfoValue(1)); +// HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(jclOrgMap.getFLeader()); +// if (null != hrmResourceById) { +// jclOrgMap.setFLeaderImg(hrmResourceById.getMessagerurl()); +// jclOrgMap.setFLeaderName(hrmResourceById.getLastname()); +// jclOrgMap.setFLeaderJobId(hrmResourceById.getJobtitle()); +// } +// jclOrgMap.setFLeaderJob(getCompTriggerMapper().getJobTitleMarkById(jclOrgMap.getFLeaderJobId())); +// HrmResourcePO resourceByEcId = getCompTriggerMapper().getResourceByEcId(jclOrgMap.getFLeader()); +// if (null != resourceByEcId) { +// jclOrgMap.setFLeaderSt(resourceByEcId.getJobGrade()); +// jclOrgMap.setFLeaderLv(resourceByEcId.getJobLevel()); +// } +// jclOrgMap.setFParentId(-1); +// jclOrgMap.setFObjParentId(0); +// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); +// jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); +// jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclOrgMap.getFDateBegin(), "0", jclOrgMap.getFObjId().toString()); +// if (null != jclOrgMapByObjID) { +// jclOrgMap.setFPlan(jclOrgMapByObjID.getFPlan()); +// jclOrgMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); +// } else { +// jclOrgMap.setFPlan(0); +// jclOrgMap.setFOnJob(0); +// } +// jclOrgMap.setFIsVitual(0); +// Calendar cal = Calendar.getInstance(); +// cal.setTime(jclOrgMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getGroupTriggerMapper().deleteMap(0, jclOrgMap.getFDateBegin()); +// getGroupTriggerMapper().updateMap(0, jclOrgMap.getFDateBegin(), time); +// +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclOrgMap); +// } +// +// private Integer parseString2Int(Object args) { +// String s = Util.null2String(args); +// if (StringUtils.isBlank(s)) { +// return null; +// } +// return Integer.parseInt(s); +// } +//} diff --git a/src/com/engine/organization/thread/HrmResourceTriggerRunnable.java b/src/com/engine/organization/thread/HrmResourceTriggerRunnable.java index 0a19fe93..1a4844c6 100644 --- a/src/com/engine/organization/thread/HrmResourceTriggerRunnable.java +++ b/src/com/engine/organization/thread/HrmResourceTriggerRunnable.java @@ -1,114 +1,114 @@ -package com.engine.organization.thread; - -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.mapper.hrmresource.HrmResourceMapper; -import com.engine.organization.mapper.jclorgmap.JclOrgMapper; -import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.mapper.trigger.CompTriggerMapper; -import com.engine.organization.mapper.trigger.HrmResourceTriggerMapper; -import com.engine.organization.util.OrganizationDateUtil; -import com.engine.organization.util.db.MapperProxyFactory; -import weaver.common.DateUtil; -import weaver.hrm.passwordprotection.domain.HrmResource; - -import java.sql.Date; -import java.util.Calendar; - -/** - * @author:dxfeng - * @createTime: 2022/09/01 - * @version: 1.0 - */ -public class HrmResourceTriggerRunnable implements Runnable { - Long userId; - - private CompTriggerMapper getCompTriggerMapper() { - return MapperProxyFactory.getProxy(CompTriggerMapper.class); - } - - private HrmResourceTriggerMapper getHrmResourceTriggerMapper() { - return MapperProxyFactory.getProxy(HrmResourceTriggerMapper.class); - } - private HrmResourceMapper getHrmResourceMapper() { - return MapperProxyFactory.getProxy(HrmResourceMapper.class); - } - private JclOrgMapper getJclOrgMapper() { - return MapperProxyFactory.getProxy(JclOrgMapper.class); - } - - public HrmResourceTriggerRunnable(Long id) { - this.userId = id; - } - - @Override - public void run() { - int st = 100000000; - int sj = 200000000; - int sk = 300000000; - Integer delete = null; - JclOrgMap jclMap = new JclOrgMap(); - jclMap.setFType(4); - // 查询当前人员信息数据 - String ecResourceId = getHrmResourceMapper().getEcResourceId(userId.toString()); - // EC人员 - HrmResource ecHrmResource = getHrmResourceTriggerMapper().getHrmResource(Long.parseLong(ecResourceId)); - // 聚才林人员 - HrmResourcePO hrmResource = getCompTriggerMapper().getResourceByEcId(Integer.parseInt(ecResourceId)); - if (null != hrmResource && null!=ecHrmResource) { - jclMap.setFObjId(hrmResource.getId().intValue()); - jclMap.setId(hrmResource.getId().intValue() + sk); - jclMap.setFEcId(ecHrmResource.getId()); - jclMap.setFNumber(hrmResource.getWorkCode()); - jclMap.setFName(hrmResource.getLastName()); - jclMap.setUuid(hrmResource.getUuid()); - delete = hrmResource.getStatus() < 4 ? 0 : 1; - // 展示为花名册上传的照片 - String image = UserCard.builder().image(hrmResource.getResourceImageId()).build().getImage(); - jclMap.setFLeaderImg(image); - jclMap.setFLeaderName(hrmResource.getLastName()); - jclMap.setFLeaderJobId(hrmResource.getJobTitle().intValue()); - if (null != hrmResource.getJobTitle()) { - JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResource.getJobTitle()); - if (null != jobById) { - jclMap.setFLeaderJob(jobById.getJobName()); - } - jclMap.setFObjParentId(hrmResource.getJobTitle().intValue()); - jclMap.setFParentId(jclMap.getFObjParentId() + sj); - } - jclMap.setFLeaderSt(hrmResource.getJobGrade()); - jclMap.setFLeaderLv(hrmResource.getJobLevel()); - jclMap.setFClass(0); - jclMap.setFClassName("行政维度"); - String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); - jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); - jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - jclMap.setFIsVitual(0); - - Calendar cal = Calendar.getInstance(); - cal.setTime(jclMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - // 更新前的数据 - JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(jclMap.getFDateBegin(), "4", hrmResource.getId().toString()); - - getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); - getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); - if (0 == delete) { - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); - // 更新当前架构图负责人的卡片信息 - getHrmResourceTriggerMapper().updateLeaders(jclMap.getFDateBegin(), hrmResource.getId().toString(), jclMap.getFLeaderImg(), jclMap.getFLeaderName(), jclMap.getFLeaderJobId(), jclMap.getFLeaderJob(), jclMap.getFLeaderLv(), jclMap.getFLeaderSt()); - // 更新组织架构图在岗数 - if (null != jclOrgMapByObjID) { - new StaffTriggerRunnable(jclOrgMapByObjID.getFObjParentId()).run(); - } - new StaffTriggerRunnable(jclMap.getFObjParentId()).run(); - - } else if (null != jclOrgMapByObjID) { - new StaffTriggerRunnable(jclOrgMapByObjID.getFObjParentId()).run(); - } - } - } -} +//package com.engine.organization.thread; +// +//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.mapper.jclorgmap.JclOrgMapper; +//import com.engine.organization.mapper.job.JobMapper; +//import com.engine.organization.mapper.resource.ResourceMapper; +//import com.engine.organization.mapper.trigger.CompTriggerMapper; +//import com.engine.organization.mapper.trigger.HrmResourceTriggerMapper; +//import com.engine.organization.util.OrganizationDateUtil; +//import com.engine.organization.util.db.MapperProxyFactory; +//import weaver.common.DateUtil; +//import weaver.hrm.passwordprotection.domain.HrmResource; +// +//import java.sql.Date; +//import java.util.Calendar; +// +///** +// * @author:dxfeng +// * @createTime: 2022/09/01 +// * @version: 1.0 +// */ +//public class HrmResourceTriggerRunnable implements Runnable { +// Long userId; +// +// private CompTriggerMapper getCompTriggerMapper() { +// return MapperProxyFactory.getProxy(CompTriggerMapper.class); +// } +// +// private HrmResourceTriggerMapper getHrmResourceTriggerMapper() { +// return MapperProxyFactory.getProxy(HrmResourceTriggerMapper.class); +// } +// private ResourceMapper getResourceMapper() { +// return MapperProxyFactory.getProxy(ResourceMapper.class); +// } +// private JclOrgMapper getJclOrgMapper() { +// return MapperProxyFactory.getProxy(JclOrgMapper.class); +// } +// +// public HrmResourceTriggerRunnable(Long id) { +// this.userId = id; +// } +// +// @Override +// public void run() { +// int st = 100000000; +// int sj = 200000000; +// int sk = 300000000; +// Integer delete = null; +// JclOrgMap jclMap = new JclOrgMap(); +// jclMap.setFType(4); +// // 查询当前人员信息数据 +// String ecResourceId = getResourceMapper().getEcResourceId(userId.toString()); +// // EC人员 +// HrmResource ecHrmResource = getHrmResourceTriggerMapper().getHrmResource(Long.parseLong(ecResourceId)); +// // 聚才林人员 +// HrmResourcePO hrmResource = getCompTriggerMapper().getResourceByEcId(Integer.parseInt(ecResourceId)); +// if (null != hrmResource && null!=ecHrmResource) { +// jclMap.setFObjId(hrmResource.getId().intValue()); +// jclMap.setId(hrmResource.getId().intValue() + sk); +// jclMap.setFEcId(ecHrmResource.getId()); +// jclMap.setFNumber(hrmResource.getWorkCode()); +// jclMap.setFName(hrmResource.getLastName()); +// jclMap.setUuid(hrmResource.getUuid()); +// delete = hrmResource.getStatus() < 4 ? 0 : 1; +// // 展示为花名册上传的照片 +// String image = UserCard.builder().image(hrmResource.getResourceImageId()).build().getImage(); +// jclMap.setFLeaderImg(image); +// jclMap.setFLeaderName(hrmResource.getLastName()); +// jclMap.setFLeaderJobId(hrmResource.getJobTitle().intValue()); +// if (null != hrmResource.getJobTitle()) { +// JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResource.getJobTitle()); +// if (null != jobById) { +// jclMap.setFLeaderJob(jobById.getJobName()); +// } +// jclMap.setFObjParentId(hrmResource.getJobTitle().intValue()); +// jclMap.setFParentId(jclMap.getFObjParentId() + sj); +// } +// jclMap.setFLeaderSt(hrmResource.getJobGrade()); +// jclMap.setFLeaderLv(hrmResource.getJobLevel()); +// jclMap.setFClass(0); +// jclMap.setFClassName("行政维度"); +// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); +// jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); +// jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// jclMap.setFIsVitual(0); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(jclMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// // 更新前的数据 +// JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(jclMap.getFDateBegin(), "4", hrmResource.getId().toString()); +// +// getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); +// if (0 == delete) { +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); +// // 更新当前架构图负责人的卡片信息 +// getHrmResourceTriggerMapper().updateLeaders(jclMap.getFDateBegin(), hrmResource.getId().toString(), jclMap.getFLeaderImg(), jclMap.getFLeaderName(), jclMap.getFLeaderJobId(), jclMap.getFLeaderJob(), jclMap.getFLeaderLv(), jclMap.getFLeaderSt()); +// // 更新组织架构图在岗数 +// if (null != jclOrgMapByObjID) { +// new StaffTriggerRunnable(jclOrgMapByObjID.getFObjParentId()).run(); +// } +// new StaffTriggerRunnable(jclMap.getFObjParentId()).run(); +// +// } else if (null != jclOrgMapByObjID) { +// new StaffTriggerRunnable(jclOrgMapByObjID.getFObjParentId()).run(); +// } +// } +// } +//} diff --git a/src/com/engine/organization/thread/JobTriggerRunnable.java b/src/com/engine/organization/thread/JobTriggerRunnable.java index 81effe44..de1cef2d 100644 --- a/src/com/engine/organization/thread/JobTriggerRunnable.java +++ b/src/com/engine/organization/thread/JobTriggerRunnable.java @@ -1,202 +1,202 @@ -package com.engine.organization.thread; - -import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.entity.logview.bo.FieldBaseEquator; -import com.engine.organization.entity.map.JclOrgMap; -import com.engine.organization.entity.staff.po.StaffPO; -import com.engine.organization.enums.ModuleTypeEnum; -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.mapper.trigger.JobTriggerMapper; -import com.engine.organization.util.OrganizationDateUtil; -import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.collections.CollectionUtils; -import weaver.common.DateUtil; - -import java.sql.Date; -import java.util.Calendar; -import java.util.List; - -/** - * @author:dxfeng - * @createTime: 2022/08/30 - * @version: 1.0 - */ -public class JobTriggerRunnable implements Runnable { - - private final JobPO oldJob; - private final JobPO newJob; - private Boolean forbiddenTag = false; - - private CompTriggerMapper getCompTriggerMapper() { - return MapperProxyFactory.getProxy(CompTriggerMapper.class); - } - - private JobTriggerMapper getJobTriggerMapper() { - return MapperProxyFactory.getProxy(JobTriggerMapper.class); - } - - public JobTriggerRunnable(JobPO oldJob, JobPO newJob) { - this.oldJob = oldJob; - this.newJob = newJob; - } - - public JobTriggerRunnable(Boolean forbiddenTag, JobPO oldJob, JobPO newJob) { - this.oldJob = oldJob; - this.newJob = newJob; - this.forbiddenTag = forbiddenTag; - } - - public JobTriggerRunnable(Long jobId) { - this.oldJob = new JobPO(); - this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId); - } - - public JobTriggerRunnable(Long oldJobId, Long newJobId) { - this.oldJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(oldJobId); - this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(newJobId); - } - - public JobTriggerRunnable(JobPO newJob) { - this.oldJob = new JobPO(); - this.newJob = newJob; - this.newJob.setDeleteType(1); - } - - @Override - public void run() { - FieldBaseEquator fieldBaseEquator = new FieldBaseEquator(); - List diffFields = fieldBaseEquator.getDiffFieldList(oldJob, newJob); - if (CollectionUtils.isEmpty(diffFields)) { - return; - } - // 判断 - JclOrgMap jclMap = new JclOrgMap(); - int st = 100000000; - int sj = 200000000; - jclMap.setFType(3); - // 更新逻辑 - jclMap.setFObjId(newJob.getId().intValue()); - jclMap.setId(newJob.getId().intValue() + sj); - jclMap.setFNumber(newJob.getJobNo()); - jclMap.setFName(newJob.getJobName()); - jclMap.setFParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() + st : newJob.getParentJob().intValue() + sj); - jclMap.setFObjParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() : newJob.getParentJob().intValue()); - Integer parentdept = newJob.getParentDept().intValue(); - - jclMap.setFClass(0); - jclMap.setFClassName("行政维度"); - - String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); - jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); - jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - - JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.jobfielddefined.getValue().toString(), jclMap.getFObjId().toString()); - - // 该岗位有下级岗位时,查询 - JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(jclMap.getFDateBegin(), jclMap.getId().toString()); - - StaffPO staffPO = new StaffPO(); - switch (jclMap.getFType()) { - // 部门 - case 2: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, jclMap.getFObjId().toString(), null); - break; - // 岗位 - case 3: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, null, jclMap.getFObjId().toString()); - break; - default: - break; - } - if (null != jclOrgMapByObjID) { - if (null != jclOrgMap) { - jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); - jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob() + jclOrgMap.getFOnJob()); - } else { - jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); - } - } else { - jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - jclMap.setFOnJob(0); - } - jclMap.setFIsVitual(0); - - Calendar cal = Calendar.getInstance(); - cal.setTime(jclMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); - getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); - - if (1 != newJob.getDeleteType() && 1 != newJob.getForbiddenTag()) { - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); - } - if (null != jclOrgMapByObjID) { - if (null != jclOrgMapByObjID.getFParentId()) { - updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); - } - } - // 部门启用,刷新上级数据 - if (forbiddenTag) { - updateParentPlanAndJob(jclMap.getFDateBegin(), jclMap.getFParentId().toString()); - } - if (null != oldJob) { - if (null != oldJob.getId()) { - updateParentPlanAndJob(jclMap.getFDateBegin(), oldJob.getId().toString()); - } - } - - } - - /** - * 更新上级部门在编、在岗数 - */ - void updateParentPlanAndJob(Date currentDate, String parentId) { - JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); - if (null != parentJclOrgMap) { - // 上级部门当前在编、在岗数 - JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); - StaffPO staffPO = new StaffPO(); - switch (parentJclOrgMap.getFType()) { - // 分部 - case 1: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1, parentJclOrgMap.getFObjId().toString(), null, null); - break; - // 部门 - case 2: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, parentJclOrgMap.getFObjId().toString(), null); - break; - // 岗位 - case 3: - staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, parentJclOrgMap.getFObjId().toString(), null); - break; - default: - break; - } - if (null != jclOrgMapSum) { - parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); - parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); - } else { - parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); - parentJclOrgMap.setFOnJob(0); - } - parentJclOrgMap.setFDateBegin(currentDate); - parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); - - Calendar cal = Calendar.getInstance(); - cal.setTime(parentJclOrgMap.getFDateBegin()); - Calendar calendar = DateUtil.addDay(cal, -1); - Date time = new Date(calendar.getTime().getTime()); - getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); - getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); - MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); - if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { - updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); - } - } - } -} \ No newline at end of file +//package com.engine.organization.thread; +// +//import com.engine.organization.entity.job.po.JobPO; +//import com.engine.organization.entity.logview.bo.FieldBaseEquator; +//import com.engine.organization.entity.map.JclOrgMap; +//import com.engine.organization.entity.staff.po.StaffPO; +//import com.engine.organization.enums.ModuleTypeEnum; +//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.mapper.trigger.JobTriggerMapper; +//import com.engine.organization.util.OrganizationDateUtil; +//import com.engine.organization.util.db.MapperProxyFactory; +//import org.apache.commons.collections.CollectionUtils; +//import weaver.common.DateUtil; +// +//import java.sql.Date; +//import java.util.Calendar; +//import java.util.List; +// +///** +// * @author:dxfeng +// * @createTime: 2022/08/30 +// * @version: 1.0 +// */ +//public class JobTriggerRunnable implements Runnable { +// +// private final JobPO oldJob; +// private final JobPO newJob; +// private Boolean forbiddenTag = false; +// +// private CompTriggerMapper getCompTriggerMapper() { +// return MapperProxyFactory.getProxy(CompTriggerMapper.class); +// } +// +// private JobTriggerMapper getJobTriggerMapper() { +// return MapperProxyFactory.getProxy(JobTriggerMapper.class); +// } +// +// public JobTriggerRunnable(JobPO oldJob, JobPO newJob) { +// this.oldJob = oldJob; +// this.newJob = newJob; +// } +// +// public JobTriggerRunnable(Boolean forbiddenTag, JobPO oldJob, JobPO newJob) { +// this.oldJob = oldJob; +// this.newJob = newJob; +// this.forbiddenTag = forbiddenTag; +// } +// +// public JobTriggerRunnable(Long jobId) { +// this.oldJob = new JobPO(); +// this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId); +// } +// +// public JobTriggerRunnable(Long oldJobId, Long newJobId) { +// this.oldJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(oldJobId); +// this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(newJobId); +// } +// +// public JobTriggerRunnable(JobPO newJob) { +// this.oldJob = new JobPO(); +// this.newJob = newJob; +// this.newJob.setDeleteType(1); +// } +// +// @Override +// public void run() { +// FieldBaseEquator fieldBaseEquator = new FieldBaseEquator(); +// List diffFields = fieldBaseEquator.getDiffFieldList(oldJob, newJob); +// if (CollectionUtils.isEmpty(diffFields)) { +// return; +// } +// // 判断 +// JclOrgMap jclMap = new JclOrgMap(); +// int st = 100000000; +// int sj = 200000000; +// jclMap.setFType(3); +// // 更新逻辑 +// jclMap.setFObjId(newJob.getId().intValue()); +// jclMap.setId(newJob.getId().intValue() + sj); +// jclMap.setFNumber(newJob.getJobNo()); +// jclMap.setFName(newJob.getJobName()); +// jclMap.setFParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() + st : newJob.getParentJob().intValue() + sj); +// jclMap.setFObjParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() : newJob.getParentJob().intValue()); +// Integer parentdept = newJob.getParentDept().intValue(); +// +// jclMap.setFClass(0); +// jclMap.setFClassName("行政维度"); +// +// String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); +// jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); +// jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// +// JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.jobfielddefined.getValue().toString(), jclMap.getFObjId().toString()); +// +// // 该岗位有下级岗位时,查询 +// JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(jclMap.getFDateBegin(), jclMap.getId().toString()); +// +// StaffPO staffPO = new StaffPO(); +// switch (jclMap.getFType()) { +// // 部门 +// case 2: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, jclMap.getFObjId().toString(), null); +// break; +// // 岗位 +// case 3: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, null, jclMap.getFObjId().toString()); +// break; +// default: +// break; +// } +// if (null != jclOrgMapByObjID) { +// if (null != jclOrgMap) { +// jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); +// jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob() + jclOrgMap.getFOnJob()); +// } else { +// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); +// } +// } else { +// jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// jclMap.setFOnJob(0); +// } +// jclMap.setFIsVitual(0); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(jclMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); +// +// if (1 != newJob.getDeleteType() && 1 != newJob.getForbiddenTag()) { +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); +// } +// if (null != jclOrgMapByObjID) { +// if (null != jclOrgMapByObjID.getFParentId()) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); +// } +// } +// // 部门启用,刷新上级数据 +// if (forbiddenTag) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), jclMap.getFParentId().toString()); +// } +// if (null != oldJob) { +// if (null != oldJob.getId()) { +// updateParentPlanAndJob(jclMap.getFDateBegin(), oldJob.getId().toString()); +// } +// } +// +// } +// +// /** +// * 更新上级部门在编、在岗数 +// */ +// void updateParentPlanAndJob(Date currentDate, String parentId) { +// JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); +// if (null != parentJclOrgMap) { +// // 上级部门当前在编、在岗数 +// JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); +// StaffPO staffPO = new StaffPO(); +// switch (parentJclOrgMap.getFType()) { +// // 分部 +// case 1: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1, parentJclOrgMap.getFObjId().toString(), null, null); +// break; +// // 部门 +// case 2: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, parentJclOrgMap.getFObjId().toString(), null); +// break; +// // 岗位 +// case 3: +// staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, parentJclOrgMap.getFObjId().toString(), null); +// break; +// default: +// break; +// } +// if (null != jclOrgMapSum) { +// parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); +// parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); +// } else { +// parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); +// parentJclOrgMap.setFOnJob(0); +// } +// parentJclOrgMap.setFDateBegin(currentDate); +// parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); +// +// Calendar cal = Calendar.getInstance(); +// cal.setTime(parentJclOrgMap.getFDateBegin()); +// Calendar calendar = DateUtil.addDay(cal, -1); +// Date time = new Date(calendar.getTime().getTime()); +// getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); +// getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); +// MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); +// if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { +// updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); +// } +// } +// } +//} \ No newline at end of file diff --git a/src/com/engine/organization/thread/OrganizationRunable.java b/src/com/engine/organization/thread/OrganizationRunable.java deleted file mode 100644 index 90689f41..00000000 --- a/src/com/engine/organization/thread/OrganizationRunable.java +++ /dev/null @@ -1,478 +0,0 @@ -package com.engine.organization.thread; - -import com.engine.common.util.ServiceUtil; -import com.engine.hrm.service.impl.HrmJobServiceImpl; -import com.engine.hrm.service.impl.OrganizationServiceImpl; -import com.engine.organization.entity.commom.RecordInfo; -import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.entity.department.po.DepartmentPO; -import com.engine.organization.entity.extend.param.ExtendInfoParams; -import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.enums.LogModuleNameEnum; -import com.engine.organization.enums.OperateTypeEnum; -import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.extend.ExtMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; -import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.relation.EcHrmRelationUtil; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import weaver.general.Util; -import weaver.hrm.User; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author:dxfeng - * @createTime: 2022/07/12 - * @version: 1.0 - */ -public class OrganizationRunable implements Runnable { - private LogModuleNameEnum moduleName; - private OperateTypeEnum operateType; - private Map params; - private User user; - private JobPO oldJobPO; - - private static final String HRM_COMPANY = "hrmsubcompany"; - private static final String HRM_DEPARTMENT = "hrmdepartment"; - - private static final String JCL_COMPANY = "jcl_org_comp"; - private static final String JCL_DEPARTMENT = "jcl_org_dept"; - - private SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); - } - - private ExtMapper getExtMapper() { - return MapperProxyFactory.getProxy(ExtMapper.class); - } - - public OrganizationRunable(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map params) { - this.moduleName = moduleName; - this.operateType = operateType; - this.params = params; - this.user = user; - } - - public OrganizationRunable(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map params, JobPO oldJobPO) { - this.moduleName = moduleName; - this.operateType = operateType; - this.params = params; - this.user = user; - this.oldJobPO = oldJobPO; - } - - - @Override - public void run() { - switch (moduleName) { - case COMPANY: - refreshCompany(); - break; - case DEPARTMENT: - refreshDepartment(); - break; - case JOB: - refreshJob(); - break; - default: - break; - } - } - - /** - * 刷新HrmSubCompany表数据 - */ - private void refreshCompany() { - switch (operateType) { - case ADD: - addCompany(); - break; - case UPDATE: - updateCompany(); - break; - case CANCELED: - cancelCompany(); - break; - default: - break; - } - } - - /** - * 刷新HrmDepartment表数据 - */ - private void refreshDepartment() { - switch (operateType) { - case ADD: - addDepartment(); - break; - case UPDATE: - updateDepartment(); - break; - case CANCELED: - cancelDepartment(); - break; - default: - break; - } - } - - private void refreshJob() { - switch (operateType) { - case ADD: - addJob(); - break; - case UPDATE: - updateJob(); - break; - case CANCELED: - cancelJob(); - break; - default: - break; - } - } - - /** - * 新增岗位 - * - *

- * 1、EC表HrmJobTitles - *

- * 2、系统中新建“聚才林”、“默认职务”(sql写入) - *

- * 3、检索岗位名称jobtitlename,如果已存在,判断是否封存,对已封存数据解封操作 - *

- * 4、如果不存在,在“聚才林--默认职务”下新建岗位 - */ - private void addJob() { - // 判断是否存在同名岗位、存在不做处理,不存在,在“默认职务分类--默认职务”下新建岗位 - String jobName = Util.null2String(params.get("job_name")); - RecordInfo hrmJobActivity = getSystemDataMapper().getHrmJobTitleByName(jobName); - Map map = new HashMap<>(); - //存在且已封存,对岗位解封 - if (null != hrmJobActivity && "1".equals(hrmJobActivity.getCanceled())) { - map.put("ids", hrmJobActivity.getId()); - map.put("canceled", "docanceled"); - ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - // 不存在则新建职务 - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", jobName); - map.put("jobtitlename", jobName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no"))); - - ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user); - } - } - - /** - * 更新岗位 - */ - private void updateJob() { - Long jclJobId = oldJobPO.getId(); - String oldName = oldJobPO.getJobName(); - - String newName = Util.null2String(params.get("job_name")); - RecordInfo oldHrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(oldName); - - Map map = new HashMap<>(); - // 修改前不存在共用 - if (EcHrmRelationUtil.isNotExistJob(oldName, jclJobId)) { - // 修改后不存在共用、直接修改EC岗位表数据 - if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) { - // 查询ec表ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(oldName); - map.put("id", Util.null2String(hrmJobTitle.getId())); - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", newName); - map.put("jobtitlename", newName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no"))); - // 修改岗位表数据 - ServiceUtil.getService(HrmJobServiceImpl.class, user).editJobTitle(map, user); - } else { - // 修改后存在共用、不修改岗位表数据,更新对应人员的岗位信息为当前岗位的ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - // 查询原分部、原岗位下的人员,并更新岗位ID - List hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId()); - getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds); - // 封存原名称岗位 - map.clear(); - map.put("ids", oldHrmJobTitle.getId()); - map.put("canceled", "canceled"); - ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } - } else { - // 修改前存在共用,不对原有数据进行操作。 - - // 修改后不存在共用、新建岗位,更新原有岗位下人员的岗位ID - if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) { - // 不存在则新建职务 - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", newName); - map.put("jobtitlename", newName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no"))); - ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user); - // 新建岗位 - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - // 查询原分部、原岗位下的人员,并更新岗位ID - List hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId()); - getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds); - } else { - // 修改后存在共用,更新原有岗位下人员的岗位ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - // 查询原分部、原岗位下的人员,并更新岗位ID - List hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId()); - getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds); - } - } - } - - /** - * 封存、解封岗位 - */ - private void cancelJob() { - Map map = new HashMap<>(); - RecordInfo hrmJobTitleByName = getSystemDataMapper().getHrmJobTitleByName(oldJobPO.getJobName()); - if (0 == oldJobPO.getForbiddenTag()) { - // 启用 - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "docanceled"); - ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - // 禁用 - List jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listByNameExceptId(oldJobPO.getJobName(), oldJobPO.getId()); - // 不存在共用 - if (CollectionUtils.isEmpty(jobPOS)) { - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "canceled"); - ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - List collect = jobPOS.stream().filter(item -> 0 == item.getForbiddenTag()).collect(Collectors.toList()); - // 不存在非禁用 - if (CollectionUtils.isEmpty(collect)) { - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "canceled"); - ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } - } - } - } - - /** - * 新增部门 - */ - private void addDepartment() { - Map map = new HashMap<>(); - map.put("departmentmark", Util.null2String(params.get("dept_name_short"))); - map.put("departmentname", Util.null2String(params.get("dept_name"))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_comp")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("subcompanyid1", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - - // 上级部门通过UUID联查ec表ID - String parentDepartment = Util.null2String(params.get("parent_dept")); - if (StringUtils.isNotBlank(parentDepartment)) { - map.put("supdepid", EcHrmRelationUtil.getEcDepartmentId(parentDepartment)); - } - - map.put("showorder", Util.null2String(params.get("show_order"))); - map.put("departmentcode", Util.null2String(params.get("dept_no"))); - map.put("coadjutant", Util.null2String(params.get("dept_principal"))); - Map returnMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addDepartment(map, user); - // 更新jcl_org_dept表 uuid字段 - if ("1".equals(Util.null2String(returnMap.get("status"))) && null != returnMap.get("id")) { - updateJclUUID(Util.null2String(returnMap.get("id")), HRM_DEPARTMENT, JCL_DEPARTMENT); - } - } - - /** - * 封存、解封部门 - */ - private void cancelDepartment() { - String departmentIds = Util.null2String(params.get("id")); - String forbiddenTag = Util.null2String(params.get("forbiddenTag")); - List idList = new ArrayList<>(); - String[] split = departmentIds.split(","); - if (StringUtils.isBlank(forbiddenTag)) { - long currentTimeMillis = System.currentTimeMillis(); - for (String s : split) { - DepartmentPO departmentPO = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(Long.parseLong(s)); - params.put("dept_name_short", departmentPO.getDeptNameShort() + currentTimeMillis); - params.put("dept_name", departmentPO.getDeptName() + currentTimeMillis); - params.put("parent_comp", departmentPO.getParentComp()); - params.put("parent_dept", departmentPO.getParentDept()); - params.put("show_order", departmentPO.getShowOrder()); - params.put("dept_no", departmentPO.getDeptNo()); - params.put("dept_principal", departmentPO.getDeptPrincipal()); - updateDepartment(); - idList.add(EcHrmRelationUtil.getEcDepartmentId(s)); - } - } else { - for (String s : split) { - idList.add(EcHrmRelationUtil.getEcDepartmentId(s)); - } - } - Map map = new HashMap<>(); - map.put("id", StringUtils.join(idList, ",")); - if ("0".equals(forbiddenTag)) { - // 解封 - ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentISCanceled(map, user); - } else { - // 封存 - ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(map, user); - } - } - - /** - * 更新部门 - */ - private void updateDepartment() { - Map map = new HashMap<>(); - // 获取ec表ID - map.put("id", EcHrmRelationUtil.getEcDepartmentId(Util.null2String(params.get("id")))); - map.put("departmentmark", Util.null2String(params.get("dept_name_short"))); - map.put("departmentname", Util.null2String(params.get("dept_name"))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_comp")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("subcompanyid1", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - - // 上级部门通过UUID联查ec表ID - String parentDepartment = Util.null2String(params.get("parent_dept")); - if (StringUtils.isNotBlank(parentDepartment)) { - map.put("supdepid", EcHrmRelationUtil.getEcDepartmentId(parentDepartment)); - } - - map.put("showorder", Util.null2String(params.get("show_order"))); - map.put("departmentcode", Util.null2String(params.get("dept_no"))); - map.put("coadjutant", Util.null2String(params.get("dept_principal"))); - ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(map, user); - } - - /** - * 新增分部 - */ - private void addCompany() { - Map map = new HashMap<>(); - map.put("subcompanyname", Util.null2String(params.get("comp_name_short"))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_company")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("supsubcomid", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - - map.put("subcompanycode", params.get("comp_no").toString()); - map.put("subcompanydesc", params.get("comp_name").toString()); - map.put("showorder", Util.null2String(params.get("show_order"))); - Map returnMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addSubCompany(map, user); - - // 更新jcl_org_comp表 uuid字段 - if ("1".equals(Util.null2String(returnMap.get("status"))) && null != returnMap.get("id")) { - updateJclUUID(Util.null2String(returnMap.get("id")), HRM_COMPANY, JCL_COMPANY); - } - } - - /** - * 更新分部 - */ - private void updateCompany() { - Map map = new HashMap<>(); - // 获取ec表ID - map.put("id", EcHrmRelationUtil.getEcCompanyId(Util.null2String(params.get("id")))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_company")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("supsubcomid", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - map.put("subcompanycode", Util.null2String(params.get("comp_no"))); - map.put("subcompanyname", Util.null2String(params.get("comp_name_short"))); - map.put("subcompanydesc", Util.null2String(params.get("comp_name"))); - map.put("showorder", Util.null2String(params.get("show_order"))); - ServiceUtil.getService(OrganizationServiceImpl.class, user).editSubCompany(map, user); - } - - /** - * 封存、解封分部 - */ - private void cancelCompany() { - String companyIds = Util.null2String(params.get("id")); - String forbiddenTag = Util.null2String(params.get("forbiddenTag")); - List idList = new ArrayList<>(); - String[] split = companyIds.split(","); - if (StringUtils.isBlank(forbiddenTag)) { - long currentTimeMillis = System.currentTimeMillis(); - for (String s : split) { - // 更新名称为:名称+时间戳 - CompPO comp = MapperProxyFactory.getProxy(CompMapper.class).listById(Long.parseLong(s)); - params.put("parent_company", comp.getParentCompany()); - params.put("comp_no", comp.getCompNo()); - params.put("comp_name", comp.getCompName() + currentTimeMillis); - params.put("comp_name_short", comp.getCompNameShort() + currentTimeMillis); - params.put("show_order", comp.getShowOrder()); - updateCompany(); - idList.add(EcHrmRelationUtil.getEcCompanyId(s)); - } - } else { - for (String s : split) { - idList.add(EcHrmRelationUtil.getEcCompanyId(s)); - } - } - Map map = new HashMap<>(); - map.put("id", StringUtils.join(idList, ",")); - - if ("0".equals(forbiddenTag)) { - // 解封 - ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyISCanceled(map, user); - } else { - // 删除封存、禁用封存 - ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyCancel(map, user); - } - } - - - /** - * 更新聚才林组织UUID - * - * @param id - * @param ecTableName - * @param jclTableName - */ - private void updateJclUUID(String id, String ecTableName, String jclTableName) { - RecordInfo hrmDepartment = getSystemDataMapper().getHrmObjectByID(ecTableName, id); - String uuid = hrmDepartment.getUuid(); - Map departmentMap = new HashMap<>(); - departmentMap.put("uuid", uuid); - long jclTableId = Long.parseLong(Util.null2String(params.get("id"))); - ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName(jclTableName).params(departmentMap).id(jclTableId).build(); - getExtMapper().updateTable(infoParams); - } - -} diff --git a/src/com/engine/organization/thread/OrganizationSyncEc.java b/src/com/engine/organization/thread/OrganizationSyncEc.java index 16d97e93..f6e47e88 100644 --- a/src/com/engine/organization/thread/OrganizationSyncEc.java +++ b/src/com/engine/organization/thread/OrganizationSyncEc.java @@ -1,32 +1,17 @@ package com.engine.organization.thread; import com.engine.common.util.ServiceUtil; -import com.engine.hrm.service.impl.HrmJobServiceImpl; import com.engine.hrm.service.impl.OrganizationServiceImpl; -import com.engine.organization.entity.commom.RecordInfo; -import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.entity.department.po.DepartmentPO; -import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.enums.LogModuleNameEnum; import com.engine.organization.enums.OperateTypeEnum; -import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; -import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.util.OrganizationAssert; -import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.relation.EcHrmRelationUtil; import com.engine.organization.util.relation.ResourceSyncUtil; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; import weaver.general.Util; import weaver.hrm.User; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * @author:dxfeng @@ -38,13 +23,10 @@ public class OrganizationSyncEc { private final OperateTypeEnum operateType; private Map params; private final User user; - private JobPO oldJobPO; Map resultMap; private boolean throwException = true; - private SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); - } + public OrganizationSyncEc(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map params) { this.moduleName = moduleName; @@ -61,22 +43,6 @@ public class OrganizationSyncEc { this.throwException = throwException; } - public OrganizationSyncEc(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map params, JobPO oldJobPO) { - this.moduleName = moduleName; - this.operateType = operateType; - this.params = params; - this.user = user; - this.oldJobPO = oldJobPO; - } - - public OrganizationSyncEc(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map params, JobPO oldJobPO, boolean throwException) { - this.moduleName = moduleName; - this.operateType = operateType; - this.params = params; - this.user = user; - this.oldJobPO = oldJobPO; - this.throwException = throwException; - } public Map sync() { switch (moduleName) { @@ -86,9 +52,6 @@ public class OrganizationSyncEc { case DEPARTMENT: refreshDepartment(); break; - case JOB: - refreshJob(); - break; case RESOURCE: refreshResource(); default: @@ -139,23 +102,8 @@ public class OrganizationSyncEc { } } - private void refreshJob() { - switch (operateType) { - case ADD: - addJob(); - break; - case UPDATE: - updateJob(); - break; - case CANCELED: - cancelJob(); - break; - default: - break; - } - } - private void refreshResource(){ + private void refreshResource() { switch (operateType) { case ADD: addResource(); @@ -180,233 +128,24 @@ public class OrganizationSyncEc { } - /** - * 新增岗位 - * - *

- * 1、EC表HrmJobTitles - *

- * 2、系统中新建“聚才林”、“默认职务”(sql写入) - *

- * 3、检索岗位名称jobtitlename,如果已存在,判断是否封存,对已封存数据解封操作 - *

- * 4、如果不存在,在“聚才林--默认职务”下新建岗位 - */ - private void addJob() { - // 判断是否存在同名岗位、存在不做处理,不存在,在“默认职务分类--默认职务”下新建岗位 - String jobName = Util.null2String(params.get("job_name")); - RecordInfo hrmJobActivity = getSystemDataMapper().getHrmJobTitleByName(jobName); - Map map = new HashMap<>(); - //存在且已封存,对岗位解封 - if (null != hrmJobActivity) { - map.put("ids", hrmJobActivity.getId()); - map.put("canceled", "docanceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - // 不存在则新建职务 - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", jobName); - map.put("jobtitlename", jobName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no"))); - - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user); - } - } - - /** - * 更新岗位 - */ - private void updateJob() { - Long jclJobId = oldJobPO.getId(); - String oldName = oldJobPO.getJobName(); - - String newName = Util.null2String(params.get("job_name")); - RecordInfo oldHrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(oldName); - - Map map = new HashMap<>(); - // 修改前不存在共用 - if (EcHrmRelationUtil.isNotExistJob(oldName, jclJobId)) { - // 修改后不存在共用、直接修改EC岗位表数据 - if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) { - // 查询ec表ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - if (null != hrmJobTitle) { - map.put("id", Util.null2String(hrmJobTitle.getId())); - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", newName); - map.put("jobtitlename", newName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no")) + "_" + System.currentTimeMillis()); - // 修改岗位表数据 - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).editJobTitle(map, user); - } else { - // 不存在则新建职务 - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", newName); - map.put("jobtitlename", newName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no")) + "_" + System.currentTimeMillis()); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user); - } - } else { - // 修改后存在共用、不修改岗位表数据,更新对应人员的岗位信息为当前岗位的ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - // 查询原分部、原岗位下的人员,并更新岗位ID - List hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId()); - if (CollectionUtils.isNotEmpty(hrmResourceIds)) { - getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds); - } - // 封存原名称岗位 - map.put("ids", oldHrmJobTitle.getId()); - map.put("canceled", "canceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } - } else { - // 修改前存在共用,不对原有数据进行操作。 - - // 修改后不存在共用、新建岗位,更新原有岗位下人员的岗位ID - if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) { - RecordInfo hrmJobActivity = getSystemDataMapper().getHrmJobTitleByName(newName); - //存在且已封存,对岗位解封 - if (null != hrmJobActivity) { - map.put("ids", hrmJobActivity.getId()); - map.put("canceled", "docanceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - // 不存在则新建职务 - map.put("operateIp", Util.null2String(user.getLoginip())); - map.put("jobtitlemark", newName); - map.put("jobtitlename", newName); - map.put("jobactivityid", Util.null2String(params.get("jobactivityid"))); - map.put("jobresponsibility", Util.null2String(params.get("work_duty"))); - map.put("jobcompetency", Util.null2String(params.get("work_authority"))); - map.put("jobtitleremark", Util.null2String(params.get("description"))); - map.put("jobtitlecode", Util.null2String(params.get("job_no"))); - - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user); - } - } else { - this.resultMap = new HashMap<>(); - this.resultMap.put("sign", "1"); - } - // 查询原分部、原岗位下的人员,并更新岗位ID - RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName); - List hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId()); - if (CollectionUtils.isNotEmpty(hrmResourceIds)) { - getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds); - } - } - } - - /** - * 封存、解封岗位 - */ - private void cancelJob() { - Map map = new HashMap<>(); - RecordInfo hrmJobTitleByName = getSystemDataMapper().getHrmJobTitleByName(oldJobPO.getJobName()); - if (null == hrmJobTitleByName) { - return; - } - if (0 == oldJobPO.getForbiddenTag()) { - // 启用 - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "docanceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - // 禁用 - List jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listByNameExceptId(oldJobPO.getJobName(), oldJobPO.getId()); - // 不存在共用 - if (CollectionUtils.isEmpty(jobPOS)) { - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "canceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } else { - List collect = jobPOS.stream().filter(item -> 0 == item.getForbiddenTag()).collect(Collectors.toList()); - // 不存在非禁用 - if (CollectionUtils.isEmpty(collect)) { - map.put("ids", hrmJobTitleByName.getId()); - map.put("canceled", "canceled"); - this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user); - } - } - } - } - /** * 新增部门 */ private void addDepartment() { - Map map = new HashMap<>(); - map.put("departmentmark", Util.null2String(params.get("dept_name_short"))); - map.put("departmentname", Util.null2String(params.get("dept_name"))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_comp")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("subcompanyid1", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - - // 上级部门通过UUID联查ec表ID - String parentDepartment = Util.null2String(params.get("parent_dept")); - if (StringUtils.isNotBlank(parentDepartment)) { - map.put("supdepid", EcHrmRelationUtil.getEcDepartmentId(parentDepartment)); - } - - map.put("showorder", Util.null2String(params.get("show_order"))); - map.put("departmentcode", Util.null2String(params.get("dept_no"))); - map.put("coadjutant", Util.null2String(params.get("dept_principal"))); - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addDepartment(map, user); - // 更新jcl_org_dept表 uuid字段 - //if ("1".equals(Util.null2String(resultMap.get("status"))) && null != resultMap.get("id")) { - // updateJclUUID(Util.null2String(resultMap.get("id")), HRM_DEPARTMENT, JCL_DEPARTMENT); - //} + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addDepartment(params, user); } /** * 封存、解封部门 */ private void cancelDepartment() { - String departmentIds = Util.null2String(params.get("id")); String forbiddenTag = Util.null2String(params.get("forbiddenTag")); - List idList = new ArrayList<>(); - String[] split = departmentIds.split(","); - if (StringUtils.isBlank(forbiddenTag)) { - long currentTimeMillis = System.currentTimeMillis(); - for (String s : split) { - DepartmentPO departmentPO = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(Long.parseLong(s)); - params.put("dept_name_short", departmentPO.getDeptNameShort() + currentTimeMillis); - params.put("dept_name", departmentPO.getDeptName() + currentTimeMillis); - params.put("parent_comp", departmentPO.getParentComp()); - params.put("parent_dept", departmentPO.getParentDept()); - params.put("show_order", departmentPO.getShowOrder()); - params.put("dept_no", departmentPO.getDeptNo() + currentTimeMillis); - params.put("dept_principal", departmentPO.getDeptPrincipal()); - updateDepartment(); - idList.add(EcHrmRelationUtil.getEcDepartmentId(s)); - } - } else { - for (String s : split) { - idList.add(EcHrmRelationUtil.getEcDepartmentId(s)); - } - } - Map map = new HashMap<>(); - map.put("id", StringUtils.join(idList, ",")); if ("0".equals(forbiddenTag)) { // 解封 - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentISCanceled(map, user); + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentISCanceled(params, user); } else { // 封存 - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(map, user); + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(params, user); } } @@ -415,26 +154,8 @@ public class OrganizationSyncEc { */ private void updateDepartment() { Map map = new HashMap<>(); - // 获取ec表ID - map.put("id", EcHrmRelationUtil.getEcDepartmentId(Util.null2String(params.get("id")))); - map.put("departmentmark", Util.null2String(params.get("dept_name_short"))); - map.put("departmentname", Util.null2String(params.get("dept_name"))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_comp")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("subcompanyid1", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - - // 上级部门通过UUID联查ec表ID - String parentDepartment = Util.null2String(params.get("parent_dept")); - if (StringUtils.isNotBlank(parentDepartment)) { - map.put("supdepid", EcHrmRelationUtil.getEcDepartmentId(parentDepartment)); - } - - map.put("showorder", Util.null2String(params.get("show_order"))); - map.put("departmentcode", Util.null2String(params.get("dept_no"))); - map.put("coadjutant", Util.null2String(params.get("dept_principal"))); + buildEcDepartmentData(map); + map.putAll(params); this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(map, user); } @@ -442,19 +163,7 @@ public class OrganizationSyncEc { * 新增分部 */ private void addCompany() { - Map map = new HashMap<>(); - map.put("subcompanyname", Util.null2String(params.get("comp_name_short"))); - - // 上级分部通过UUID联查ec表ID - String ecCompany = Util.null2String(params.get("ec_company")); - if (StringUtils.isNotBlank(ecCompany)) { - map.put("supsubcomid", ecCompany); - } - - map.put("subcompanycode", params.get("comp_no").toString()); - map.put("subcompanydesc", params.get("comp_name").toString()); - map.put("showorder", Util.null2String(params.get("show_order"))); - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addSubCompany(map, user); + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).addSubCompany(params, user); } /** @@ -462,18 +171,8 @@ public class OrganizationSyncEc { */ private void updateCompany() { Map map = new HashMap<>(); - // 获取ec表ID - map.put("id", EcHrmRelationUtil.getEcCompanyId(Util.null2String(params.get("id")))); - - // 上级分部通过UUID联查ec表ID - String parentCompany = Util.null2String(params.get("parent_company")); - if (StringUtils.isNotBlank(parentCompany)) { - map.put("supsubcomid", EcHrmRelationUtil.getEcCompanyId(parentCompany)); - } - map.put("subcompanycode", Util.null2String(params.get("comp_no"))); - map.put("subcompanyname", Util.null2String(params.get("comp_name_short"))); - map.put("subcompanydesc", Util.null2String(params.get("comp_name"))); - map.put("showorder", Util.null2String(params.get("show_order"))); + buildEcCompanyData(map); + map.putAll(params); this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editSubCompany(map, user); } @@ -481,37 +180,61 @@ public class OrganizationSyncEc { * 封存、解封分部 */ private void cancelCompany() { - String companyIds = Util.null2String(params.get("id")); + // TODO String forbiddenTag = Util.null2String(params.get("forbiddenTag")); - List idList = new ArrayList<>(); - String[] split = companyIds.split(","); - if (StringUtils.isBlank(forbiddenTag)) { - long currentTimeMillis = System.currentTimeMillis(); - for (String s : split) { - // 更新名称为:名称+时间戳 - CompPO comp = MapperProxyFactory.getProxy(CompMapper.class).listById(Long.parseLong(s)); - params.put("parent_company", comp.getParentCompany()); - params.put("comp_no", comp.getCompNo() + currentTimeMillis); - params.put("comp_name", comp.getCompName() + currentTimeMillis); - params.put("comp_name_short", comp.getCompNameShort() + currentTimeMillis); - params.put("show_order", comp.getShowOrder()); - updateCompany(); - idList.add(EcHrmRelationUtil.getEcCompanyId(s)); - } - } else { - for (String s : split) { - idList.add(EcHrmRelationUtil.getEcCompanyId(s)); - } - } - Map map = new HashMap<>(); - map.put("id", StringUtils.join(idList, ",")); - if ("0".equals(forbiddenTag)) { // 解封 - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyISCanceled(map, user); + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyISCanceled(params, user); } else { // 删除封存、禁用封存 - this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyCancel(map, user); + this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).doSubCompanyCancel(params, user); } } + + private void buildEcCompanyData(Map map) { + String ecCompanyId = Util.null2String(params.get("id")); + + map.put("id", ecCompanyId); + RecordSet rs = new RecordSet(); + // 先查拓展表 + rs.execute("select * from hrmsubcompanydefined where subcomid = '" + ecCompanyId + "'"); + int colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + // 再查主表 + rs.execute("select * from hrmsubcompany where id = '" + ecCompanyId + "'"); + colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + } + + private void buildEcDepartmentData(Map map) { + String ecDepartment = Util.null2String(params.get("id")); + + map.put("id", ecDepartment); + RecordSet rs = new RecordSet(); + // 先查拓展表 + rs.execute("select * from hrmdepartmentdefined where deptid = '" + ecDepartment + "'"); + int colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + // 再查主表 + rs.execute("select * from hrmdepartment where id = '" + ecDepartment + "'"); + colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + } + } diff --git a/src/com/engine/organization/thread/StaffTriggerRunnable.java b/src/com/engine/organization/thread/StaffTriggerRunnable.java index 39e5affa..076ebed0 100644 --- a/src/com/engine/organization/thread/StaffTriggerRunnable.java +++ b/src/com/engine/organization/thread/StaffTriggerRunnable.java @@ -1,188 +1,188 @@ -package com.engine.organization.thread; - -import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.entity.department.po.DepartmentPO; -import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.entity.map.JclOrgMap; -import com.engine.organization.entity.staff.po.StaffPO; -import com.engine.organization.entity.staff.po.StaffPlanPO; -import com.engine.organization.enums.ModuleTypeEnum; -import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.jclorgmap.JclOrgMapper; -import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.mapper.staff.StaffPlanMapper; -import com.engine.organization.mapper.trigger.StaffTriggerMapper; -import com.engine.organization.util.OrganizationDateUtil; -import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.lang3.StringUtils; -import weaver.common.DateUtil; - -import java.sql.Date; - -/** - * @author:dxfeng - * @createTime: 2022/09/21 - * @version: 1.0 - */ -public class StaffTriggerRunnable implements Runnable { - StaffPO staffPO; - StaffPlanPO staffPlanByID; - - private StaffPlanMapper getStaffPlanMapper() { - return MapperProxyFactory.getProxy(StaffPlanMapper.class); - } - - private StaffTriggerMapper getStaffTriggerMapper() { - return MapperProxyFactory.getProxy(StaffTriggerMapper.class); - } - - private CompMapper getCompMapper() { - return MapperProxyFactory.getProxy(CompMapper.class); - } - - private DepartmentMapper getDepartmentMapper() { - return MapperProxyFactory.getProxy(DepartmentMapper.class); - } - - private JobMapper getJobMapper() { - return MapperProxyFactory.getProxy(JobMapper.class); - } - - private JclOrgMapper getJclOrgMapper() { - return MapperProxyFactory.getProxy(JclOrgMapper.class); - } - - private final Date currentDate; - private final Date yesterday; - - public StaffTriggerRunnable(StaffPO staffPO) { - this.staffPO = staffPO; - this.staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId()); - - currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime()); - yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime()); - } - - public StaffTriggerRunnable(Integer jclJobId) { - if (null != jclJobId) { - JobPO jobById = getJobMapper().getJobById((long) jclJobId); - if (null != jobById) { - this.staffPO = StaffPO.builder().compId(jobById.getParentComp()).deptId(jobById.getParentDept()).jobId(jobById.getId()).build(); - this.staffPlanByID = StaffPlanPO.builder().controlDimension("3").build(); - } - } - currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime()); - yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime()); - } - - @Override - public void run() { - if (null != staffPO) { - if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) { - String fType = staffPlanByID.getControlDimension(); - switch (fType) { - case "1": - // 更新分部编制 - refreshCompanyStaff(staffPO.getCompId()); - break; - case "2": - // 更新部门编制 - refreshDepartmentStaff(staffPO.getDeptId()); - refreshCompanyStaff(staffPO.getCompId()); - break; - case "3": - // 更新岗位编制 - refreshJobStaff(staffPO.getJobId()); - refreshDepartmentStaff(staffPO.getDeptId()); - refreshCompanyStaff(staffPO.getCompId()); - break; - default: - break; - } - } - } - } - - private void refreshCompanyStaff(Long companyId) { - if (null == companyId) { - return; - } - CompPO compPO = getCompMapper().listById(companyId); - if (null != compPO) { - updateOrgMap(ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), companyId.toString()); - if (null != compPO.getParentCompany() && 0 != compPO.getParentCompany()) { - refreshCompanyStaff(compPO.getParentCompany()); - } else { - // 刷新集团数据 - refreshGroupStaff(); - } - } - } - - private void refreshDepartmentStaff(Long departmentId) { - if (null == departmentId) { - return; - } - DepartmentPO deptById = getDepartmentMapper().getDeptById(departmentId); - if (null != deptById) { - updateOrgMap(ModuleTypeEnum.departmentfielddefined.getValue().toString(), departmentId.toString()); - if (null != deptById.getParentDept() && 0 != deptById.getParentDept()) { - refreshDepartmentStaff(deptById.getParentDept()); - } - } - } - - private void refreshJobStaff(Long jobId) { - if (null == jobId) { - return; - } - JobPO jobById = getJobMapper().getJobById(jobId); - if (null != jobById) { - updateOrgMap(ModuleTypeEnum.jobfielddefined.getValue().toString(), jobId.toString()); - if (null != jobById.getParentJob() && 0 != jobById.getParentJob()) { - refreshJobStaff(jobById.getParentJob()); - } - } - } - - private void refreshGroupStaff() { - updateOrgMap("0", "0"); - } - - - private void updateOrgMap(String type, String objId) { - Integer planSum = 0; - Integer onJobSum = 0; - switch (type) { - case "1": - planSum = getStaffTriggerMapper().countCompanyStaffNum(currentDate, objId); - break; - case "2": - planSum = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, objId); - break; - case "3": - planSum = getStaffTriggerMapper().countJobStaffNum(currentDate, objId); - onJobSum = getStaffTriggerMapper().countOnJobByJObId(objId); - default: - break; - } - - JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(currentDate, type, objId); - String mapInfoId = getStaffTriggerMapper().getIdByObjIdAndType(currentDate, objId, type); - Integer childPlanSum = getStaffTriggerMapper().sumPlanByParentId(currentDate, mapInfoId); - Integer childOnJobSum = getStaffTriggerMapper().sumOnJobByParentId(currentDate, mapInfoId); - getJclOrgMapper().deleteMap(type, objId, currentDate); - getJclOrgMapper().updateMap(type, objId, currentDate, yesterday); - jclOrgMapByObjID.setFPlan(addInteger(planSum, childPlanSum)); - jclOrgMapByObjID.setFOnJob(addInteger(onJobSum, childOnJobSum)); - jclOrgMapByObjID.setFDateBegin(currentDate); - getJclOrgMapper().insertMap(jclOrgMapByObjID); - } - - private Integer addInteger(Integer num1, Integer num2) { - num1 = num1 == null ? 0 : num1; - num2 = num2 == null ? 0 : num2; - return num1 + num2; - } -} +//package com.engine.organization.thread; +// +//import com.engine.organization.entity.company.po.CompPO; +//import com.engine.organization.entity.department.po.DepartmentPO; +//import com.engine.organization.entity.job.po.JobPO; +//import com.engine.organization.entity.map.JclOrgMap; +//import com.engine.organization.entity.staff.po.StaffPO; +//import com.engine.organization.entity.staff.po.StaffPlanPO; +//import com.engine.organization.enums.ModuleTypeEnum; +//import com.engine.organization.mapper.comp.CompMapper; +//import com.engine.organization.mapper.department.DepartmentMapper; +//import com.engine.organization.mapper.jclorgmap.JclOrgMapper; +//import com.engine.organization.mapper.job.JobMapper; +//import com.engine.organization.mapper.staff.StaffPlanMapper; +//import com.engine.organization.mapper.trigger.StaffTriggerMapper; +//import com.engine.organization.util.OrganizationDateUtil; +//import com.engine.organization.util.db.MapperProxyFactory; +//import org.apache.commons.lang3.StringUtils; +//import weaver.common.DateUtil; +// +//import java.sql.Date; +// +///** +// * @author:dxfeng +// * @createTime: 2022/09/21 +// * @version: 1.0 +// */ +//public class StaffTriggerRunnable implements Runnable { +// StaffPO staffPO; +// StaffPlanPO staffPlanByID; +// +// private StaffPlanMapper getStaffPlanMapper() { +// return MapperProxyFactory.getProxy(StaffPlanMapper.class); +// } +// +// private StaffTriggerMapper getStaffTriggerMapper() { +// return MapperProxyFactory.getProxy(StaffTriggerMapper.class); +// } +// +// private CompMapper getCompMapper() { +// return MapperProxyFactory.getProxy(CompMapper.class); +// } +// +// private DepartmentMapper getDepartmentMapper() { +// return MapperProxyFactory.getProxy(DepartmentMapper.class); +// } +// +// private JobMapper getJobMapper() { +// return MapperProxyFactory.getProxy(JobMapper.class); +// } +// +// private JclOrgMapper getJclOrgMapper() { +// return MapperProxyFactory.getProxy(JclOrgMapper.class); +// } +// +// private final Date currentDate; +// private final Date yesterday; +// +// public StaffTriggerRunnable(StaffPO staffPO) { +// this.staffPO = staffPO; +// this.staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId()); +// +// currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime()); +// yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime()); +// } +// +// public StaffTriggerRunnable(Integer jclJobId) { +// if (null != jclJobId) { +// JobPO jobById = getJobMapper().getJobById((long) jclJobId); +// if (null != jobById) { +// this.staffPO = StaffPO.builder().compId(jobById.getEcCompany()).deptId(jobById.getEcDepartment()).jobId(jobById.getId()).build(); +// this.staffPlanByID = StaffPlanPO.builder().controlDimension("3").build(); +// } +// } +// currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime()); +// yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime()); +// } +// +// @Override +// public void run() { +// if (null != staffPO) { +// if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) { +// String fType = staffPlanByID.getControlDimension(); +// switch (fType) { +// case "1": +// // 更新分部编制 +// refreshCompanyStaff(staffPO.getCompId().intValue()); +// break; +// case "2": +// // 更新部门编制 +// refreshDepartmentStaff(staffPO.getDeptId()); +// refreshCompanyStaff(staffPO.getCompId().intValue()); +// break; +// case "3": +// // 更新岗位编制 +// refreshJobStaff(staffPO.getJobId()); +// refreshDepartmentStaff(staffPO.getDeptId()); +// refreshCompanyStaff(staffPO.getCompId().intValue()); +// break; +// default: +// break; +// } +// } +// } +// } +// +// private void refreshCompanyStaff(Integer companyId) { +// if (null == companyId) { +// return; +// } +// CompPO compPO = getCompMapper().listById(companyId); +// if (null != compPO) { +// updateOrgMap(ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), companyId.toString()); +// if (null != compPO.getSupSubComId() && 0 != compPO.getSupSubComId()) { +// refreshCompanyStaff(compPO.getSupSubComId()); +// } else { +// // 刷新集团数据 +// refreshGroupStaff(); +// } +// } +// } +// +// private void refreshDepartmentStaff(Integer departmentId) { +// if (null == departmentId) { +// return; +// } +// DepartmentPO deptById = getDepartmentMapper().getDeptById(departmentId); +// if (null != deptById) { +// updateOrgMap(ModuleTypeEnum.departmentfielddefined.getValue().toString(), departmentId.toString()); +// if (null != deptById.getSupDepId() && 0 != deptById.getSupDepId()) { +// refreshDepartmentStaff(deptById.getSupDepId()); +// } +// } +// } +// +// private void refreshJobStaff(Long jobId) { +// if (null == jobId) { +// return; +// } +// JobPO jobById = getJobMapper().getJobById(jobId); +// if (null != jobById) { +// updateOrgMap(ModuleTypeEnum.jobfielddefined.getValue().toString(), jobId.toString()); +// if (null != jobById.getParentJob() && 0 != jobById.getParentJob()) { +// refreshJobStaff(jobById.getParentJob()); +// } +// } +// } +// +// private void refreshGroupStaff() { +// updateOrgMap("0", "0"); +// } +// +// +// private void updateOrgMap(String type, String objId) { +// Integer planSum = 0; +// Integer onJobSum = 0; +// switch (type) { +// case "1": +// planSum = getStaffTriggerMapper().countCompanyStaffNum(currentDate, objId); +// break; +// case "2": +// planSum = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, objId); +// break; +// case "3": +// planSum = getStaffTriggerMapper().countJobStaffNum(currentDate, objId); +// onJobSum = getStaffTriggerMapper().countOnJobByJObId(objId); +// default: +// break; +// } +// +// JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(currentDate, type, objId); +// String mapInfoId = getStaffTriggerMapper().getIdByObjIdAndType(currentDate, objId, type); +// Integer childPlanSum = getStaffTriggerMapper().sumPlanByParentId(currentDate, mapInfoId); +// Integer childOnJobSum = getStaffTriggerMapper().sumOnJobByParentId(currentDate, mapInfoId); +// getJclOrgMapper().deleteMap(type, objId, currentDate); +// getJclOrgMapper().updateMap(type, objId, currentDate, yesterday); +// jclOrgMapByObjID.setFPlan(addInteger(planSum, childPlanSum)); +// jclOrgMapByObjID.setFOnJob(addInteger(onJobSum, childOnJobSum)); +// jclOrgMapByObjID.setFDateBegin(currentDate); +// getJclOrgMapper().insertMap(jclOrgMapByObjID); +// } +// +// private Integer addInteger(Integer num1, Integer num2) { +// num1 = num1 == null ? 0 : num1; +// num2 = num2 == null ? 0 : num2; +// return num1 + num2; +// } +//} diff --git a/src/com/engine/organization/transmethod/CompTransMethod.java b/src/com/engine/organization/transmethod/CompTransMethod.java index cbe1df11..8fd63132 100644 --- a/src/com/engine/organization/transmethod/CompTransMethod.java +++ b/src/com/engine/organization/transmethod/CompTransMethod.java @@ -1,11 +1,11 @@ package com.engine.organization.transmethod; import com.engine.organization.entity.DeleteParam; +import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.util.db.MapperProxyFactory; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; /** @@ -18,8 +18,7 @@ public class CompTransMethod { public static String getSpanById(String planId) { CompMapper compMapper = MapperProxyFactory.getProxy(CompMapper.class); - List> maps = compMapper.listCompsByIds(DeleteParam.builder().ids(planId).build().getIds()); - String names = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(",")); - return names; + List maps = compMapper.getCompsByIds(DeleteParam.builder().ids(planId).build().getIds()); + return maps.stream().map(CompPO::getSubCompanyName).collect(Collectors.joining(",")); } } diff --git a/src/com/engine/organization/transmethod/HrmResourceTransMethod.java b/src/com/engine/organization/transmethod/HrmResourceTransMethod.java index a575dc77..bcdcfbc9 100644 --- a/src/com/engine/organization/transmethod/HrmResourceTransMethod.java +++ b/src/com/engine/organization/transmethod/HrmResourceTransMethod.java @@ -1,11 +1,13 @@ package com.engine.organization.transmethod; +import com.engine.organization.entity.job.bo.JobBO; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; -import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.util.db.MapperProxyFactory; +import org.json.JSONObject; import weaver.hrm.User; +import weaver.hrm.definedfield.HrmFieldManager; /** * @author:dxfeng @@ -14,15 +16,30 @@ import weaver.hrm.User; */ public class HrmResourceTransMethod { + public static String getFieldTrueValue(String id, String para) { + HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", Integer.parseInt(para.split("_")[0])); + // hfm.getCustomFields(); + String fieldName = para.substring(para.lastIndexOf("_") + 1); + JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName); + User user = new User(); + user.setUid(1); + try { + return hfm.getFieldvalue(null, user, null, hrmFieldConf.getString("dmlurl"), hrmFieldConf.getInt("id"), hrmFieldConf.getInt("fieldhtmltype"), hrmFieldConf.getInt("type"), id, 0, fieldName); + } catch (Exception e) { + return ""; + } + } + public static String getDepartmentName(String departmentId) { - return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(Long.parseLong(departmentId)); + return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(Integer.parseInt(departmentId)); } public static String getCompanyName(String companyId) { - return MapperProxyFactory.getProxy(CompMapper.class).listById(Long.parseLong(companyId)).getCompName(); + return MapperProxyFactory.getProxy(CompMapper.class).listById(Integer.parseInt(companyId)).getSubCompanyName(); } + public static String getJobName(String jobTitle) { - return MapperProxyFactory.getProxy(JobMapper.class).getJobById(Long.parseLong(jobTitle)).getJobName(); + return JobBO.getJobTitleNameByEcJobTitle(jobTitle); } public static String getManagerName(String managerId) { diff --git a/src/com/engine/organization/transmethod/JobTransMethod.java b/src/com/engine/organization/transmethod/JobTransMethod.java index 20850a8b..82d0b130 100644 --- a/src/com/engine/organization/transmethod/JobTransMethod.java +++ b/src/com/engine/organization/transmethod/JobTransMethod.java @@ -1,6 +1,7 @@ package com.engine.organization.transmethod; import com.engine.organization.entity.DeleteParam; +import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.scheme.GradeMapper; import com.engine.organization.mapper.scheme.LevelMapper; @@ -20,18 +21,16 @@ import java.util.stream.Collectors; */ public class JobTransMethod { - public static String getSpanById(String planId) { + public static String getSpanById(String jobId) { JobMapper jobMapper = MapperProxyFactory.getProxy(JobMapper.class); - List> maps = jobMapper.listJobsByIds(DeleteParam.builder().ids(planId).build().getIds()); - String names = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(",")); - return names; + List jobsByIds = jobMapper.getJobsByIds(DeleteParam.builder().ids(jobId).build().getIds()); + return jobsByIds.stream().map(JobPO::getJobTitleName).collect(Collectors.joining(",")); } public static String getLevelName(String levelId) { LevelMapper levelMapper = MapperProxyFactory.getProxy(LevelMapper.class); List> maps = levelMapper.listLevelsByIds(DeleteParam.builder().ids(levelId).build().getIds()); - String levelName = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(",")); - return levelName; + return maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(",")); } public static String getGradeName(String gradeId) { diff --git a/src/com/engine/organization/transmethod/ManagerDetachTransMethod.java b/src/com/engine/organization/transmethod/ManagerDetachTransMethod.java index 7ad97512..330f8c65 100644 --- a/src/com/engine/organization/transmethod/ManagerDetachTransMethod.java +++ b/src/com/engine/organization/transmethod/ManagerDetachTransMethod.java @@ -5,8 +5,10 @@ import com.engine.organization.entity.DeleteParam; import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -20,8 +22,15 @@ import java.util.stream.Collectors; public class ManagerDetachTransMethod { public static String getManagerName(String ecManager) { - String managerName = MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(Long.valueOf(ecManager)); - return managerName; + if (org.apache.commons.lang.StringUtils.isBlank(ecManager)) { + return ""; + } + List collect = Arrays.stream(ecManager.split(",")).map(Long::parseLong).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + return ""; + } + List employeeNameById = MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(collect); + return StringUtils.join(employeeNameById, ","); } diff --git a/src/com/engine/organization/transmethod/SystemTransMethod.java b/src/com/engine/organization/transmethod/SystemTransMethod.java index 314b2547..bb2e4ca9 100644 --- a/src/com/engine/organization/transmethod/SystemTransMethod.java +++ b/src/com/engine/organization/transmethod/SystemTransMethod.java @@ -19,7 +19,7 @@ public class SystemTransMethod { List list = new ArrayList<>(); if (StringUtils.isNotBlank(roleIds)) { for (String roleId : roleIds.split(",")) { - list.add(rolesComInfo.getRolesname(roleId)); + list.add(rolesComInfo.getRolesRemark(roleId)); } } return StringUtils.join(list,","); diff --git a/src/com/engine/organization/util/ConfigTrans.java b/src/com/engine/organization/util/ConfigTrans.java index a520f459..8d647d90 100644 --- a/src/com/engine/organization/util/ConfigTrans.java +++ b/src/com/engine/organization/util/ConfigTrans.java @@ -13,10 +13,11 @@ import java.util.List; public class ConfigTrans { public static String getCheckBoxPopedom(String status) { - if ("0".equals(status)) + if ("0".equals(status)) { return "true"; - else + } else { return "false"; + } } public static List formatSourceOperates(String id, String isDefault) { diff --git a/src/com/engine/organization/util/OrganizationFormItemUtil.java b/src/com/engine/organization/util/OrganizationFormItemUtil.java index 7f7daa2a..91697ee1 100644 --- a/src/com/engine/organization/util/OrganizationFormItemUtil.java +++ b/src/com/engine/organization/util/OrganizationFormItemUtil.java @@ -1,10 +1,12 @@ package com.engine.organization.util; +import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; +import com.engine.organization.entity.browser.po.CustomBrowserBean; import weaver.hrm.User; import java.util.ArrayList; @@ -182,6 +184,14 @@ public class OrganizationFormItemUtil { browser.setOtherParams(otherMap); } } + if ("666".equals(type)) { + BrowserBean browserBean = browser.getBrowserConditionParam(); + String s = JSONObject.toJSONString(browserBean); + CustomBrowserBean customBrowserBean = JSONObject.parseObject(s, CustomBrowserBean.class); + customBrowserBean.setHasLeftTree(true); + customBrowserBean.setLeftToSearchKey("treeKey"); + browser.setBrowserConditionParam(customBrowserBean); + } return browser; } diff --git a/src/com/engine/organization/util/PageInfoSortUtil.java b/src/com/engine/organization/util/PageInfoSortUtil.java index 79d267e0..902ba5c5 100644 --- a/src/com/engine/organization/util/PageInfoSortUtil.java +++ b/src/com/engine/organization/util/PageInfoSortUtil.java @@ -20,15 +20,15 @@ public class PageInfoSortUtil { * @param sortParams * @return */ - public static String getSortSql(String sortParams) { + public static String getSortSql(String sortParams, String defaultOrder) { JSONArray jsonArray = JSONObject.parseArray(sortParams); if (CollectionUtils.isNotEmpty(jsonArray)) { JSONObject jsonObject = (JSONObject) jsonArray.get(0); - String orderKey = upperCharToUnderLine(jsonObject.getString("orderkey")); + String orderKey = jsonObject.getString("orderkey"); String sortOrder = jsonObject.getString("sortOrder").replace("end", ""); return "t." + orderKey + " " + sortOrder; } - return " show_order "; + return defaultOrder; } /** @@ -39,7 +39,7 @@ public class PageInfoSortUtil { */ private static String upperCharToUnderLine(String param) { Pattern p = Pattern.compile("[A-Z]"); - if (param == null || param.equals("")) { + if (param == null || "".equals(param)) { return ""; } StringBuilder builder = new StringBuilder(param); diff --git a/src/com/engine/organization/util/ResponseResult.java b/src/com/engine/organization/util/ResponseResult.java index c5fd845e..141a8b45 100644 --- a/src/com/engine/organization/util/ResponseResult.java +++ b/src/com/engine/organization/util/ResponseResult.java @@ -37,7 +37,7 @@ public class ResponseResult { private void permission() { if (permission) { List roleInfo = hrmCommonService.getRoleInfo(user.getUID()); - roleInfo.stream().map(m -> (Map) m).filter(m -> m.get("roleid") != null && m.get("roleid").toString().equals("28")).findFirst().orElseThrow(() -> new OrganizationRunTimeException("无权限")); + roleInfo.stream().map(m -> (Map) m).filter(m -> m.get("roleid") != null && "28".equals(m.get("roleid").toString())).findFirst().orElseThrow(() -> new OrganizationRunTimeException("无权限")); } } diff --git a/src/com/engine/organization/util/db/DBOperateAdapter.java b/src/com/engine/organization/util/db/DBOperateAdapter.java index ac2e0fd6..e9caa997 100644 --- a/src/com/engine/organization/util/db/DBOperateAdapter.java +++ b/src/com/engine/organization/util/db/DBOperateAdapter.java @@ -4,4 +4,8 @@ public interface DBOperateAdapter { String like(String some); String concat(String some); + + String currentDate(); + + String ifNull(String some, String defaultValue); } diff --git a/src/com/engine/organization/util/db/DBType.java b/src/com/engine/organization/util/db/DBType.java index c9ea4676..35fe3346 100644 --- a/src/com/engine/organization/util/db/DBType.java +++ b/src/com/engine/organization/util/db/DBType.java @@ -15,6 +15,16 @@ public enum DBType implements DBOperateAdapter { public String concat(String some) { return " concat(','," + some + ",',') "; } + + @Override + public String currentDate() { + return "now()"; + } + + @Override + public String ifNull(String some, String defaultValue) { + return " ifnull(" + some + ",'" + defaultValue + "')"; + } }, SQLSERVER("sqlserver") { @Override @@ -26,17 +36,58 @@ public enum DBType implements DBOperateAdapter { public String concat(String some) { return " ','+" + some + "+',' "; } + + @Override + public String currentDate() { + return "GETDATE()"; + } + + @Override + public String ifNull(String some, String defaultValue) { + return " isnull(" + some + ",'" + defaultValue + "')"; + } }, ORACLE("oracle") { @Override public String like(String some) { - return " like '%'||" + some + "||'%' "; + return " like '%" + some + "%' "; } @Override public String concat(String some) { return " ',' ||" + some + "|| ',' "; } + + @Override + public String currentDate() { + return "SYSDATE"; + } + + @Override + public String ifNull(String some, String defaultValue) { + return " NVL(" + some + ",'" + defaultValue + "')"; + } + }, + POSTGRESQL("postgresql") { + @Override + public String like(String some) { + return " like '%" + some + "%' "; + } + + @Override + public String concat(String some) { + return " ',' ||" + some + "|| ',' "; + } + + @Override + public String currentDate() { + return "now()"; + } + + @Override + public String ifNull(String some, String defaultValue) { + return " COALESCE(" + some + ",'" + defaultValue + "')"; + } }; private String dbtype; diff --git a/src/com/engine/organization/util/detach/DetachUtil.java b/src/com/engine/organization/util/detach/DetachUtil.java index 7b047c29..12f269ef 100644 --- a/src/com/engine/organization/util/detach/DetachUtil.java +++ b/src/com/engine/organization/util/detach/DetachUtil.java @@ -2,12 +2,14 @@ package com.engine.organization.util.detach; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.hrmresource.po.ResourcePO; import com.engine.organization.entity.job.dto.JobListDTO; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.service.impl.ManagerDetachServiceImpl; import com.weaver.general.BaseBean; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; import java.util.ArrayList; import java.util.List; @@ -20,14 +22,14 @@ import java.util.List; public class DetachUtil { private boolean DETACH = "true".equals(new BaseBean().getPropValue("hrmOrganization", "detach")); - private final List jclRoleLevels; + private final List jclRoleLevels; - public DetachUtil(Integer uId) { - if (1 == uId) { + public DetachUtil(User user) { + if (1 == user.getUID() || user.isAdmin()) { DETACH = false; } if (DETACH) { - jclRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(uId); + jclRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(user.getUID()); } else { jclRoleLevels = new ArrayList<>(); } @@ -47,7 +49,7 @@ public class DetachUtil { */ public void filterDepartmentList(List departmentList) { if (DETACH && CollectionUtils.isNotEmpty(departmentList)) { - departmentList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp())); + departmentList.removeIf(item -> !jclRoleLevels.contains(item.getSubCompanyId1())); } } @@ -56,7 +58,7 @@ public class DetachUtil { */ public void filterJobDTOList(List jobList) { if (DETACH && CollectionUtils.isNotEmpty(jobList)) { - jobList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp())); + jobList.removeIf(item -> !jclRoleLevels.contains(item.getEcCompany())); } } @@ -65,7 +67,13 @@ public class DetachUtil { */ public void filterJobList(List jobList) { if (DETACH && CollectionUtils.isNotEmpty(jobList)) { - jobList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp())); + jobList.removeIf(item -> !jclRoleLevels.contains(item.getEcCompany())); + } + } + + public void filterResourceList(List resourcePOS) { + if (DETACH && CollectionUtils.isNotEmpty(resourcePOS)) { + resourcePOS.removeIf(item -> !jclRoleLevels.contains(item.getSubcompanyid1())); } } diff --git a/src/com/engine/organization/util/excel/ExcelSupport.java b/src/com/engine/organization/util/excel/ExcelSupport.java index 2d307995..63b0f7cf 100644 --- a/src/com/engine/organization/util/excel/ExcelSupport.java +++ b/src/com/engine/organization/util/excel/ExcelSupport.java @@ -20,7 +20,7 @@ import static org.apache.poi.ss.usermodel.CellType.STRING; public class ExcelSupport { - private static final String pattern = "yyyy-MM-dd HH:mm:ss"; + private static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; //excel类型 public static final String EXCEL_TYPE_XLSX = "xlsx"; @@ -115,7 +115,7 @@ public class ExcelSupport { switch (cell.getCellType()) { case NUMERIC: // 数值类型 if (DateUtil.isCellDateFormatted(cell)) { - cellValue = getDateStr(cell.getDateCellValue(), pattern); + cellValue = getDateStr(cell.getDateCellValue(), PATTERN); } else { cell.setCellType(STRING); cellValue = cell.getStringCellValue(); diff --git a/src/com/engine/organization/util/field/FieldDefinedValueUtil.java b/src/com/engine/organization/util/field/FieldDefinedValueUtil.java index 3fc69167..56f9c188 100644 --- a/src/com/engine/organization/util/field/FieldDefinedValueUtil.java +++ b/src/com/engine/organization/util/field/FieldDefinedValueUtil.java @@ -221,7 +221,9 @@ public class FieldDefinedValueUtil { } else if (fieldType == 161 || fieldType == 162) { //自定义浏览按钮 try { String fieldDbType = requestId;//用requestid传递数据 dmlurl - if (Util.null2String(fieldDbType).length() == 0 || fieldDbType.equals("emptyVal")) return ""; + if (Util.null2String(fieldDbType).length() == 0 || "emptyVal".equals(fieldDbType)) { + return ""; + } String sql = "select count(1) from mode_browser where showname = '" + fieldDbType + "'"; rs.execute(sql); if (rs.next()) {//建模浏览框 @@ -239,7 +241,7 @@ public class FieldDefinedValueUtil { try { BrowserBean bb = browser.searchById(s); String name = Util.null2String(bb.getName()); - if (showName.toString().equals("")) { + if ("".equals(showName.toString())) { showName.append(name); } else { showName.append(",").append(name); @@ -254,12 +256,12 @@ public class FieldDefinedValueUtil { } } else if (fieldType == 256 || fieldType == 257) { - if (!fieldValue.equals("null")) { + if (!"null".equals(fieldValue)) { CustomTreeUtil customTreeUtil = new CustomTreeUtil(); for (String s : tempshowidlist) { String show_val = Util.null2String(s); String name = customTreeUtil.getTreeFieldShowName(show_val, requestId); - if (showName.toString().equals("")) { + if ("".equals(showName.toString())) { showName.append(name); } else { showName.append(",").append(name); @@ -274,8 +276,8 @@ public class FieldDefinedValueUtil { + fieldType); String keyColumName = new BrowserComInfo() .getBrowserkeycolumname("" + fieldType); - if (columName.equals("") || tableName.equals("") - || keyColumName.equals("") || fieldValue.equals("")) { + if ("".equals(columName) || "".equals(tableName) + || "".equals(keyColumName) || "".equals(fieldValue)) { new BaseBean().writeLog("GET FIELD ERR: fieldType=" + fieldType); } else { sql = "select " + columName + " from " + tableName @@ -291,7 +293,7 @@ public class FieldDefinedValueUtil { showName = new StringBuilder(showName.substring(0, showName.length() - 1)); } } else if (fieldHtmlType == 4) { // check框 - if (fieldValue.equals("1")) { + if ("1".equals(fieldValue)) { showName.append("√"); } } else if (fieldHtmlType == 5) { diff --git a/src/com/engine/organization/util/field/StaticFieldName.java b/src/com/engine/organization/util/field/StaticFieldName.java new file mode 100644 index 00000000..8c474f5c --- /dev/null +++ b/src/com/engine/organization/util/field/StaticFieldName.java @@ -0,0 +1,39 @@ +package com.engine.organization.util.field; + +import weaver.conn.RecordSet; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/12/20 + * @version: 1.0 + */ +public class StaticFieldName { + private static final Map fieldNameMap; + public static final String zdzjFieldName; + // 等级方案 + public static final String schemeFieldName; + // 职等 + public static final String levelFieldName; + // 职级 + public static final String gradeFieldName; + // 岗位序列 + public static final String sequenceFieldName; + + static { + fieldNameMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + rs.execute("select fieldlabel ,fieldname from jcl_org_field"); + while (rs.next()) { + fieldNameMap.put(rs.getString("fieldlabel"), rs.getString("fieldname")); + } + zdzjFieldName = fieldNameMap.get("职等职级"); + schemeFieldName = fieldNameMap.get("等级方案"); + levelFieldName = fieldNameMap.get("职等"); + gradeFieldName = fieldNameMap.get("职级"); + sequenceFieldName = fieldNameMap.get("岗位序列"); + } + +} diff --git a/src/com/engine/organization/util/page/PageInfo.java b/src/com/engine/organization/util/page/PageInfo.java index 41cc3411..56cdbd0e 100644 --- a/src/com/engine/organization/util/page/PageInfo.java +++ b/src/com/engine/organization/util/page/PageInfo.java @@ -2,6 +2,7 @@ package com.engine.organization.util.page; import com.engine.organization.annotation.TableTitle; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.ToString; import java.lang.reflect.Field; @@ -10,6 +11,7 @@ import java.util.List; @Data @ToString +@EqualsAndHashCode(callSuper=false) public class PageInfo extends com.github.pagehelper.PageInfo { Class clazz; diff --git a/src/com/engine/organization/util/relation/EcHrmRelationUtil.java b/src/com/engine/organization/util/relation/EcHrmRelationUtil.java index eca283eb..7219bd1e 100644 --- a/src/com/engine/organization/util/relation/EcHrmRelationUtil.java +++ b/src/com/engine/organization/util/relation/EcHrmRelationUtil.java @@ -1,19 +1,9 @@ package com.engine.organization.util.relation; -import com.engine.organization.entity.commom.RecordInfo; -import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.mapper.comp.CompMapper; -import com.engine.organization.mapper.department.DepartmentMapper; -import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.util.db.MapperProxyFactory; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; - -import java.util.Arrays; -import java.util.List; +import weaver.general.Util; /** * @author:dxfeng @@ -22,127 +12,18 @@ import java.util.List; */ public class EcHrmRelationUtil { - private static final String HRM_COMPANY = "hrmsubcompany"; - private static final String HRM_DEPARTMENT = "hrmdepartment"; - - - private static SystemDataMapper getSystemDataMapper() { - return MapperProxyFactory.getProxy(SystemDataMapper.class); - } - - private static CompMapper getCompMapper() { - return MapperProxyFactory.getProxy(CompMapper.class); - } - - private static DepartmentMapper getDepartmentMapper() { - return MapperProxyFactory.getProxy(DepartmentMapper.class); - } - private static JobMapper getJobMapper() { return MapperProxyFactory.getProxy(JobMapper.class); } - /** - * 根据jcl_org_comp.id获取HrmSubCompany.id - * - * @param companyId - * @return - */ - public static String getEcCompanyId(String companyId) { - CompPO compPO = getCompMapper().listById(Long.parseLong(companyId)); - RecordInfo supSubCompany = getSystemDataMapper().getHrmObjectByUUID(HRM_COMPANY, compPO.getUuid()); - if (null == supSubCompany) { - return "0"; - } - return supSubCompany.getId(); - } - - /** - * 根据jcl_org_dept.id获取HrmDepartment.id - * - * @param departmentId - * @return - */ - public static String getEcDepartmentId(String departmentId) { - DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Long.parseLong(departmentId)); - RecordInfo supDepartment = getSystemDataMapper().getHrmObjectByUUID(HRM_DEPARTMENT, departmentPO.getUuid()); - return supDepartment.getId(); - } - - public static CompPO getJclCompanyId(String ecCompanyId) { - if (StringUtils.isBlank(ecCompanyId)) { - return null; - } - RecordInfo ecCompany = getSystemDataMapper().getHrmObjectByID(HRM_COMPANY, ecCompanyId); - if (null == ecCompany) { - return null; - } - String uuid = ecCompany.getUuid(); - return getCompMapper().getCompanyByUUID(uuid); - } - - public static String getBatchJclCompanyId(String ecBatchCompanyId) { - if (StringUtils.isBlank(ecBatchCompanyId)) { - return null; - } - List strings = Arrays.asList(ecBatchCompanyId.split(",")); - List uuids = getSystemDataMapper().getBatchUuidByIds(HRM_COMPANY, strings); - List companyIdsByUuid = getCompMapper().getCompanyIdsByUuid(uuids); - if (CollectionUtils.isNotEmpty(companyIdsByUuid)) { - return StringUtils.join(companyIdsByUuid, ","); - } - return ""; - } - - - public static DepartmentPO getJclDepartmentId(String ecDepartmentId) { - if (StringUtils.isBlank(ecDepartmentId)) { - return null; - } - RecordInfo ecDepartment = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentId); - if (null == ecDepartment) { - return null; - } - String uuid = ecDepartment.getUuid(); - return getDepartmentMapper().getDepartmentByUUID(uuid); - } - public static String getEcJobId(Long jclJobId) { JobPO jobById = getJobMapper().getJobById(jclJobId); if (null == jobById) { return ""; } - RecordInfo hrmJobTitleByName = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmJobTitleByName(jobById.getJobName()); - if (null == hrmJobTitleByName) { - return ""; - } - return hrmJobTitleByName.getId(); - } - - /** - * 判断岗位名称是否共用 - *

存在返回true

- * - * @param jobName - * @param id - * @return - */ - public static boolean isExistJob(String jobName, Long id) { - List jobPOS = getJobMapper().listByNameExceptId(jobName, id); - return CollectionUtils.isNotEmpty(jobPOS); + return Util.null2String(jobById.getEcJobTitle()); } - /** - * 判断岗位名称是否共用 - *

不存在返回true

- * - * @param jobName - * @param id - * @return - */ - public static boolean isNotExistJob(String jobName, Long id) { - return !isExistJob(jobName, id); - } } diff --git a/src/com/engine/organization/util/relation/ResourceSyncUtil.java b/src/com/engine/organization/util/relation/ResourceSyncUtil.java index 274032ff..0c013e2a 100644 --- a/src/com/engine/organization/util/relation/ResourceSyncUtil.java +++ b/src/com/engine/organization/util/relation/ResourceSyncUtil.java @@ -17,8 +17,6 @@ import com.engine.hrm.util.HrmWeakPasswordUtil; import com.engine.hrm.util.face.HrmFaceCheckManager; import com.engine.hrm.util.face.ValidateFieldManager; import com.engine.hrm.util.face.bean.CheckItemBean; -import com.engine.organization.mapper.hrmresource.HrmResourceMapper; -import com.engine.organization.util.db.MapperProxyFactory; import com.weaver.general.BaseBean; import ln.LN; import org.apache.commons.lang3.StringUtils; @@ -65,8 +63,8 @@ import java.util.Map; * @version: 1.0 */ public class ResourceSyncUtil { - private static final char separator = Util.getSeparator(); - private static final String today = DateUtil.getCurrentDate(); + private static final char SEPARATOR = Util.getSeparator(); + private static final String TODAY = DateUtil.getCurrentDate(); public static Map addResource(User user, Map params) { @@ -83,7 +81,9 @@ public class ResourceSyncUtil { } String loginid = Util.null2String(params.get("loginid")); String accounttype = Util.null2s(Util.fromScreen3(Util.null2String(params.get(("accounttype"))), user.getLanguage()), "0"); - if (accounttype.equals("1")) loginid = "";//次账号没有loginid + if ("1".equals(accounttype)) { + loginid = "";//次账号没有loginid + } boolean canSave = false; LN LN = new LN(); int ckHrmnum = LN.CkHrmnum(); @@ -101,7 +101,7 @@ public class ResourceSyncUtil { } - if (!loginid.equals("") && "0".equals(accounttype)) { + if (!"".equals(loginid) && "0".equals(accounttype)) { sql = "select count(1) from hrmresourceallview where loginid='" + loginid + "' "; rs.execute(sql); if (rs.next()) { @@ -115,7 +115,7 @@ public class ResourceSyncUtil { String departmentid = Util.null2String(params.get("departmentid")); String subcompanyid = departmentComInfo.getSubcompanyid1(departmentid); - if (!loginid.equals("") && !subcompanyid.equals("0") && new HrmResourceManager().noMore(subcompanyid)) { + if (!"".equals(loginid) && !"0".equals(subcompanyid) && new HrmResourceManager().noMore(subcompanyid)) { retmap.put("status", "-1"); retmap.put("message", SystemEnv.getHtmlLabelName(81926, user.getLanguage())); return retmap; @@ -148,14 +148,14 @@ public class ResourceSyncUtil { //【初始密码】 String defaultPassword = Util.null2String(settings.getDefaultPassword()); //如果管理员设置的密码为空。并且开启了【启用初始密码】,且初始密码不为空,则默认取初始密码作为密码 - if (password.equals("") && defaultPasswordEnable.equals("1") && !defaultPassword.equals("")) { + if ("".equals(password) && "1".equals(defaultPasswordEnable) && !"".equals(defaultPassword)) { password = defaultPassword; } //判断是否开启了【禁止弱密码保存】 String weakPasswordDisable = Util.null2s(settings.getWeakPasswordDisable(), "0"); - if (weakPasswordDisable.equals("1")) { - if (!password.equals("")) {//密码为空的情况 + if ("1".equals(weakPasswordDisable)) { + if (!"".equals(password)) {//密码为空的情况 //判断是否为弱密码 HrmWeakPasswordUtil hrmWeakPasswordUtil = new HrmWeakPasswordUtil(); if (hrmWeakPasswordUtil.isWeakPsd(password)) { @@ -186,8 +186,10 @@ public class ResourceSyncUtil { String workstartdate = Util.null2String(params.get("workstartdate"));//参加工作日期 String companystartdate = Util.null2String(params.get("companystartdate"));//入职日期 String dsporder = Util.fromScreen3(Util.null2String(params.get("dsporder")), user.getLanguage()); - if (dsporder.length() == 0) dsporder = "" + id; - if (accounttype.equals("0")) { + if (dsporder.length() == 0) { + dsporder = "" + id; + } + if ("0".equals(accounttype)) { String encrptPassword = ""; String salt = ""; @@ -224,8 +226,8 @@ public class ResourceSyncUtil { //OA与第三方接口单条数据同步方法结束 //BBS集成相关 String bbsLingUrl = new weaver.general.BaseBean().getPropValue(GCONST.getConfigFile(), "ecologybbs.linkUrl"); - if (!password.equals("0")) { - if (!bbsLingUrl.equals("")) { + if (!"0".equals(password)) { + if (!"".equals(bbsLingUrl)) { new Thread(new weaver.bbs.BBSRunnable(loginid, password)).start(); } } @@ -283,7 +285,9 @@ public class ResourceSyncUtil { String dsporder = Util.fromScreen3(Util.null2String(params.get("dsporder")), user.getLanguage()); String accounttype = Util.fromScreen3(Util.null2String(params.get("accounttype")), user.getLanguage()); String systemlanguage = Util.null2String(params.get("systemlanguage")); - if (systemlanguage.equals("") || systemlanguage.equals("0")) systemlanguage = "7"; + if ("".equals(systemlanguage) || "0".equals(systemlanguage)) { + systemlanguage = "7"; + } String belongto = Util.fromScreen3(Util.null2String(params.get("belongto")), user.getLanguage()); //应聘人员id String rcid = Util.null2String(params.get("rcId")); @@ -305,8 +309,10 @@ public class ResourceSyncUtil { } - if (dsporder.length() == 0) dsporder = id; - if (accounttype.equals("0")) { + if (dsporder.length() == 0) { + dsporder = id; + } + if ("0".equals(accounttype)) { belongto = "-1"; } String departmentvirtualids = Util.null2String(params.get("departmentvirtualids"));//虚拟部门id; @@ -314,12 +320,12 @@ public class ResourceSyncUtil { //Td9325,解决多账号次账号没有登陆Id在浏览框组织结构中无法显示的问题。 boolean falg = false; String loginid = ""; - if (accounttype.equals("1")) { + if ("1".equals(accounttype)) { rs.execute("select loginid from HrmResource where id =" + belongto); if (rs.next()) { loginid = rs.getString("loginid"); } - if (!loginid.equals("")) { + if (!"".equals(loginid)) { String maxidsql = "select max(id) as id from HrmResource where loginid like '" + loginid + "%'"; rs.execute(maxidsql); if (rs.next()) { @@ -356,8 +362,12 @@ public class ResourceSyncUtil { while (rs.next()) { String tmp_managerstr = rs.getString("managerstr"); //处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 begin - if (!tmp_managerstr.startsWith(",")) tmp_managerstr = "," + tmp_managerstr; - if (!tmp_managerstr.endsWith(",")) tmp_managerstr = tmp_managerstr + ","; + if (!tmp_managerstr.startsWith(",")) { + tmp_managerstr = "," + tmp_managerstr; + } + if (!tmp_managerstr.endsWith(",")) { + tmp_managerstr = tmp_managerstr + ","; + } //处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 end managerstr += tmp_managerstr; managerstr = "," + managerid + managerstr; @@ -368,24 +378,44 @@ public class ResourceSyncUtil { RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); try { - if (resourceimageid.length() == 0) resourceimageid = "null"; - if (costcenterid.length() == 0) costcenterid = "null"; - if (managerid.length() == 0) managerid = "null"; - if (assistantid.length() == 0) assistantid = "null"; - if (accounttype.length() == 0) accounttype = "null"; - if (belongto.length() == 0) belongto = "null"; - if (jobcall.length() == 0) jobcall = "null"; - if (mobileshowtype.length() == 0) mobileshowtype = "null"; - if (rst.getDBType().equalsIgnoreCase("postgresql")) { - if (joblevel.length() == 0) joblevel = null; - if (dsporder.length() == 0) dsporder = null; + if (resourceimageid.length() == 0) { + resourceimageid = "null"; + } + if (costcenterid.length() == 0) { + costcenterid = "null"; + } + if (managerid.length() == 0) { + managerid = "null"; + } + if (assistantid.length() == 0) { + assistantid = "null"; + } + if (accounttype.length() == 0) { + accounttype = "null"; + } + if (belongto.length() == 0) { + belongto = "null"; + } + if (jobcall.length() == 0) { + jobcall = "null"; + } + if (mobileshowtype.length() == 0) { + mobileshowtype = "null"; + } + if ("postgresql".equalsIgnoreCase(rst.getDBType())) { + if (joblevel.length() == 0) { + joblevel = null; + } + if (dsporder.length() == 0) { + dsporder = null; + } } workcode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, subcmpanyid1, departmentid, jobtitle, workcode); - para = new StringBuilder("" + id + separator + workcode + separator + lastname + separator + sex + separator + resourceimageid + separator + - departmentid + separator + costcenterid + separator + jobtitle + separator + joblevel + separator + jobactivitydesc + separator + - managerid + separator + assistantid + separator + status + separator + locationid + separator + workroom + separator + telephone + - separator + mobile + separator + mobilecall + separator + fax + separator + jobcall + separator + subcmpanyid1 + separator + managerstr + - separator + accounttype + separator + belongto + separator + systemlanguage + separator + email + separator + dsporder + separator + mobileshowtype); + para = new StringBuilder("" + id + SEPARATOR + workcode + SEPARATOR + lastname + SEPARATOR + sex + SEPARATOR + resourceimageid + SEPARATOR + + departmentid + SEPARATOR + costcenterid + SEPARATOR + jobtitle + SEPARATOR + joblevel + SEPARATOR + jobactivitydesc + SEPARATOR + + managerid + SEPARATOR + assistantid + SEPARATOR + status + SEPARATOR + locationid + SEPARATOR + workroom + SEPARATOR + telephone + + SEPARATOR + mobile + SEPARATOR + mobilecall + SEPARATOR + fax + SEPARATOR + jobcall + SEPARATOR + subcmpanyid1 + SEPARATOR + managerstr + + SEPARATOR + accounttype + SEPARATOR + belongto + SEPARATOR + systemlanguage + SEPARATOR + email + SEPARATOR + dsporder + SEPARATOR + mobileshowtype); rst.executeProc("HrmResourceBasicInfo_Insert", para.toString()); if (Util.null2String(locationid).length() > 0) { @@ -416,19 +446,21 @@ public class ResourceSyncUtil { } } int userid = user.getUID(); - String userpara = "" + userid + separator + today; + String userpara = "" + userid + SEPARATOR + TODAY; para = new StringBuilder("" + id); for (int i = 0; i < 5; i++) { int idx = i; - if (formdefined) idx++; + if (formdefined) { + idx++; + } String datefield = Util.null2String(params.get("datefield" + idx)); String numberfield = "" + Util.getDoubleValue(Util.null2String(params.get("numberfield" + idx)), 0); String textfield = Util.null2String(params.get("textfield" + idx)); String tinyintfield = "" + Util.getIntValue(Util.null2String(params.get("tinyintfield" + idx)), 0); - para.append(separator).append(datefield).append(separator).append(numberfield).append(separator).append(textfield).append(separator).append(tinyintfield); + para.append(SEPARATOR).append(datefield).append(SEPARATOR).append(numberfield).append(SEPARATOR).append(textfield).append(SEPARATOR).append(tinyintfield); } rs.executeProc("HrmResourceDefine_Update", para.toString()); - rs.executeProc("HrmResource_CreateInfo", "" + id + separator + userpara + separator + userpara); + rs.executeProc("HrmResource_CreateInfo", "" + id + SEPARATOR + userpara + SEPARATOR + userpara); //421944 用户自定义隐私设置 @@ -443,7 +475,7 @@ public class ResourceSyncUtil { for (Map.Entry me : mapShowSets.entrySet()) { String fieldName = me.getKey(); String fieldVal = Util.null2String(mapShowSets.get(fieldName)); - if (fieldVal.equals("1")) { + if ("1".equals(fieldVal)) { String tmpPK = id + "__" + fieldName; String tmpPvalue = Util.null2String(params.get(fieldName + "showtype")); insertSql = "insert into userprivacysetting (combinedid,userid,ptype,pvalue) values('" + tmpPK + "','" + id + "','" + fieldName + "','" + tmpPvalue + "')"; @@ -460,7 +492,7 @@ public class ResourceSyncUtil { ResourceComInfo.addResourceInfoCache(id); SalaryManager.initResourceSalary(id); - para = new StringBuilder("" + id + separator + managerid + separator + departmentid + separator + subcmpanyid1 + separator + "0" + separator + managerstr); + para = new StringBuilder("" + id + SEPARATOR + managerid + SEPARATOR + departmentid + SEPARATOR + subcmpanyid1 + SEPARATOR + "0" + SEPARATOR + managerstr); rs.executeProc("HrmResource_Trigger_Insert", para.toString()); String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + id + ")"); @@ -483,7 +515,7 @@ public class ResourceSyncUtil { Subject += ":" + lastname; //modifier by lvyi 2013-12-31 - if (settings.getEntervalid().equals("1")) {//入职提醒 + if ("1".equals(settings.getEntervalid())) {//入职提醒 String thesql = "select hrmids from HrmInfoMaintenance where id<4 or id = 10"; rs.execute(thesql); StringBuilder members = new StringBuilder(); @@ -493,14 +525,14 @@ public class ResourceSyncUtil { members.append(",").append(rs.getString("hrmids")); } } - if (!members.toString().equals("")) { + if (!"".equals(members.toString())) { members = new StringBuilder(members.substring(1)); members = new StringBuilder(new HrmResourceBaseService().duplicateRemoval(members.toString(), user.getUID() + "")); SWFAccepter = members.toString(); SWFTitle = SystemEnv.getHtmlLabelName(15670, user.getLanguage()); SWFTitle += ":" + lastname; SWFTitle += "-" + CurrentUserName; - SWFTitle += "-" + today; + SWFTitle += "-" + TODAY; SWFRemark = "" + Util.fromScreen2(Subject, user.getLanguage()) + ""; SWFSubmiter = CurrentUser; SysRemindWorkflow.setPrjSysRemind(SWFTitle, 0, Util.getIntValue(SWFSubmiter), SWFAccepter, SWFRemark); @@ -531,15 +563,19 @@ public class ResourceSyncUtil { String healthinfo = Util.null2String(rs.getString("healthinfo")); String height = Util.null2String(rs.getString("height")); - if (height.contains(".")) height = height.substring(0, height.indexOf(".")); + if (height.contains(".")) { + height = height.substring(0, height.indexOf(".")); + } String weight = Util.null2String(rs.getString("weight")); - if (weight.contains(".")) weight = weight.substring(0, weight.indexOf(".")); + if (weight.contains(".")) { + weight = weight.substring(0, weight.indexOf(".")); + } String residentplace = Util.null2String(rs.getString("residentplace")); String homeaddress = Util.null2String(rs.getString("homeaddress")); String tempresidentnumber = Util.null2String(rs.getString("tempresidentnumber")); - para = new StringBuilder("" + id + separator + birthday + separator + folk + separator + nativeplace + separator + regresidentplace + separator + maritalstatus + separator + policy + separator + bememberdate + separator + bepartydate + separator + islabouunion + separator + educationlevel + separator + degree + separator + healthinfo + separator + height + separator + weight + separator + residentplace + separator + homeaddress + separator + tempresidentnumber + separator + certificatenum); + para = new StringBuilder("" + id + SEPARATOR + birthday + SEPARATOR + folk + SEPARATOR + nativeplace + SEPARATOR + regresidentplace + SEPARATOR + maritalstatus + SEPARATOR + policy + SEPARATOR + bememberdate + SEPARATOR + bepartydate + SEPARATOR + islabouunion + SEPARATOR + educationlevel + SEPARATOR + degree + SEPARATOR + healthinfo + SEPARATOR + height + SEPARATOR + weight + SEPARATOR + residentplace + SEPARATOR + homeaddress + SEPARATOR + tempresidentnumber + SEPARATOR + certificatenum); RecordSet rs1 = new RecordSet(); rs1.executeProc("HrmResourcePersonalInfo_Insert", para.toString()); } @@ -555,7 +591,9 @@ public class ResourceSyncUtil { rs.execute(" select count(*) from HrmResourceVirtual where departmentid ='" + s + "' and resourceid = " + id); if (rs.next()) { //如果已存在 无需处理 - if (rs.getInt(1) > 0) continue; + if (rs.getInt(1) > 0) { + continue; + } } //写入 @@ -630,7 +668,9 @@ public class ResourceSyncUtil { resourceimageid = ServiceUtil.saveResourceImage(resourceimageBase64); } String oldresourceimageid = Util.null2String(params.get("oldresourceimage")); - if (resourceimageid.equals("")) resourceimageid = oldresourceimageid; + if ("".equals(resourceimageid)) { + resourceimageid = oldresourceimageid; + } String departmentid = Util.fromScreen3(Util.null2String(params.get("departmentid")), user.getLanguage()); String costcenterid = Util.fromScreen3(Util.null2String(params.get("costcenterid")), user.getLanguage()); String jobtitle = Util.fromScreen3(Util.null2String(params.get("jobtitle")), user.getLanguage()); @@ -650,13 +690,15 @@ public class ResourceSyncUtil { String dsporder = Util.fromScreen3(Util.null2String(params.get("dsporder")), user.getLanguage()); String jobcall = Util.fromScreen3(Util.null2String(params.get("jobcall")), user.getLanguage()); String systemlanguage = Util.fromScreen3(Util.null2String(params.get("systemlanguage")), user.getLanguage()); - if (systemlanguage.equals("") || systemlanguage.equals("0")) { + if ("".equals(systemlanguage) || "0".equals(systemlanguage)) { systemlanguage = "7"; } String accounttype = Util.fromScreen3(Util.null2String(params.get("accounttype")), user.getLanguage()); String belongto = Util.fromScreen3(Util.null2String(params.get("belongto")), user.getLanguage()); - if (dsporder.length() == 0) dsporder = id; - if (accounttype.equals("0")) { + if (dsporder.length() == 0) { + dsporder = id; + } + if ("0".equals(accounttype)) { belongto = "-1"; } @@ -707,18 +749,18 @@ public class ResourceSyncUtil { } String thisAccounttype = rs.getString("accounttype"); - if (thisAccounttype.equals("1") && accounttype.equals("0")) { + if ("1".equals(thisAccounttype) && "0".equals(accounttype)) { oldbelongto = rs.getString("belongto"); } } - if (accounttype.equals("1") && loginid.equalsIgnoreCase("")) { + if ("1".equals(accounttype) && "".equalsIgnoreCase(loginid)) { rs.execute("select loginid from HrmResource where id =" + belongto); if (rs.next()) { loginid = rs.getString(1); } - if (!loginid.equals("")) { + if (!"".equals(loginid)) { loginid = loginid + (id + 1); falg = true; } @@ -731,29 +773,49 @@ public class ResourceSyncUtil { oldmanagerid = rs.getString("managerid"); oldmanagerstr = rs.getString("managerstr"); // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 begin - if (!oldmanagerstr.startsWith(",")) oldmanagerstr = "," + oldmanagerstr; - if (!oldmanagerstr.endsWith(",")) oldmanagerstr = oldmanagerstr + ","; + if (!oldmanagerstr.startsWith(",")) { + oldmanagerstr = "," + oldmanagerstr; + } + if (!oldmanagerstr.endsWith(",")) { + oldmanagerstr = oldmanagerstr + ","; + } // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 end } //mysql报错问题java.sql.SQLException: Incorrect integer value: '' for column 'COSTCENTERID' at row 1 - if(resourceimageid.length()==0)resourceimageid="null"; - if(costcenterid.length()==0)costcenterid="null"; - if(managerid.length()==0)managerid="null"; - if(assistantid.length()==0)assistantid="null"; - if(accounttype.length()==0)accounttype="null"; - if(belongto.length()==0)belongto="null"; - if(jobcall.length()==0)jobcall="null"; - if(mobileshowtype.length()==0)mobileshowtype="null"; + if(resourceimageid.length()==0) { + resourceimageid="null"; + } + if(costcenterid.length()==0) { + costcenterid="null"; + } + if(managerid.length()==0) { + managerid="null"; + } + if(assistantid.length()==0) { + assistantid="null"; + } + if(accounttype.length()==0) { + accounttype="null"; + } + if(belongto.length()==0) { + belongto="null"; + } + if(jobcall.length()==0) { + jobcall="null"; + } + if(mobileshowtype.length()==0) { + mobileshowtype="null"; + } if (StringUtils.isNotEmpty(workcode)) { CodeRuleManager.getCodeRuleManager().checkReservedIfDel(RuleCodeType.USER.getValue(), workcode); } - para = new StringBuilder("" + id + separator + workcode + separator + lastname + separator + sex + separator + resourceimageid - + separator + departmentid + separator + costcenterid + separator + jobtitle + separator + joblevel - + separator + jobactivitydesc + separator + managerid + separator + assistantid + separator + status - + separator + locationid + separator + workroom + separator + telephone + separator + mobile - + separator + mobilecall + separator + fax + separator + jobcall + separator + systemlanguage - + separator + accounttype + separator + belongto + separator + email + separator + dsporder + separator + mobileshowtype); + para = new StringBuilder("" + id + SEPARATOR + workcode + SEPARATOR + lastname + SEPARATOR + sex + SEPARATOR + resourceimageid + + SEPARATOR + departmentid + SEPARATOR + costcenterid + SEPARATOR + jobtitle + SEPARATOR + joblevel + + SEPARATOR + jobactivitydesc + SEPARATOR + managerid + SEPARATOR + assistantid + SEPARATOR + status + + SEPARATOR + locationid + SEPARATOR + workroom + SEPARATOR + telephone + SEPARATOR + mobile + + SEPARATOR + mobilecall + SEPARATOR + fax + SEPARATOR + jobcall + SEPARATOR + systemlanguage + + SEPARATOR + accounttype + SEPARATOR + belongto + SEPARATOR + email + SEPARATOR + dsporder + SEPARATOR + mobileshowtype); RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); try { @@ -792,7 +854,7 @@ public class ResourceSyncUtil { for (Map.Entry me : mapShowSets.entrySet()) { String fieldName = me.getKey(); String fieldVal = Util.null2String(mapShowSets.get(fieldName)); - if (fieldVal.equals("1")) { + if ("1".equals(fieldVal)) { String tmpPK = id + "__" + fieldName; String tmpPvalue = Util.null2String(params.get(fieldName + "showtype")); insertSql = "insert into userprivacysetting (combinedid,userid,ptype,pvalue) values('" + tmpPK + "','" + id + "','" + fieldName + "','" + tmpPvalue + "')"; @@ -805,8 +867,8 @@ public class ResourceSyncUtil { } int userid = user.getUID(); - String userpara = "" + userid + separator + today; - rs.executeProc("HrmResource_ModInfo", "" + id + separator + userpara); + String userpara = "" + userid + SEPARATOR + TODAY; + rs.executeProc("HrmResource_ModInfo", "" + id + SEPARATOR + userpara); String managerstr = ""; if (!id.equals(managerid)) { sql = "select managerstr from HrmResource where id = " + Util.getIntValue(managerid); @@ -814,8 +876,12 @@ public class ResourceSyncUtil { while (rs.next()) { managerstr = rs.getString("managerstr"); // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 begin - if (!managerstr.startsWith(",")) managerstr = "," + managerstr; - if (!managerstr.endsWith(",")) managerstr = managerstr + ","; + if (!managerstr.startsWith(",")) { + managerstr = "," + managerstr; + } + if (!managerstr.endsWith(",")) { + managerstr = managerstr + ","; + } // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 end managerstr = "," + managerid + managerstr; managerstr = managerstr.endsWith(",") ? managerstr : (managerstr + ","); @@ -827,7 +893,7 @@ public class ResourceSyncUtil { rst = new RecordSetTrans(); rst.setAutoCommit(false); try { - para = new StringBuilder("" + id + separator + managerstr); + para = new StringBuilder("" + id + SEPARATOR + managerstr); rst.executeProc("HrmResource_UpdateManagerStr", para.toString()); rst.commit(); } catch (Exception e) { @@ -845,13 +911,18 @@ public class ResourceSyncUtil { while (rs.next()) { String nowmanagerstr = Util.null2String(rs.getString("managerstr")); // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 begin - if (!nowmanagerstr.startsWith(",")) nowmanagerstr = "," + nowmanagerstr; - if (!nowmanagerstr.endsWith(",")) nowmanagerstr = nowmanagerstr + ","; + if (!nowmanagerstr.startsWith(",")) { + nowmanagerstr = "," + nowmanagerstr; + } + if (!nowmanagerstr.endsWith(",")) { + nowmanagerstr = nowmanagerstr + ","; + } // 处理managerstr 不以逗号开始或者结束的情况 形如 managerstr:8 end String resourceid = rs.getString("id"); //指定上级为自身的情况,不更新自身上级 - if (id.equals(resourceid)) + if (id.equals(resourceid)) { continue; + } String nowmanagerstr2 = ""; int index = nowmanagerstr.lastIndexOf(oldmanagerstr); if (index != -1) { @@ -864,7 +935,7 @@ public class ResourceSyncUtil { rst = new RecordSetTrans(); rst.setAutoCommit(false); try { - para = new StringBuilder(resourceid + separator + nowmanagerstr2); + para = new StringBuilder(resourceid + SEPARATOR + nowmanagerstr2); rst.executeProc("HrmResource_UpdateManagerStr", para.toString()); rst.commit(); ResourceComInfo.updateResourceInfoCache(resourceid); //更新缓存 @@ -876,7 +947,7 @@ public class ResourceSyncUtil { } String subcmpanyid1 = DepartmentComInfo.getSubcompanyid1(departmentid); - para = new StringBuilder("" + id + separator + subcmpanyid1); + para = new StringBuilder("" + id + SEPARATOR + subcmpanyid1); rst = new RecordSetTrans(); rst.setAutoCommit(false); try { @@ -902,12 +973,14 @@ public class ResourceSyncUtil { para = new StringBuilder("" + id); for (int i = 0; i < 5; i++) { int idx = i; - if (formdefined) idx++; + if (formdefined) { + idx++; + } String datefield = Util.null2String(params.get("datefield" + idx)); String numberfield = "" + Util.getDoubleValue(Util.null2String(params.get("numberfield" + idx)), 0); String textfield = Util.null2String(params.get("textfield" + idx)); String tinyintfield = "" + Util.getIntValue(Util.null2String(params.get("tinyintfield" + idx)), 0); - para.append(separator).append(datefield).append(separator).append(numberfield).append(separator).append(textfield).append(separator).append(tinyintfield); + para.append(SEPARATOR).append(datefield).append(SEPARATOR).append(numberfield).append(SEPARATOR).append(textfield).append(SEPARATOR).append(tinyintfield); } rs.executeProc("HrmResourceDefine_Update", para.toString()); @@ -926,10 +999,10 @@ public class ResourceSyncUtil { //处理次账号修改为主账号时,检查次账号所属 主账号的 其他设置是否需要修改 add by kzw QC159888 try { - if (!oldbelongto.equals("")) { + if (!"".equals(oldbelongto)) { HrmUserSettingComInfo userSetting = new HrmUserSettingComInfo(); String belongtoshow = userSetting.getBelongtoshowByUserId(oldbelongto); - if (belongtoshow.equals("1")) { + if ("1".equals(belongtoshow)) { rs.execute("select id from hrmresource where belongto = " + oldbelongto); if (!rs.next()) { String setId = userSetting.getId(oldbelongto); @@ -984,52 +1057,15 @@ public class ResourceSyncUtil { // 先查询原有EC人员信息,再封装传参 Map convertParams = new HashMap<>(); String jclResourceId = Util.null2String(params.get("id")); - String ecResourceId = ""; - if(StringUtils.isNotBlank(jclResourceId)){ - ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(jclResourceId); - } // 更新人员时,初始化人员参数 - if(StringUtils.isNotBlank(ecResourceId)){ + if (StringUtils.isNotBlank(jclResourceId)) { RecordSet rs = new RecordSet(); - rs.execute("select * from hrmresource where id = '" + ecResourceId + "'"); - if(rs.next()){ - convertParams.put("id",rs.getString("id")); - convertParams.put("loginid",rs.getString("loginid")); - convertParams.put("accounttype",rs.getString("accounttype")); - convertParams.put("password",rs.getString("password")); - convertParams.put("seclevel",rs.getString("seclevel")); - convertParams.put("workstartdate",rs.getString("workstartdate")); - convertParams.put("companystartdate",rs.getString("companystartdate")); - convertParams.put("dsporder",rs.getString("dsporder")); - convertParams.put("workcode",rs.getString("workcode")); - convertParams.put("lastname",rs.getString("lastname")); - convertParams.put("sex",rs.getString("sex")); - convertParams.put("resourceimageid",rs.getString("resourceimageid")); - convertParams.put("joblevel",rs.getString("joblevel")); - convertParams.put("jobactivitydesc",rs.getString("jobactivitydesc")); - convertParams.put("managerid",rs.getString("managerid")); - convertParams.put("assistantid",rs.getString("assistantid")); - convertParams.put("status",rs.getString("status")); - convertParams.put("locationid",rs.getString("locationid")); - convertParams.put("workroom",rs.getString("workroom")); - convertParams.put("telephone",rs.getString("telephone")); - convertParams.put("mobile",rs.getString("mobile")); - convertParams.put("mobilecall",rs.getString("mobilecall")); - convertParams.put("fax",rs.getString("fax")); - convertParams.put("jobcall",rs.getString("jobcall")); - convertParams.put("email",rs.getString("email")); - convertParams.put("systemlanguage",rs.getString("systemlanguage")); - convertParams.put("belongto",rs.getString("belongto")); - - convertParams.put("mobileshowtype",rs.getString("mobileshowtype")); - convertParams.put("costcenterid",rs.getString("costcenterid")); - convertParams.put("cmd",rs.getString("cmd")); - convertParams.put("rcId",rs.getString("rcId")); - convertParams.put("departmentvirtualids",rs.getString("departmentvirtualids")); - // 更新EC人员用到参数 - convertParams.put("editcontact",rs.getString("editcontact")); - convertParams.put("resourceimageBase64",rs.getString("resourceimageBase64")); - convertParams.put("oldresourceimage",rs.getString("oldresourceimage")); + rs.execute("select * from hrmresource where id = '" + jclResourceId + "'"); + int colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + convertParams.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } } } diff --git a/src/com/engine/organization/util/response/ReturnResult.java b/src/com/engine/organization/util/response/ReturnResult.java index 53544000..c1b2db72 100644 --- a/src/com/engine/organization/util/response/ReturnResult.java +++ b/src/com/engine/organization/util/response/ReturnResult.java @@ -116,49 +116,6 @@ public class ReturnResult implements Serializable { return new ReturnResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data); } - /** - * 失败返回结果 - * - * @param errorCode - * @param - * @return - */ - public static ReturnResult failed(IErrorCode errorCode) { - return new ReturnResult<>(errorCode.getCode(), errorCode.getMessage(), null); - } - - /** - * 返回失败状态 - * - * @param msg - * @return - */ - public static ReturnResult failed(String msg) { - return failed(ResultCode.FAILED); - } - - - /** - * 参数验证失败 - * - * @param - * @return - */ - public static ReturnResult validateFailed() { - return failed(ResultCode.VALIDATE_FAILED); - } - - /** - * 参数验证失败,返回信息 - * - * @param msg - * @param - * @return - */ - public static ReturnResult validateFailed(String msg) { - return new ReturnResult<>(ResultCode.VALIDATE_FAILED.getCode(), msg); - } - /** * 异常处理 * @@ -171,27 +128,4 @@ public class ReturnResult implements Serializable { return new ReturnResult<>(ResultCode.FAILED.getCode(), e.getMessage()); } - /** - * 未登录返回结果 。 token过期.. - * - * @param data - * @param - * @return - */ - public static ReturnResult unauthorized(T data) { - return new ReturnResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data); - } - - /** - * 未授权返回结果 - * - * @param data - * @param - * @return - */ - public static ReturnResult forbiden(T data) { - return new ReturnResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data); - } - - } diff --git a/src/com/engine/organization/util/saveimport/CompanyImport.java b/src/com/engine/organization/util/saveimport/CompanyImport.java new file mode 100644 index 00000000..66b8854d --- /dev/null +++ b/src/com/engine/organization/util/saveimport/CompanyImport.java @@ -0,0 +1,295 @@ +package com.engine.organization.util.saveimport; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.hrm.util.face.hrmrestful.service.HrmFieldManagerForService; +import com.engine.organization.entity.fieldset.param.FieldTransferParam; +import com.engine.organization.entity.jclimport.po.HrmFormFieldPO; +import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; +import com.engine.organization.enums.HrmGroupEnum; +import com.engine.organization.enums.LogModuleNameEnum; +import com.engine.organization.enums.OperateTypeEnum; +import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.mapper.jclimport.ImportMapper; +import com.engine.organization.thread.OrganizationSyncEc; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author:dxfeng + * @createTime: 2022/12/01 + * @version: 1.0 + */ +public class CompanyImport { + + private static ImportMapper getImportMapper() { + return MapperProxyFactory.getProxy(ImportMapper.class); + } + + /** + * 导入模板可选择字段 + * + * @param user 当前用户 + * @param excludedFields 排除的字段 + */ + public static Map getImportFields(User user, List excludedFields) { + Map returnMaps = new HashMap<>(); + List importFields = getImportMapper().getImportFields(user.getLanguage(), HrmGroupEnum.COMPANY.getGroupType()); + importFields.removeIf(item -> excludedFields.contains(item.getFieldName())); + + // 查询所有可以勾选的字段 + List fieldDatas = importFields.stream().map(item -> FieldTransferParam.builder().id(item.getFieldId().toString()).name(item.getLabelName()).build()).collect(Collectors.toList()); + returnMaps.put("data", fieldDatas); + // 设置必填字段 + List selectedKeys = importFields.stream().filter(item -> null != item.getIsSystem() && 1 == item.getIsSystem() && 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList()); + returnMaps.put("selectedKeys", selectedKeys); + return returnMaps; + } + + /** + * 获取导入模板及导入提示信息 + * + * @param user 当前用户 + * @param templatePath 导入模板路径 + */ + public static List> importForm(User user, String templatePath) { + // 返回导入数据 + List> lsGroup = new ArrayList<>(); + Map groupItem = new HashMap<>(); + List itemList = new ArrayList<>(); + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + + SearchConditionItem searchConditionItem; + ConditionFactory conditionFactory = new ConditionFactory(user); + //导入类型 + List statusOptions = new ArrayList<>(); + statusOptions.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); + statusOptions.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions); + searchConditionItem.setValue("add"); + itemList.add(searchConditionItem); + + //模板文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); + searchConditionItem.setValue(templatePath); + itemList.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + lsGroup.add(groupItem); + + + itemList = new ArrayList<>(); + groupItem = new HashMap<>(); + groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + List lsPromptLabel = new ArrayList<>(); //提示信息 + lsPromptLabel.add(34275); + lsPromptLabel.add(125452); + lsPromptLabel.add(125466); + lsPromptLabel.add(522356); + lsPromptLabel.add(522357); + lsPromptLabel.add(530411); + + for (int i = 0; i < lsPromptLabel.size(); i++) { + Map item = new HashMap<>(); + item.put("index", (i + 1)); + String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); + if (i == 0) { + value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); + item.put("link", templatePath); + } + item.put("value", value); + itemList.add(item); + } + groupItem.put("items", itemList); + lsGroup.add(groupItem); + return lsGroup; + } + + /** + * @param operateType 导入类型 + * @param excelFile 上传的文件 + * @param user 当前用户 + */ + public static Long saveImport(String operateType, String excelFile, User user) { + Long importHistoryId = OrgImportUtil.saveImportLog("company", operateType, user); + JclImportHistoryDetailPO historyDetailPO; + + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(excelFile)); + XSSFWorkbook workbook; + try { + workbook = new XSSFWorkbook(manager.getInputStream()); + } catch (IOException e) { + throw new RuntimeException(e); + } + // 当前sheet + XSSFSheet sheetAt = workbook.getSheetAt(0); + int lastRow = sheetAt.getLastRowNum(); + List extendInfoPOS = new ArrayList<>(); + OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); + short lastCellNum = sheetAt.getRow(0).getLastCellNum(); + + + // 遍历每一行数据 + nextRow: + for (int i = 0; i <= lastRow; i++) { + historyDetailPO = new JclImportHistoryDetailPO(); + historyDetailPO.setPid(importHistoryId); + XSSFRow row = sheetAt.getRow(i); + if (null == row) { + continue; + } + // 组装待处理数据 + Map map = new HashMap<>(); + Integer parentCompanyId = null; + String companyName = ""; + + historyDetailPO.setRowNums(String.valueOf(i + 1)); + for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { + XSSFCell cell = row.getCell((short) cellIndex); + String cellValue = OrgImportUtil.getCellValue(cell).trim(); + if (i == 0) { + List infoPOList = getImportMapper().getImportFieldInfo(user.getLanguage(), HrmGroupEnum.COMPANY.getGroupType(), cellValue); + boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } + // 首行 初始化字段信息 + extendInfoPOS.add(infoPOList.get(0)); + } else { + HrmFormFieldPO infoPO = extendInfoPOS.get(cellIndex); + // 数据校验 + if (infoPO.getIsMand() == 1 && StringUtils.isBlank(cellValue) && !"subcompanycode".equalsIgnoreCase(infoPO.getFieldName())) { + historyDetailPO.setOperateDetail(infoPO.getLabelName() + "为必填项"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + + Object reallyValue; + try { + if ("subcompanyname".equalsIgnoreCase(infoPO.getFieldName())) { + reallyValue = cellValue; + } else if (StringUtils.isBlank(cellValue)) { + reallyValue = ""; + } else { + reallyValue = HrmFieldManagerForService.getReallyFieldvalue(infoPO.getJsonObject(cellValue), null != infoPO.getIsSystem() && 1 == infoPO.getIsSystem()); + } + } catch (Exception e) { + historyDetailPO.setOperateDetail(cellValue + "转换失败"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue))) { + historyDetailPO.setOperateDetail(infoPO.getLabelName() + "数据转换失败,未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + map.put(infoPO.getFieldName(), reallyValue); + if ("subcompanyname".equalsIgnoreCase(infoPO.getFieldName())) { + historyDetailPO.setRelatedName(cellValue); + String[] split = cellValue.split(">"); + if (split.length > 0) { + if (split.length > 8) { + historyDetailPO.setOperateDetail("分部层级不能大于10"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + for (int index = 0; index < split.length - 1; index++) { + parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId); + if (null == parentCompanyId) { + historyDetailPO.setOperateDetail(split[index] + "分部未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + } + } + map.put("supsubcomid", Util.null2String(parentCompanyId)); + + companyName = split[split.length - 1]; + map.put("subcompanyname", companyName); + map.put("subcompanydesc", companyName); + } + + } + } + // 校验、数据交互 + if (i == 0) { + continue; + } + + if ("add".equals(operateType)) { + Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map, false).sync(); + if (OrgImportUtil.isThrowError(syncMap)) { + // 刷新组织架构图 + //TODO new CompanyTriggerRunnable(infoParams.getId()).run(); + historyDetailPO.setOperateDetail("添加成功"); + historyDetailPO.setStatus("1"); + } else { + historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); + historyDetailPO.setStatus("0"); + } + OrgImportUtil.saveImportDetailLog(historyDetailPO); + } else if ("update".equals(operateType)) { + String compNo = (String) map.get("subcompanycode"); + // 查询对应ID + if (StringUtils.isNotBlank(compNo)) { + Integer companyId = MapperProxyFactory.getProxy(CompMapper.class).getIdBySubCompanyCode(compNo); + if (companyId == null) { + historyDetailPO.setOperateDetail("未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } + map.put("id", Util.null2String(companyId)); + Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map, false).sync(); + if (OrgImportUtil.isThrowError(syncMap)) { + // 刷新组织架构图 + //TODO new CompanyTriggerRunnable(companyId).run(); + historyDetailPO.setOperateDetail("更新成功"); + historyDetailPO.setStatus("1"); + } else { + historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); + historyDetailPO.setStatus("0"); + } + OrgImportUtil.saveImportDetailLog(historyDetailPO); + } else { + historyDetailPO.setOperateDetail("编号为空,更新失败"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + } + } + } + return importHistoryId; + } + +} diff --git a/src/com/engine/organization/util/saveimport/DepartmentImport.java b/src/com/engine/organization/util/saveimport/DepartmentImport.java new file mode 100644 index 00000000..6f05cd62 --- /dev/null +++ b/src/com/engine/organization/util/saveimport/DepartmentImport.java @@ -0,0 +1,333 @@ +package com.engine.organization.util.saveimport; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.hrm.util.face.hrmrestful.service.HrmFieldManagerForService; +import com.engine.organization.entity.fieldset.param.FieldTransferParam; +import com.engine.organization.entity.jclimport.po.HrmFormFieldPO; +import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; +import com.engine.organization.enums.HrmGroupEnum; +import com.engine.organization.enums.LogModuleNameEnum; +import com.engine.organization.enums.OperateTypeEnum; +import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.jclimport.ImportMapper; +import com.engine.organization.thread.OrganizationSyncEc; +import com.engine.organization.util.OrganizationAssert; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author:dxfeng + * @createTime: 2022/12/06 + * @version: 1.0 + */ +public class DepartmentImport { + + private static ImportMapper getImportMapper() { + return MapperProxyFactory.getProxy(ImportMapper.class); + } + + /** + * 导入模板可选择字段 + * + * @param user 当前用户 + * @param excludedFields 排除的字段 + */ + public static Map getImportFields(User user, List excludedFields) { + Map returnMaps = new HashMap<>(); + List importFields = getImportMapper().getImportFields(user.getLanguage(), HrmGroupEnum.DEPARTMENT.getGroupType()); + importFields.removeIf(item -> excludedFields.contains(item.getFieldName())); + + // 查询所有可以勾选的字段 + List fieldDatas = importFields.stream().map(item -> FieldTransferParam.builder().id(item.getFieldId().toString()).name(item.getLabelName()).build()).collect(Collectors.toList()); + returnMaps.put("data", fieldDatas); + // 设置必填字段 + List selectedKeys = importFields.stream().filter(item -> null != item.getIsSystem() && 1 == item.getIsSystem() && 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList()); + returnMaps.put("selectedKeys", selectedKeys); + return returnMaps; + } + + /** + * 获取导入模板及导入提示信息 + * + * @param user 当前用户 + * @param templatePath 导入模板路径 + */ + public static List> importForm(User user, String templatePath) { + + // 返回导入数据 + List> lsGroup = new ArrayList<>(); + Map groupItem = new HashMap<>(); + List itemList = new ArrayList<>(); + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + + SearchConditionItem searchConditionItem; + ConditionFactory conditionFactory = new ConditionFactory(user); + //导入类型 + List statusOptions = new ArrayList<>(); + statusOptions.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); + statusOptions.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions); + searchConditionItem.setValue("add"); + itemList.add(searchConditionItem); + + //模板文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); + searchConditionItem.setValue(templatePath); + itemList.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + lsGroup.add(groupItem); + + + itemList = new ArrayList<>(); + groupItem = new HashMap<>(); + groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + List lsPromptLabel = new ArrayList<>(); //提示信息 + lsPromptLabel.add(34275); + lsPromptLabel.add(125452); + lsPromptLabel.add(125466); + lsPromptLabel.add(522356); + lsPromptLabel.add(522357); + lsPromptLabel.add(530411); + + for (int i = 0; i < lsPromptLabel.size(); i++) { + Map item = new HashMap<>(); + item.put("index", (i + 1)); + String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); + if (i == 0) { + value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); + item.put("link", templatePath); + } + if (3 == i) { + value = value.replace("及显示顺序", ""); + } + item.put("value", value); + itemList.add(item); + } + groupItem.put("items", itemList); + lsGroup.add(groupItem); + return lsGroup; + } + + /** + * @param operateType 导入类型 + * @param excelFile 上传的文件 + * @param user 当前用户 + */ + public static Long saveImport(String operateType, String excelFile, User user) { + Long importHistoryId = OrgImportUtil.saveImportLog("department", operateType, user); + JclImportHistoryDetailPO historyDetailPO; + + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(excelFile)); + XSSFWorkbook workbook; + try { + workbook = new XSSFWorkbook(manager.getInputStream()); + } catch (IOException e) { + throw new RuntimeException(e); + } + // 当前sheet + XSSFSheet sheetAt = workbook.getSheetAt(0); + int lastRow = sheetAt.getLastRowNum(); + List extendInfoPOS = new ArrayList<>(); + OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); + short lastCellNum = sheetAt.getRow(0).getLastCellNum(); + + + // 遍历每一行数据 + nextRow: + for (int i = 0; i <= lastRow; i++) { + historyDetailPO = new JclImportHistoryDetailPO(); + historyDetailPO.setPid(importHistoryId); + XSSFRow row = sheetAt.getRow(i); + if (null == row) { + continue; + } + // 组装待处理数据 + Map map = new HashMap<>(); + Integer parentCompanyId = null; + Integer parentDepartmentId = null; + String departmentName = ""; + + historyDetailPO.setRowNums(String.valueOf(i + 1)); + for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) { + XSSFCell cell = row.getCell((short) cellIndex); + String cellValue = OrgImportUtil.getCellValue(cell).trim(); + if (i == 0) { + // 首行 初始化字段信息 + List infoPOList = getImportMapper().getImportFieldInfo(user.getLanguage(), HrmGroupEnum.DEPARTMENT.getGroupType(), cellValue); + boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } + extendInfoPOS.add(infoPOList.get(0)); + } else { + HrmFormFieldPO infoPO = extendInfoPOS.get(cellIndex); + + // 数据校验 + if (infoPO.getIsMand() == 1 && StringUtils.isBlank(cellValue) && !"departmentcode".equalsIgnoreCase(infoPO.getFieldName())) { + historyDetailPO.setOperateDetail(infoPO.getLabelName() + "为必填项"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + // 人员导入校验 + if ("3".equals(infoPO.getFieldHtmlType()) && ("1".equals(infoPO.getType()) || "17".equals(infoPO.getType())) && OrgImportUtil.hasSameName(historyDetailPO, cellValue)) { + continue nextRow; + } + + Object reallyValue; + try { + if ("departmentmark".equalsIgnoreCase(infoPO.getFieldName()) || "subcompanyid1".equalsIgnoreCase(infoPO.getFieldName())) { + reallyValue = cellValue; + } else if (StringUtils.isBlank(cellValue)) { + reallyValue = ""; + } else { + reallyValue = HrmFieldManagerForService.getReallyFieldvalue(infoPO.getJsonObject(cellValue), null != infoPO.getIsSystem() && 1 == infoPO.getIsSystem()); + } + } catch (Exception e) { + historyDetailPO.setOperateDetail(cellValue + "转换失败"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue))) { + historyDetailPO.setOperateDetail(infoPO.getLabelName() + "数据转换失败,未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + map.put(infoPO.getFieldName(), reallyValue); + // 上级分部 + if ("subcompanyid1".equals(infoPO.getFieldName())) { + String[] split = cellValue.split(">"); + if (split.length > 0) { + if (split.length > 8) { + historyDetailPO.setOperateDetail("分部层级不能大于10"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + for (String s : split) { + parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId); + if (null == parentCompanyId) { + historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + } + } + } + + if ("departmentmark".equals(infoPO.getFieldName())) { + if (null == parentCompanyId) { + historyDetailPO.setOperateDetail(cellValue + "所属分部未找到"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + historyDetailPO.setRelatedName(cellValue); + String[] split = cellValue.split(">"); + if (split.length > 0) { + if (split.length > 8) { + historyDetailPO.setOperateDetail("部门层级不能大于10"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + for (int index = 0; index < split.length - 1; index++) { + parentDepartmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(split[index], parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); + if (null == parentDepartmentId) { + historyDetailPO.setOperateDetail(split[index] + "部门未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue nextRow; + } + } + } + map.put("subcompanyid1", Util.null2String(parentCompanyId)); + map.put("supdepid", Util.null2String(parentDepartmentId)); + + departmentName = split[split.length - 1]; + map.put("departmentmark", departmentName); + map.put("departmentname", departmentName); + } + } + } + // 校验、数据交互 + if (i == 0) { + continue; + } + if ("add".equals(operateType)) { + Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map, false).sync(); + if (OrgImportUtil.isThrowError(syncMap)) { + // 查询UUID + historyDetailPO.setOperateDetail("添加成功"); + historyDetailPO.setStatus("1"); + } else { + historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); + historyDetailPO.setStatus("0"); + } + OrgImportUtil.saveImportDetailLog(historyDetailPO); + } else if ("update".equals(operateType)) { + String deptNo = (String) map.get("departmentcode"); + // 查询对应ID + if (StringUtils.isNotBlank(deptNo)) { + String departmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByDepartmentCode(deptNo); + if (departmentId == null) { + historyDetailPO.setOperateDetail("未找到对应数据"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + continue; + } + map.put("id", departmentId); + Map syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map, false).sync(); + if (OrgImportUtil.isThrowError(syncMap)) { + // 刷新组织架构图 + //TODO new DepartmentTriggerRunnable(departmentId).run(); + historyDetailPO.setOperateDetail("更新成功"); + historyDetailPO.setStatus("1"); + } else { + historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message"))); + historyDetailPO.setStatus("0"); + } + OrgImportUtil.saveImportDetailLog(historyDetailPO); + + } else { + historyDetailPO.setOperateDetail("编号为空,更新失败"); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + } + } + } + return importHistoryId; + } + +} diff --git a/src/com/engine/organization/util/saveimport/OrgImportUtil.java b/src/com/engine/organization/util/saveimport/OrgImportUtil.java index cfda1908..c13bbcf3 100644 --- a/src/com/engine/organization/util/saveimport/OrgImportUtil.java +++ b/src/com/engine/organization/util/saveimport/OrgImportUtil.java @@ -7,10 +7,14 @@ import com.engine.organization.entity.SelectOptionParam; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryPO; +import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryMapper; +import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.validator.GenericValidator; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.xssf.usermodel.XSSFCell; import weaver.common.DateUtil; @@ -18,6 +22,7 @@ import weaver.general.Util; import weaver.hrm.User; import weaver.hrm.definedfield.HrmFieldManager; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; @@ -30,17 +35,35 @@ import java.util.stream.Collectors; */ public class OrgImportUtil { + /** + * 插入导入日志信息 + * + * @param importType + * @param operateType + * @param user + * @return + */ public static Long saveImportLog(String importType, String operateType, User user) { JclImportHistoryPO historyPO = JclImportHistoryPO.builder().operator((long) user.getUID()).operateTime(DateUtil.getFullDate()).clientAddress(user.getLoginip()).importType(importType).sourceFrom("excel").operateType(operateType).status("importing").build(); MapperProxyFactory.getProxy(JclImportHistoryMapper.class).insertHistory(historyPO); return historyPO.getId(); } + /** + * 插入导入日志详细信息 + * + * @param historyDetailPO + */ public static void saveImportDetailLog(JclImportHistoryDetailPO historyDetailPO) { - String detailMsg = "导入第" + historyDetailPO.getRowNums() + "行数据," + historyDetailPO.getRelatedName() + historyDetailPO.getOperateDetail(); + String relatedName = ""; + if (StringUtils.isNotBlank(historyDetailPO.getRelatedName())) { + relatedName = "[" + historyDetailPO.getRelatedName() + "]"; + } + String detailMsg = "导入第" + historyDetailPO.getRowNums() + "行数据," + relatedName + historyDetailPO.getOperateDetail(); historyDetailPO.setOperateDetail(detailMsg); MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(historyDetailPO); } + /** * 转换存入数据库的值 */ @@ -59,7 +82,11 @@ public class OrgImportUtil { } else if ("float".equals(valueType)) { object = Float.parseFloat(cellValue); } else { - object = cellValue; + try { + object = new BigDecimal(cellValue).toPlainString(); + } catch (NumberFormatException ignore) { + object = cellValue; + } } break; case 3: @@ -75,6 +102,10 @@ public class OrgImportUtil { } jsonObject.put("fieldid", 0); object = HrmFieldManager.getReallyFieldvalue(jsonObject); + // 如果是日期,校验日期的合法性 + if ("2".equals(extendInfo.getBrowserType())) { + OrganizationAssert.isTrue(GenericValidator.isDate(Util.null2String(object), "yyyy-MM-dd", true), Util.null2String(object) + "日期转换失败"); + } break; case 5: // SELECT @@ -97,10 +128,17 @@ public class OrgImportUtil { return object; } + /** + * 读取表格中的内容 + * + * @param cell + * @return + */ public static String getCellValue(XSSFCell cell) { String cellValue = ""; - if (cell == null) + if (cell == null) { return ""; + } switch (cell.getCellType()) { case BOOLEAN: // 得到Boolean对象的方法 cellValue = String.valueOf(cell.getBooleanCellValue()); @@ -111,8 +149,9 @@ public class OrgImportUtil { cellValue = sft.format(cell.getDateCellValue()); // 读取日期格式 } else { cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 - if (cellValue.endsWith(".0")) + if (cellValue.endsWith(".0")) { cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } } break; case FORMULA: // 读取公式 @@ -125,4 +164,56 @@ public class OrgImportUtil { cellValue = Util.toHtmlForHrm(cellValue); return cellValue; } + + public static boolean isBreak(JclImportHistoryDetailPO historyDetailPO, String cellValue, List infoPOList) { + String operateDetail = ""; + if (CollectionUtils.isEmpty(infoPOList)) { + operateDetail = "[" + cellValue + "]未找到对应字段"; + } + if (infoPOList.size() > 1) { + operateDetail = "[" + cellValue + "]在表中定义多个,请修改后重新导入"; + } + if (StringUtils.isNotBlank(operateDetail)) { + historyDetailPO.setOperateDetail(operateDetail); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + return true; + } + return false; + } + + public static boolean isThrowError(Map resultMap) { + return "1".equals(Util.null2String(resultMap.get("status"))) || "1".equals(Util.null2String(resultMap.get("sign"))); + } + + /** + * 判断负责人是否有重名人员、若有重复人员、给出反馈信息。不处理该条数据 + * + * @param historyDetailPO + * @param cellValue + * @return + */ + public static boolean hasSameName(JclImportHistoryDetailPO historyDetailPO, String cellValue) { + String operateDetail = ""; + if (StringUtils.isBlank(cellValue)) { + return false; + } + String[] split = cellValue.split(","); + for (String s : split) { + List resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIdsByName(s); + if (CollectionUtils.isEmpty(resourceIds)) { + operateDetail = "[" + s + "]未找到对应人员"; + } + if (resourceIds.size() > 1) { + operateDetail = "[" + s + "]查询到多个人员"; + } + if (StringUtils.isNotBlank(operateDetail)) { + historyDetailPO.setOperateDetail(operateDetail); + historyDetailPO.setStatus("0"); + OrgImportUtil.saveImportDetailLog(historyDetailPO); + return true; + } + } + return false; + } } diff --git a/src/com/engine/organization/util/saveimport/PostInfoImportUtil.java b/src/com/engine/organization/util/saveimport/PostInfoImportUtil.java index df9d271d..1aaca042 100644 --- a/src/com/engine/organization/util/saveimport/PostInfoImportUtil.java +++ b/src/com/engine/organization/util/saveimport/PostInfoImportUtil.java @@ -4,7 +4,6 @@ import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; import com.engine.organization.entity.postion.po.PostInfoPO; import com.engine.organization.entity.postion.po.PostPO; -import com.engine.organization.entity.staff.po.StaffPlanPO; import com.engine.organization.mapper.post.PostInfoMapper; import com.engine.organization.mapper.post.PostMapper; import com.engine.organization.util.OrganizationAssert; @@ -56,7 +55,7 @@ public class PostInfoImportUtil { // 当前sheet XSSFSheet sheetAt = workbook.getSheetAt(0); int lastRow = sheetAt.getLastRowNum(); - OrganizationAssert.isTrue(lastRow > 0, "导入数据为空"); + OrganizationAssert.isTrue(lastRow > 0, "文件数据为空"); short lastCellNum = sheetAt.getRow(0).getLastCellNum(); List extendInfoPOS = new ArrayList<>(); Date currDate = new Date(); @@ -66,6 +65,9 @@ public class PostInfoImportUtil { historyDetailPO = new JclImportHistoryDetailPO(); historyDetailPO.setPid(importHistoryId); XSSFRow row = sheetAt.getRow(i); + if (null == row) { + continue; + } // 组装待处理数据 Map map = new HashMap<>(); PostInfoPO postInfoPO = null; @@ -85,6 +87,7 @@ public class PostInfoImportUtil { ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); // 数据校验 if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { + historyDetailPO.setRelatedName(""); historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); historyDetailPO.setStatus("0"); OrgImportUtil.saveImportDetailLog(historyDetailPO); diff --git a/src/com/engine/organization/util/saveimport/ResourceImport.java b/src/com/engine/organization/util/saveimport/ResourceImport.java new file mode 100644 index 00000000..cf61ed38 --- /dev/null +++ b/src/com/engine/organization/util/saveimport/ResourceImport.java @@ -0,0 +1,202 @@ +package com.engine.organization.util.saveimport; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.engine.organization.entity.fieldset.param.FieldTransferParam; +import com.engine.organization.entity.jclimport.po.HrmFormFieldPO; +import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; +import com.engine.organization.entity.personnelcard.po.CusTreeFormPO; +import com.engine.organization.exception.OrganizationRunTimeException; +import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper; +import com.engine.organization.mapper.personnelcard.PersonnelCardMapper; +import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.saveimport.hrmimport.HrmImportAdaptExcelE9; +import com.engine.organization.util.saveimport.hrmimport.HrmImportProcessE9; +import weaver.file.FileUploadToPath; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.definedfield.HrmFieldManager; +import weaver.join.hrm.in.HrmResourceVo; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author:dxfeng + * @createTime: 2022/12/07 + * @version: 1.0 + */ +public class ResourceImport { + + private static PersonnelCardMapper getPersonnelCardMapper() { + return MapperProxyFactory.getProxy(PersonnelCardMapper.class); + } + + /** + * 导入模板可选择字段 + * + * @param user 当前用户 + * @param excludedFields 排除的字段 + */ + public static Map getImportFields(User user, List excludedFields) { + + try { + List importFields = new ArrayList<>(); + List cusTreeForms = getPersonnelCardMapper().getCusTreeForms(0); + importFields.add(HrmFormFieldPO.builder().fieldName("subcompanyid1").labelName("分部").build()); + for (CusTreeFormPO cusTreeForm : cusTreeForms) { + HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", cusTreeForm.getId()); + hfm.getCustomFields(); + while (hfm.next()) { + String fieldName = hfm.getFieldname(); + if (-1 != cusTreeForm.getId()) { + fieldName = cusTreeForm.getId() + fieldName; + } + String fieldLabel = SystemEnv.getHtmlLabelNames(hfm.getLable(), user.getLanguage()); + importFields.add(HrmFormFieldPO.builder().fieldName(fieldName).labelName(fieldLabel).build()); + } + } + + Map returnMaps = new HashMap<>(); + importFields.removeIf(item -> excludedFields.contains(item.getFieldName())); + + // 查询所有可以勾选的字段 + List fieldDatas = importFields.stream().map(item -> FieldTransferParam.builder().id(item.getFieldName()).name(item.getLabelName()).build()).collect(Collectors.toList()); + returnMaps.put("data", fieldDatas); + + + // 设置必填字段 + List selectedKeys = new ArrayList<>(); + selectedKeys.add("subcompanyid1"); + selectedKeys.add("departmentid"); + selectedKeys.add("lastname"); + selectedKeys.add("jobtitle"); + selectedKeys.add("jobactivity"); + selectedKeys.add("jobGroupId"); + selectedKeys.add("locationid"); + returnMaps.put("selectedKeys", selectedKeys); + return returnMaps; + } catch (Exception e) { + new BaseBean().writeLog(e); + throw new OrganizationRunTimeException("人员导入字段生成异常"); + } + } + + /** + * 获取导入模板及导入提示信息 + * + * @param user 当前用户 + * @param templatePath 导入模板路径 + */ + public static List> importForm(User user, String templatePath) { + + // 返回导入数据 + List> lsGroup = new ArrayList<>(); + Map groupItem = new HashMap<>(); + List itemList = new ArrayList<>(); + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + + SearchConditionItem searchConditionItem; + ConditionFactory conditionFactory = new ConditionFactory(user); + + //重复验证字段 + List statusOptions = new ArrayList<>(); + statusOptions.add(new SearchConditionOption("lastname", SystemEnv.getHtmlLabelName(413, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("workcode", SystemEnv.getHtmlLabelName(714, user.getLanguage()), true)); + statusOptions.add(new SearchConditionOption("loginid", SystemEnv.getHtmlLabelName(412, user.getLanguage()))); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24638, "keyField", statusOptions); + searchConditionItem.setValue("lastname"); + itemList.add(searchConditionItem); + + //导入类型 + List statusOptions1 = new ArrayList<>(); + statusOptions1.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true)); + statusOptions1.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage()))); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions1); + searchConditionItem.setValue("add"); + itemList.add(searchConditionItem); + + //模板文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); + searchConditionItem.setValue(templatePath); + itemList.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + lsGroup.add(groupItem); + + + itemList = new ArrayList<>(); + groupItem = new HashMap<>(); + groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + List lsPromptLabel = new ArrayList<>(); //提示信息 + lsPromptLabel.add(128520); + lsPromptLabel.add(125868); + lsPromptLabel.add(128365); + //lsPromptLabel.add(81697); + //lsPromptLabel.add(81698); + lsPromptLabel.add(81699); + lsPromptLabel.add(516263); + //lsPromptLabel.add(81701); + //lsPromptLabel.add(388880); + lsPromptLabel.add(81702); + lsPromptLabel.add(81703); + lsPromptLabel.add(125869); + + for (int i = 0; i < lsPromptLabel.size(); i++) { + Map item = new HashMap<>(); + item.put("index", (i + 1)); + String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage()); + if (i == 0) { + value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); + item.put("link", templatePath); + } + item.put("value", value); + itemList.add(item); + } + groupItem.put("items", itemList); + lsGroup.add(groupItem); + return lsGroup; + } + + /** + * @param operateType 导入类型 + * @param excelFile 上传的文件 + * @param user 当前用户 + */ + public static Long saveImport(String operateType, String excelFile, User user, HttpServletRequest request) { + Long importHistoryId = OrgImportUtil.saveImportLog("resource", operateType, user); + HrmImportAdaptExcelE9 importAdapt = new HrmImportAdaptExcelE9(); + FileUploadToPath fu = new FileUploadToPath(request); + + List errorInfo = importAdapt.creatImportMap(fu); + + //如果读取数据和验证模板没有发生错误 + if (errorInfo.isEmpty()) { + Map hrMap = importAdapt.getHrmImportMap(); + HrmImportProcessE9 importProcess = new HrmImportProcessE9(); + importProcess.init(request, importHistoryId); + importProcess.processMap(hrMap); + } else { + for (String s : errorInfo) { + MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid(importHistoryId).operateDetail(Util.null2String(s)).status("0").build()); + } + } + return importHistoryId; + } + +} diff --git a/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java b/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java index 7515af01..4fc78a89 100644 --- a/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java +++ b/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java @@ -2,8 +2,10 @@ package com.engine.organization.util.saveimport; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; +import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.staff.bo.StaffBO; import com.engine.organization.entity.staff.param.StaffSearchParam; import com.engine.organization.entity.staff.po.StaffPO; @@ -15,7 +17,6 @@ import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffPlanMapper; import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; -import com.engine.organization.util.relation.EcHrmRelationUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -76,10 +77,13 @@ public class StaffInfoImportUtil { historyDetailPO = new JclImportHistoryDetailPO(); historyDetailPO.setPid(importHistoryId); XSSFRow row = sheetAt.getRow(i); + if (null == row) { + continue; + } // 组装待处理数据 Map map = new HashMap<>(); - Long parentCompanyId = null; - Long parentDepartmentId = null; + Integer parentCompanyId = null; + Integer parentDepartmentId = null; Long parentJobId = null; StaffPlanPO staffPlanPO = null; @@ -156,7 +160,7 @@ public class StaffInfoImportUtil { } } map.put("comp_id", parentCompanyId); - map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentCompanyId))); + map.put("ec_company", parentCompanyId); } // 部门 if ("dept_id".equals(infoPO.getFieldName())) { @@ -180,9 +184,7 @@ public class StaffInfoImportUtil { } map.put("dept_id", parentDepartmentId); - if (null != parentDepartmentId) { - map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(Util.null2String(parentDepartmentId))); - } + map.put("ec_department", parentDepartmentId); } // 岗位 @@ -249,21 +251,33 @@ public class StaffInfoImportUtil { param.setJobId(null); break; case "2":// 部门 - if (null == parentCompanyId) { - checkMsg = "编制维度选择分部时,分部必填!"; - } else if (null == parentDepartmentId) { + if (null == parentDepartmentId) { checkMsg = "编制维度选择部门时,部门必填!"; + } else { + DepartmentPO deptById = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(parentDepartmentId); + if (null == deptById) { + checkMsg = "未找到对应部门!"; + } else { + param.setCompId(deptById.getSubCompanyId1()); + param.setEcCompany(deptById.getSubCompanyId1()); + } } // 取消岗位赋值 param.setJobId(null); break; case "3": // 岗位 - if (null == parentCompanyId) { - checkMsg = "编制维度选择分部时,分部必填!"; - } else if (null == parentDepartmentId) { - checkMsg = "编制维度选择部门时,部门必填!"; - } else if (null == parentJobId) { + if (null == parentJobId) { checkMsg = "编制维度选择岗位时,岗位必填!"; + } else { + JobPO jobPO = MapperProxyFactory.getProxy(JobMapper.class).getJobById(parentJobId); + if (null == jobPO) { + checkMsg = "未找到对应岗位!"; + } else { + param.setCompId(jobPO.getEcCompany()); + param.setEcCompany(jobPO.getEcCompany()); + param.setDeptId(jobPO.getEcDepartment()); + param.setEcDepartment(jobPO.getEcDepartment()); + } } break; default: diff --git a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java index 4769b914..194ac3d9 100644 --- a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java +++ b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java @@ -54,9 +54,9 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { private String[] temFields; //标准模板字段 - private String tempField = "所属分部,部门," + + private String tempField = "分部,部门," + "编号,姓名,登录名,密码,安全级别,性别," + - // "岗位,职务,职务类别,职称," + + "岗位,职务,职务类别,职称,职级," + "职责描述,直接上级,助理,状态," + "办公室,办公地点,办公电话,移动电话,其他电话," + "传真,电子邮件,系统语言,出生日期,民族," + @@ -72,7 +72,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { private String[] requiredFields; //必填列标准模板或字段下标 - // 所属分部,部门,姓名,岗位,职务,职务类别,办公地点 + // 分部,部门,姓名,岗位,职务,职务类别,办公地点 // private String requiredField = "0,1,3,8,9,10,18"; private final StringBuilder requiredField = new StringBuilder(); @@ -82,7 +82,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { //标准导入字段 private String voField = "subcompanyid1,departmentid," + "workcode,lastname,loginid,password,seclevel,sex," + - // "jobtitle,jobactivityid,jobgroupid,jobcall," + + "jobtitle,jobactivityid,jobgroupid,jobcall,joblevel," + "jobactivitydesc,managerid,assistantid,status," + "workroom,locationid,telephone,mobile,mobilecall," + "fax,email,systemlanguage,birthday,folk," + @@ -232,7 +232,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { if ("accounttype".equalsIgnoreCase(voFields[i])) { accounttypeIndex = i; } - if (keyFieldIndex != 2 && certificateNumIndex != 29) break; + //if (keyFieldIndex != 2 && certificateNumIndex != 29) break; } try { Workbook workbook; @@ -282,8 +282,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { cellValue = getCellValue(cell).trim(); for (int k = 0; k < temFields.length; k++) { if (cellValue.equals(temFields[k])) { - String requiredFields = "所属分部,部门,姓名,岗位,职务,职务类别,办公地点"; - requiredFields = "所属分部,部门,登录名,姓名,性别,状态,办公地点,入职日期,参加工作日期,担任岗位,职等职级,担任职务"; + String requiredFields = "分部,部门,姓名,岗位,职务,职务类别,办公地点"; List requiredFieldList = Arrays.asList(requiredFields.split(",")); if (requiredFieldList.contains(cellValue)) { @@ -293,10 +292,12 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { fieldList.add(cellValue); if (keyFieldIndex == k) //如果重复性验证标准数据库字段下标与标准excel模板下标相等,则找到对应的excel验证列 keyColumn = i; - if (certificateNumIndex == k) { + // if (certificateNumIndex == k) { + if ("身份证号码".equals(cellValue)) { certificateNumColumn = i; } - if (accounttypeIndex == k) { + // if (accounttypeIndex == k) { + if ("账号类型".equals(cellValue)) { accounttypeColumn = i; } flag = true; @@ -307,19 +308,19 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { errorInfo.add(getCellPosition(i, (rowIndex + 1)) + "[" + cellValue + "]" + " 不是模板中字段,请检查是否有误"); //不是模板中字段,请检查是否有误 if (importType.equals("add")) { //如果是插入操作才验证固定列 if (i == 0 && !cellValue.equals(temFields[0])) - errorInfo.add("分所属分部部必须在第" + (rowIndex + 1) + "行第1列"); //【所属分部】固定列 + errorInfo.add("分部必须在第" + (rowIndex + 1) + "行第1列"); //【分部】固定列 if (i == 1 && !cellValue.equals(temFields[1])) errorInfo.add("部门必须在第" + (rowIndex + 1) + "行第2列"); // 【部门】固定列 } else { //如果是更新,并且存在分部部门列,就规定分部、部门在第1、2列 if (cellValue.equals(temFields[0]) && !temFields[1].equals(getCellValue(rowIndex, 1).trim())) - errorInfo.add("更新时有分所属分部部则后一列必须为部门,且第" + (rowIndex + 1) + "行第1列为分所属分部部,第2列为部门"); //【分部】固定列 + errorInfo.add("更新时有分部则后一列必须为部门,且第" + (rowIndex + 1) + "行第1列为分部,第2列为部门"); //【分部】固定列 else if (cellValue.equals(temFields[0]) && i != 0) - errorInfo.add("所属分部必须在第" + (rowIndex + 1) + "行第1列"); //【分部】固定列 + errorInfo.add("分部必须在第" + (rowIndex + 1) + "行第1列"); //【分部】固定列 if (cellValue.equals(temFields[1]) && !temFields[0].equals(getCellValue(rowIndex, 0).trim())) - errorInfo.add("更新时有部门则前一列必须为所属分部,且第" + (rowIndex + 1) + "行第1列为所属分部,第2列为部门"); //【分部】固定列 + errorInfo.add("更新时有部门则前一列必须为分部,且第" + (rowIndex + 1) + "行第1列为分部,第2列为部门"); //【分部】固定列 else if (cellValue.equals(temFields[1]) && i != 1) errorInfo.add("部门必须在第" + (rowIndex + 1) + "行第2列"); //【部门】固定列 @@ -432,7 +433,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { if (flag) { // 为true则,设置值,否则不需要 - if (fieldIndex == 0 && getCellValue(1, cellNum).equals("所属分部")) { // 对于excel分部为空则取上面分部读取的值 + if (fieldIndex == 0 && getCellValue(1, cellNum).equals("分部")) { // 对于excel分部为空则取上面分部读取的值 if (cellValue.equals("")) cellValue = subCompany; else @@ -551,7 +552,12 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { if (certificateNumColumn == -1) return false; String certificateNum = getCellValue(row.getCell((short) certificateNumColumn)).trim(); - String accounttype = getCellValue(row.getCell((short) accounttypeColumn)).trim(); + String accounttype; + if (accounttypeColumn == -1) { + accounttype = ""; + } else { + accounttype = getCellValue(row.getCell((short) accounttypeColumn)).trim(); + } String key = getCellValue(row.getCell((short) keyColumn)).trim(); if (voFields[fieldsMap.get(keyColumn)].equals("")) key = getCellValue(row.getCell((short) 0)).trim() + ">" + getCellValue(row.getCell((short) 1)).trim() + "_" + key; @@ -619,7 +625,7 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { String fieldName = voFields[fieldIndex]; // 人员信息第1行(模板第2行)的分部和部门为必填 - if ((rowNum == 1 || rowNum == 2) && fieldName.equals("subcompanyid1") && getCellValue(1, cellNum).equals("所属分部") && cellValue.equals("")) { + if ((rowNum == 1 || rowNum == 2) && fieldName.equals("subcompanyid1") && getCellValue(1, cellNum).equals("分部") && cellValue.equals("")) { flag = false; msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【分部】为必填 errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); @@ -652,28 +658,28 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { return flag; } - //// 岗位 - //if (fieldName.equals("jobtitle") && cellValue.equals("")) { - // flag = false; - // msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【岗位】为必填 - // errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); - // return flag; - //} - // - //if (fieldName.equals("jobactivityid") && cellValue.equals("")) { - // flag = false; - // msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【职务】为必填 - // errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); - // return flag; - //} - // - // - //if (fieldName.equals("jobgroupid") && cellValue.equals("")) { - // flag = false; - // msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【职务类别】为必填 - // errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); - // return flag; - //} + // 岗位 + if (fieldName.equals("jobtitle") && cellValue.equals("")) { + flag = false; + msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【岗位】为必填 + errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); + return flag; + } + + if (fieldName.equals("jobactivityid") && cellValue.equals("")) { + flag = false; + msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【职务】为必填 + errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); + return flag; + } + + + if (fieldName.equals("jobgroupid") && cellValue.equals("")) { + flag = false; + msg = getCellPosition(cellNum, rowNum + 1) + "[" + temFields[fieldIndex] + "]"; //【职务类别】为必填 + errorInfo.add(msg + " " + SystemEnv.getHtmlLabelName(83626, userlanguage)); + return flag; + } // 办公地点 diff --git a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java index fdeffea8..cc484069 100644 --- a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java +++ b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java @@ -6,6 +6,7 @@ import com.engine.common.util.ParamUtil; import com.engine.encrypt.biz.EncryptFieldConfigComInfo; import com.engine.hrm.entity.RuleCodeType; import com.engine.hrm.util.CodeRuleManager; +import com.engine.hrm.util.HrmTriggerUtil; import com.engine.hrm.util.HrmWeakPasswordUtil; import com.engine.hrm.util.face.HrmFaceCheckManager; import com.engine.hrm.util.face.ValidateFieldManager; @@ -13,8 +14,6 @@ import com.engine.hrm.util.face.bean.CheckItemBean; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryMapper; -import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.thread.HrmResourceTriggerRunnable; import com.engine.organization.util.db.MapperProxyFactory; import com.weaver.integration.ldap.sync.oa.OaSync; import com.weaver.integration.ldap.util.AuthenticUtil; @@ -232,8 +231,8 @@ public class HrmImportProcessE9 extends BaseBean { Class voClass = HrmResourceVo.class; String field = "id,subcompanyid1,departmentid,workcode,lastname," - + "loginid,password,seclevel,sex," - + "managerid,assistantid,status,locationid,workroom," + + "loginid,password,seclevel,sex,jobtitle,jobcall,joblevel," + + "jobactivitydesc,managerid,assistantid,status,locationid,workroom," + "telephone,mobile,mobilecall,fax,email," + "systemlanguage,birthday,folk,nativeplace,regresidentplace," + "certificatenum,maritalstatus,policy,bememberdate,bepartydate," @@ -262,13 +261,13 @@ public class HrmImportProcessE9 extends BaseBean { RemindSettings settings = reminder.getRemindSettings(); //判断是否启用【启用初始密码】 //是否启用初始密码:false-不启用初始密码、true-启用初始密码 - boolean defaultPasswordEnable = Util.null2String(settings.getDefaultPasswordEnable()).equals("1"); + boolean defaultPasswordEnable = "1".equals(Util.null2String(settings.getDefaultPasswordEnable())); //初始密码 //初始密码 String defaultPassword = Util.null2String(settings.getDefaultPassword()); //判断是否启用【弱密码禁止保存】 //弱密码禁止保存:false-允许保存弱密码、true-不允许保存弱密码 - boolean weakPasswordDisable = Util.null2String(settings.getWeakPasswordDisable()).equals("1"); + boolean weakPasswordDisable = "1".equals(Util.null2String(settings.getWeakPasswordDisable())); try { //判断是否为弱密码 hrmWeakPasswordUtil = new HrmWeakPasswordUtil(); @@ -287,7 +286,7 @@ public class HrmImportProcessE9 extends BaseBean { //TimeUnit.SECONDS.sleep(1); try { // 异常处理 - if (operateType.equals("add")) { + if ("add".equals(operateType)) { if (keyMap.get(key) != null) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(83520, userlanguage))); @@ -398,7 +397,7 @@ public class HrmImportProcessE9 extends BaseBean { if (vo.getBelongto() != null && !"".equals(vo.getBelongto().trim())) { int belongto = getBelongId(vo.getBelongto(), keyField); hrm.setBelongto(belongto); - if (!vo.getBelongto().equals("") && belongto == 0) { + if (!"".equals(vo.getBelongto()) && belongto == 0) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(131279, userlanguage))); continue; } else { @@ -415,7 +414,7 @@ public class HrmImportProcessE9 extends BaseBean { } else if (vo.getBelongto() != null && !"".equals(vo.getBelongto().trim())) { int belongto = getBelongId(vo.getBelongto(), keyField); hrm.setBelongto(belongto); - if (!vo.getBelongto().equals("") && belongto == 0) { + if (!"".equals(vo.getBelongto()) && belongto == 0) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(131279, userlanguage))); continue; } else { @@ -426,29 +425,15 @@ public class HrmImportProcessE9 extends BaseBean { hrm.setAccounttype(0); } - //// 岗位id - //if (vo.getJobtitle() != null && vo.getJobactivityid() != null && vo.getJobgroupid() != null) { - // int jobtitle = getJobTitles(vo.getJobtitle(), vo - // .getJobactivityid(), vo.getJobgroupid()); - // /// -1:职务类别不存在,-2:职务不存在,-3:职务类别不存在 - // if (jobtitle == -1) { - // resultList.add(createLog(vo, "创建", "失败", "职务类别不存在")); - // continue; - // } else if (jobtitle == -2) { - // resultList.add(createLog(vo, "创建", "失败", "职务不存在")); - // continue; - // } else if (jobtitle == -3) { - // resultList.add(createLog(vo, "创建", "失败", "岗位名称不存在")); - // continue; - // } - // hrm.setJobtitle(jobtitle); - //} else { - // resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(83531, userlanguage))); - // continue; - //} - - // 担任岗位字段校验 - + // 岗位id + if (vo.getJobtitle() != null && vo.getJobactivityid() != null && vo.getJobgroupid() != null) { + int jobtitle = getJobTitles(vo.getJobtitle(), vo + .getJobactivityid(), vo.getJobgroupid()); + hrm.setJobtitle(jobtitle); + } else { + resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(83531, userlanguage))); + continue; + } //上级id if (vo.getManagerid() != null) { @@ -463,7 +448,7 @@ public class HrmImportProcessE9 extends BaseBean { hrm.setManagerstr(managerstr); //如果vo.getManagerid()有值,但manageid未找到,说明填写有误 - if (!vo.getManagerid().equals("") && managerid == 0) { + if (!"".equals(vo.getManagerid()) && managerid == 0) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage))); continue; } @@ -478,7 +463,7 @@ public class HrmImportProcessE9 extends BaseBean { int assistantid; assistantid = getAssistantid(vo.getAssistantid(), keyField); hrm.setAssistantid(assistantid); - if (!vo.getAssistantid().equals("") && assistantid == 0) { + if (!"".equals(vo.getAssistantid()) && assistantid == 0) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(24678, userlanguage))); continue; } @@ -513,10 +498,12 @@ public class HrmImportProcessE9 extends BaseBean { //mobile-sunjsh if (vo.getMobile() != null) { - if ("".equals(vo.getMobile().trim()) || (!"".equals(vo.getMobile().trim()) && vo.getMobile().contains("*"))) + if ("".equals(vo.getMobile().trim()) || (!"".equals(vo.getMobile().trim()) && vo.getMobile().contains("*"))) { vo.setMobile(null); - } else + } + } else { hrm.setMobile(""); + } //工资银行-sunjsh if (vo.getBankid1() != null && !"".equals(vo.getBankid1())) { @@ -621,7 +608,7 @@ public class HrmImportProcessE9 extends BaseBean { continue; } //安全级别必须是数字 - if (!Util.null2String(vo.getSeclevel()).equals("")) { + if (!"".equals(Util.null2String(vo.getSeclevel()))) { if (Util.getIntValue(vo.getSeclevel(), -1000) == -1000) { resultList.add(createLog(vo, "创建", "失败", "安全级别必须是数字")); continue; @@ -634,12 +621,12 @@ public class HrmImportProcessE9 extends BaseBean { } //职级 - //if (isInteger(vo.getJoblevel())) { - // int joblevel = vo.getJoblevel().equals("") ? 0 : Integer.parseInt(vo.getJoblevel()); - // hrm.setJoblevel((short) joblevel); - //} else { - // hrm.setJoblevel((short) 0); - //} + if (isInteger(vo.getJoblevel())) { + int joblevel = "".equals(vo.getJoblevel()) ? 0 : Integer.parseInt(vo.getJoblevel()); + hrm.setJoblevel((short) joblevel); + } else { + hrm.setJoblevel((short) 0); + } //用工性质 if (vo.getUsekind() != null) { int usekind = getUseKind(vo.getUsekind()); @@ -678,7 +665,7 @@ public class HrmImportProcessE9 extends BaseBean { password_tmp = "1"; //人员导入文件中,将密码这一列删除或者密码这一列存在,但是不填写都默认为初始密码 if (defaultPasswordEnable) { - if (!defaultPassword.equals("")) { + if (!"".equals(defaultPassword)) { if (weakPasswordDisable && this.hrmWeakPasswordUtil.isWeakPsd(defaultPassword)) { resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(515436, userlanguage))); continue; @@ -728,7 +715,7 @@ public class HrmImportProcessE9 extends BaseBean { } else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { insertFields.append(s).append(","); String insertValueStr = Util.null2String(hrmField.get(hrm)); - if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("".equals(insertValueStr) && "postgresql".equalsIgnoreCase(recordSet.getDBType())) { insertValues.append("null,"); } else { insertValues.append(hrmField.get(hrm)).append(","); @@ -736,8 +723,8 @@ public class HrmImportProcessE9 extends BaseBean { } } else if (voField.get(vo) != null) { if (voFieldType.endsWith("String")) { - if (recordSet.getDBType().equalsIgnoreCase("mysql") || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - if (Util.null2String(voField.get(vo)).equals("")) { + if ("mysql".equalsIgnoreCase(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { + if ("".equals(Util.null2String(voField.get(vo)))) { insertFields.append(s).append(","); insertValues.append("null,"); } else { @@ -751,7 +738,7 @@ public class HrmImportProcessE9 extends BaseBean { } else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { insertFields.append(s).append(","); String insertValueStr = Util.null2String(voField.get(vo)); - if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("".equals(insertValueStr) && "postgresql".equalsIgnoreCase(recordSet.getDBType())) { insertValues.append("null,"); } else { insertValues.append(voField.get(vo)).append(","); @@ -775,11 +762,17 @@ public class HrmImportProcessE9 extends BaseBean { PasswordUtil.updateResourceSalt(id + "", salt); if (updateBaseData(vo.getBaseFields(), vo.getBaseFieldsValue(), id)) //添加基础字段信息 + { flag = false; + } if (updatePersonData(vo.getPersonFields(), vo.getPersonFieldsValue(), id)) //添加个人字段信息 + { flag = false; + } if (updateWorkData(vo.getWorkFields(), vo.getWorkFieldsValue(), id)) //添加工作字段信息 + { flag = false; + } } /*添加人员缓存,人员默认按id显示顺序,HrmResource_Trigger_Insert 人员共享 入职维护项目状态*/ @@ -822,7 +815,7 @@ public class HrmImportProcessE9 extends BaseBean { new HrmDateCheck().calWorkInfo("" + id); // 刷新组织结构图 - new Thread(new HrmResourceTriggerRunnable((long) id)).start(); + // TODO new Thread(new HrmResourceTriggerRunnable((long) id)).start(); } @@ -846,7 +839,6 @@ public class HrmImportProcessE9 extends BaseBean { if (this.checkInfo(vo, resultList)) { continue; } - new BaseBean().writeLog("checkKeys校验通过"); if (vo.getAccounttype() == null || "".equalsIgnoreCase(Util.null2String(vo.getAccounttype()))) { if (StringUtil.isNotNull(vo.getCertificatenum()) && certificateNums.get(StringUtil.vString(vo.getCertificatenum())) != null) { @@ -880,6 +872,7 @@ public class HrmImportProcessE9 extends BaseBean { issameSub = false; } + if (subcompanyid1 == -9) { resultList.add(createLog(vo, "更新", "失败", SystemEnv.getErrorMsgName(56, userlanguage))); continue; @@ -942,7 +935,7 @@ public class HrmImportProcessE9 extends BaseBean { if (vo.getBelongto() != null && !"".equals(vo.getBelongto().trim())) { int belongto = getBelongId(vo.getBelongto(), keyField); hrm.setBelongto(belongto); - if (!vo.getBelongto().equals("") && belongto == 0) { + if (!"".equals(vo.getBelongto()) && belongto == 0) { resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(131279, userlanguage))); continue; } else { @@ -959,7 +952,7 @@ public class HrmImportProcessE9 extends BaseBean { } else if (vo.getBelongto() != null && !"".equals(vo.getBelongto().trim())) { int belongto = getBelongId(vo.getBelongto(), keyField); hrm.setBelongto(belongto); - if (!vo.getBelongto().equals("") && belongto == 0) { + if (!"".equals(vo.getBelongto()) && belongto == 0) { resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(131279, userlanguage))); continue; } else { @@ -967,47 +960,39 @@ public class HrmImportProcessE9 extends BaseBean { } } - //// 岗位id - //if ("".equals(Util.null2String(vo.getJobtitle())) && (!"".equals(Util.null2String(vo.getJobactivityid())) || !"".equals(Util.null2String(vo.getJobgroupid())))) { - // resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(83544, userlanguage))); - // continue; - //} - //if (!"".equals(Util.null2String(vo.getJobtitle()))) { - // String jobtitle; - // String jobactivityid; - // String jobactivityname; - // String jobgroupid; - // String jobgroupname; - // if (vo.getJobactivityid() == null) { - // jobtitle = resourcecominfo.getJobTitle(hrmId); - // jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle); - // jobactivityname = jobActivitiesComInfo.getJobActivitiesname(jobactivityid); - // } else - // jobactivityname = vo.getJobactivityid(); - // if (vo.getJobgroupid() == null) { - // jobtitle = resourcecominfo.getJobTitle(hrmId); - // jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle); - // jobgroupid = jobActivitiesComInfo.getJobgroupid(jobactivityid); - // jobgroupname = jobGroupsComInfo.getJobGroupsname(jobgroupid); - // } else { - // jobgroupname = vo.getJobgroupid(); - // } - // int jobtitleid = getJobTitles(vo.getJobtitle(), jobactivityname, jobgroupname); - // if (jobtitleid == -1) { - // resultList.add(createLog(vo, "创建", "失败", "职务类别不存在")); - // continue; - // } else if (jobtitleid == -2) { - // resultList.add(createLog(vo, "创建", "失败", "职务不存在")); - // continue; - // } else if (jobtitleid == -3) { - // resultList.add(createLog(vo, "创建", "失败", "岗位名称不存在")); - // continue; - // } - // hrm.setJobtitle(jobtitleid); - //} - - new BaseBean().writeLog("hrmId【" + hrmId + "】"); - if (Util.getIntValue(hrmId) < 0) continue; + // 岗位id + if ("".equals(Util.null2String(vo.getJobtitle())) && (!"".equals(Util.null2String(vo.getJobactivityid())) || !"".equals(Util.null2String(vo.getJobgroupid())))) { + resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(83544, userlanguage))); + continue; + } + if (!"".equals(Util.null2String(vo.getJobtitle()))) { + String jobtitle = ""; + String jobactivityid = ""; + String jobactivityname = ""; + String jobgroupid = ""; + String jobgroupname = ""; + if (vo.getJobactivityid() == null) { + jobtitle = resourcecominfo.getJobTitle(hrmId); + jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle); + jobactivityname = jobActivitiesComInfo.getJobActivitiesname(jobactivityid); + } else { + jobactivityname = vo.getJobactivityid(); + } + if (vo.getJobgroupid() == null) { + jobtitle = resourcecominfo.getJobTitle(hrmId); + jobactivityid = jobTitlesComInfo.getJobactivityid(jobtitle); + jobgroupid = jobActivitiesComInfo.getJobgroupid(jobactivityid); + jobgroupname = jobGroupsComInfo.getJobGroupsname(jobgroupid); + } else { + jobgroupname = vo.getJobgroupid(); + } + int jobtitleid = getJobTitles(vo.getJobtitle(), jobactivityname, jobgroupname); + hrm.setJobtitle(jobtitleid); + } + + if (Util.getIntValue(hrmId) < 0) { + continue; + } //上级id String managerstr = ""; //所有上级 @@ -1023,7 +1008,7 @@ public class HrmImportProcessE9 extends BaseBean { } //如果vo.getManagerid()有值,但manageid未找到,说明填写有误 - if (vo.getManagerid() != null && !vo.getManagerid().equals("") && managerid == 0) { + if (vo.getManagerid() != null && !"".equals(vo.getManagerid()) && managerid == 0) { resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(83532, userlanguage))); continue; } @@ -1044,7 +1029,7 @@ public class HrmImportProcessE9 extends BaseBean { if (!"".equals(Util.null2String(vo.getAssistantid()))) { int assistantid; assistantid = getAssistantid(vo.getAssistantid(), keyField); - if (vo.getAssistantid() != null && !vo.getAssistantid().equals("") && assistantid == 0) { + if (vo.getAssistantid() != null && !"".equals(vo.getAssistantid()) && assistantid == 0) { resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(24678, userlanguage))); continue; } @@ -1076,10 +1061,11 @@ public class HrmImportProcessE9 extends BaseBean { //mobile-sunjsh if (vo.getMobile() != null) { - if ("".equals(vo.getMobile().trim())) + if ("".equals(vo.getMobile().trim())) { hrm.setMobile(""); - else if (!"".equals(vo.getMobile().trim()) && vo.getMobile().contains("*")) + } else if (!"".equals(vo.getMobile().trim()) && vo.getMobile().contains("*")) { vo.setMobile(null); + } } //工资银行-sunjsh @@ -1138,14 +1124,14 @@ public class HrmImportProcessE9 extends BaseBean { // 性别,为空或其他情况统一为0(男) if (!"".equals(Util.null2String(vo.getSex()))) { - String sex = vo.getSex().equals("女") ? "1" : "0"; + String sex = "女".equals(vo.getSex()) ? "1" : "0"; hrm.setSex(sex); } // 婚姻状况,如果不是以下选项,则默认为未婚 if (!"".equals(Util.null2String(vo.getMaritalstatus()))) { - String maritalstatus = vo.getMaritalstatus().equals("已婚") ? "1" - : vo.getMaritalstatus().equals("离异") ? "2" : "0"; + String maritalstatus = "已婚".equals(vo.getMaritalstatus()) ? "1" + : "离异".equals(vo.getMaritalstatus()) ? "2" : "0"; hrm.setMaritalstatus(maritalstatus); } @@ -1170,7 +1156,7 @@ public class HrmImportProcessE9 extends BaseBean { // 工会会员,默认为是 if (!"".equals(Util.null2String(vo.getIslabouunion()))) { - String islabouunion = vo.getIslabouunion().equals("是") ? "1" + String islabouunion = "是".equals(vo.getIslabouunion()) ? "1" : "0"; hrm.setIslabouunion(islabouunion); } @@ -1192,7 +1178,7 @@ public class HrmImportProcessE9 extends BaseBean { continue; } //安全级别必须是数字 - if (!Util.null2String(vo.getSeclevel()).equals("")) { + if (!"".equals(Util.null2String(vo.getSeclevel()))) { if (Util.getIntValue(vo.getSeclevel(), -1000) == -1000) { resultList.add(createLog(vo, "更新", "失败", "安全级别必须是数字")); continue; @@ -1205,10 +1191,10 @@ public class HrmImportProcessE9 extends BaseBean { } //职级 - //if (isInteger(vo.getJoblevel())) { - // int joblevel = vo.getJoblevel().equals("") ? 0 : Integer.parseInt(vo.getJoblevel()); - // hrm.setJoblevel((short) joblevel); - //} + if (isInteger(vo.getJoblevel())) { + int joblevel = "".equals(vo.getJoblevel()) ? 0 : Integer.parseInt(vo.getJoblevel()); + hrm.setJoblevel((short) joblevel); + } //用工性质 if (vo.getUsekind() != null) { @@ -1245,7 +1231,9 @@ public class HrmImportProcessE9 extends BaseBean { if (!"".equals(Util.null2String(vo.getPassword()))) { String orgPwd = "1"; - if (!"".equals(vo.getPassword())) orgPwd = vo.getPassword(); + if (!"".equals(vo.getPassword())) { + orgPwd = vo.getPassword(); + } String[] pwdArr = PasswordUtil.encrypt(orgPwd); String salt = pwdArr[1]; hrm.setPassword(pwdArr[0]); @@ -1274,19 +1262,19 @@ public class HrmImportProcessE9 extends BaseBean { voField.setAccessible(true); if (Util.null2String(hrmField.get(hrm)).trim().length() > 0) { - if (hrmFieldType.endsWith("String")) + if (hrmFieldType.endsWith("String")) { updateStr.append(fields[k]).append("='").append(hrmField.get(hrm)).append("',"); - else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { + } else if (hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { updateStr.append(fields[k]).append("=").append(hrmField.get(hrm)).append(","); } - if (fields[k].equals("status")) { + if ("status".equals(fields[k])) { tmpstatus = Util.null2String(hrmField.get(hrm)); } } else if (Util.null2String(voField.get(vo)).trim().length() > 0) { if (voFieldType.endsWith("String")) { - if (recordSet.getDBType().equalsIgnoreCase("mysql") || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - if (Util.null2String(voField.get(vo)).equals("")) { + if ("mysql".equalsIgnoreCase(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { + if ("".equals(Util.null2String(voField.get(vo)))) { updateStr.append(fields[k]).append("=null,"); } else { updateStr.append(fields[k]).append("='").append(voField.get(vo)).append("',"); @@ -1301,14 +1289,17 @@ public class HrmImportProcessE9 extends BaseBean { updateStr.append(fields[k]).append("=").append(voField.get(vo)).append(","); } } - if (fields[k].equals("status")) tmpstatus = Util.null2String(voField.get(vo)); + if ("status".equals(fields[k])) { + tmpstatus = Util.null2String(voField.get(vo)); + } } } updateStr.append(" lastmodid=").append(lastmodid).append(",lastmoddate='").append(lastmoddate).append("',managerstr='").append(hrm.getManagerstr()).append("',").append(DbFunctionUtil.getUpdateSetSql(new RecordSet().getDBType(), lastmodid)).append(" where id=").append(keyMap.get(key)); - if (!execSql(updateStr.toString())) + if (!execSql(updateStr.toString())) { flag = false; + } //同步密码到AD if (flag && !"".equals(Util.null2String(vo.getPassword()))) { @@ -1324,7 +1315,7 @@ public class HrmImportProcessE9 extends BaseBean { String optype = "4"; //1,强制修改密码操作。2,首次登录密码操作,3,忘记密码找回。其它,系统修改ad操作。 map.put("optype", optype); Map retInfo = new OaSync("", "").modifyADPWDNew(map); - if (Util.null2String(retInfo.get("code")).equals("0")) { + if ("0".equals(Util.null2String(retInfo.get("code")))) { //更新修改密码时间 String passwdchgdate = Util.null2String(TimeUtil.getCurrentDateString()); flag = recordSet.executeUpdate("update hrmresource set passwdchgdate=?, haschangepwd='y' where id = ?", passwdchgdate, userid); @@ -1383,14 +1374,17 @@ public class HrmImportProcessE9 extends BaseBean { //OA与第三方接口单条数据同步方法结束 } - if (updateBaseData(vo.getBaseFields(), vo.getBaseFieldsValue().trim(), keyMap.get(key))) + if (updateBaseData(vo.getBaseFields(), vo.getBaseFieldsValue().trim(), keyMap.get(key))) { flag = false; + } - if (updatePersonData(vo.getPersonFields(), vo.getPersonFieldsValue().trim(), keyMap.get(key))) + if (updatePersonData(vo.getPersonFields(), vo.getPersonFieldsValue().trim(), keyMap.get(key))) { flag = false; + } - if (updateWorkData(vo.getWorkFields().trim(), vo.getWorkFieldsValue(), keyMap.get(key))) + if (updateWorkData(vo.getWorkFields().trim(), vo.getWorkFieldsValue(), keyMap.get(key))) { flag = false; + } /*update HrmResource_Trigger */ if (flag) { @@ -1420,9 +1414,9 @@ public class HrmImportProcessE9 extends BaseBean { String nowmanagerstr = Util.null2String(recordSet.getString("managerstr")); String resourceid = recordSet.getString("id"); //指定上级为自身的情况,不更新自身上级 - new BaseBean().writeLog("resourceid【" + resourceid + "】"); - if (hrmId.equals(resourceid)) + if (hrmId.equals(resourceid)) { continue; + } String nowmanagerstr2 = ""; int index = nowmanagerstr.lastIndexOf(oldmanagerstr); if (index != -1) { @@ -1466,7 +1460,7 @@ public class HrmImportProcessE9 extends BaseBean { if (rst.next()) { loginid = rst.getString("loginid"); } - if (loginid != null && !loginid.equals("")) { + if (loginid != null && !"".equals(loginid)) { if (!rtxService.checkUser(Integer.parseInt(hrmId))) { rtxService.addUser(Integer.parseInt(hrmId));//更新人员rtx } @@ -1481,7 +1475,7 @@ public class HrmImportProcessE9 extends BaseBean { if (rst.next()) { loginid = rst.getString("loginid"); } - if (loginid != null && !loginid.equals("")) { + if (loginid != null && !"".equals(loginid)) { if (!rtxService.checkUser(Integer.parseInt(hrmId))) { rtxService.addUser(Integer.parseInt(hrmId));//更新人员rtx } @@ -1494,7 +1488,7 @@ public class HrmImportProcessE9 extends BaseBean { resultList.add(createLog(vo, "更新", "失败", "系统错误,请联系管理员")); } // 刷新组织结构图 - new Thread(new HrmResourceTriggerRunnable((long) keyMap.get(key))).start(); + // TODO new Thread(new HrmResourceTriggerRunnable((long) keyMap.get(key))).start(); } } catch (Exception e) { //数据异常 @@ -1536,7 +1530,9 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean addBaseData(String baseFild, String baseValue, int id) { - if (baseFild == null || baseFild.equals("")) return true; + if (baseFild == null || "".equals(baseFild)) { + return true; + } String[] baseValues = baseValue.split(";"); String[] baseFields = baseFild.split(","); String fielddbType; @@ -1574,28 +1570,18 @@ public class HrmImportProcessE9 extends BaseBean { fielddbType = jsonObject.getString("fielddbtype"); jsonObject.put("fieldvalue", baseValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); - // 处理自动获取时,或取到已删除的数据 - if ("field100002".equalsIgnoreCase(fieldname)) { - // 根据分部、部门,获取对应的岗位ID - recordSet.execute("select subcompanyid1,departmentid from hrmresource where id = " + id); - while (recordSet.next()) { - String ecCompany = recordSet.getString("subcompanyid1"); - String ecDepartment = recordSet.getString("departmentid"); - Long jobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndEcId(baseValues[i], ecCompany, ecDepartment); - fieldvalue = null == jobId ? "" : jobId.toString(); - } - } EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) - valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'"); - else - valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL"); + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { + valueStr.append(",").append("'").append(!"".equals(fieldvalue) ? fieldvalue : "").append("'"); + } else { + valueStr.append(",").append(!"".equals(fieldvalue) ? fieldvalue : "NULL"); + } } valueStr = new StringBuilder(valueStr.substring(1)); sql += "(scope,scopeid,id," + baseFild + ") values('HrmCustomFieldByInfoType'," + -1 + "," + id + "," + valueStr + ")"; @@ -1616,7 +1602,9 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean updateBaseData(String baseFild, String baseValue, int id) { - if (baseFild == null || baseFild.equals("")) return false; + if (baseFild == null || "".equals(baseFild)) { + return false; + } //检查cus_fielddata表中是否存在,对应id人员的基础自定义信息,如果不存在则向数据库添加 RecordSet recordSet = new RecordSet(); @@ -1663,31 +1651,24 @@ public class HrmImportProcessE9 extends BaseBean { fielddbType = jsonObject.getString("fielddbtype"); jsonObject.put("fieldvalue", baseValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); - // 处理自动获取时,或取到已删除的数据 - if ("field100002".equalsIgnoreCase(fieldname)) { - // 根据分部、部门,获取对应的岗位ID - recordSet.execute("select subcompanyid1,departmentid from hrmresource where id = " + id); - while (recordSet.next()) { - String ecCompany = recordSet.getString("subcompanyid1"); - String ecDepartment = recordSet.getString("departmentid"); - Long jobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndEcId(baseValues[i], ecCompany, ecDepartment); - fieldvalue = null == jobId ? "" : jobId.toString(); - new BaseBean().writeLog("岗位[" + baseValues[i] + "],jobId[" + Util.null2String(jobId) + "],ecCompany[" + ecCompany + "],ecDepartment[" + ecDepartment + "]"); - } - } EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fieldvalue.startsWith(",")) fieldvalue = fieldvalue.substring(1); - if (fieldvalue.endsWith(",")) fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); - if (!fieldvalue.equals("") || "field100002".equalsIgnoreCase(fieldname)) { + if (fieldvalue.startsWith(",")) { + fieldvalue = fieldvalue.substring(1); + } + if (fieldvalue.endsWith(",")) { + fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); + } + if (!"".equals(fieldvalue)) { flag = true; - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { setStr.append(",").append(baseFields[i]).append("='").append(fieldvalue).append("'"); - else + } else { setStr.append(",").append(baseFields[i]).append("=").append(fieldvalue); + } } } sql += setStr.substring(1) + " where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=" + id; @@ -1712,7 +1693,9 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean addPersonData(String personFild, String personValue, int id) { - if (personFild == null || personFild.equals("")) return true; + if (personFild == null || "".equals(personFild)) { + return true; + } String[] personValues = personValue.split(";"); String[] personFields = personFild.split(","); String fielddbType; @@ -1751,14 +1734,15 @@ public class HrmImportProcessE9 extends BaseBean { jsonObject.put("fieldvalue", personValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) - valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'"); - else - valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL"); + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { + valueStr.append(",").append("'").append(!"".equals(fieldvalue) ? fieldvalue : "").append("'"); + } else { + valueStr.append(",").append(!"".equals(fieldvalue) ? fieldvalue : "NULL"); + } } valueStr = new StringBuilder(valueStr.substring(1)); sql += "(scope,scopeid,id," + personFild + ") values('HrmCustomFieldByInfoType'," + 1 + "," + id + "," + valueStr + ")"; @@ -1779,7 +1763,9 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean updatePersonData(String personFild, String personValue, int id) { - if (personFild == null || personFild.equals("")) return false; + if (personFild == null || "".equals(personFild)) { + return false; + } //检查cus_fielddata表中是否存在,对应id人员的个人自定义信息,如果不存在则向数据库添加 String checkWorkInfo = "select id from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=1 and id=" + id; RecordSet recordSet = new RecordSet(); @@ -1787,8 +1773,7 @@ public class HrmImportProcessE9 extends BaseBean { if (!recordSet.next()) { return !addPersonData(personFild, personValue, id); } - new BaseBean().writeLog("personValue【" + personValue + "】"); - new BaseBean().writeLog("personFild【" + personFild + "】"); + String[] personValues = personValue.split(";"); String[] personFields = personFild.split(","); String fielddbType; @@ -1827,18 +1812,23 @@ public class HrmImportProcessE9 extends BaseBean { jsonObject.put("fieldvalue", personValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fieldvalue.startsWith(",")) fieldvalue = fieldvalue.substring(1); - if (fieldvalue.endsWith(",")) fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); - if (!fieldvalue.equals("")) { + if (fieldvalue.startsWith(",")) { + fieldvalue = fieldvalue.substring(1); + } + if (fieldvalue.endsWith(",")) { + fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); + } + if (!"".equals(fieldvalue)) { flag = true; - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { setStr.append(",").append(personFields[i]).append("='").append(fieldvalue).append("'"); - else + } else { setStr.append(",").append(personFields[i]).append("=").append(fieldvalue); + } } } sql += setStr.substring(1) + " where scope='HrmCustomFieldByInfoType' and scopeid=1 and id=" + id; @@ -1859,7 +1849,7 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean addWorkData(String workField, String workValue, int id) { - if (workField == null || workField.equals("")) { + if (workField == null || "".equals(workField)) { return true; } String[] workValues = workValue.split(";"); @@ -1899,14 +1889,15 @@ public class HrmImportProcessE9 extends BaseBean { jsonObject.put("fieldvalue", workValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) - valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'"); - else - valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL"); + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { + valueStr.append(",").append("'").append(!"".equals(fieldvalue) ? fieldvalue : "").append("'"); + } else { + valueStr.append(",").append(!"".equals(fieldvalue) ? fieldvalue : "NULL"); + } } valueStr = new StringBuilder(valueStr.substring(1)); sql += "(scope,scopeid,id," + workField + ") values('HrmCustomFieldByInfoType'," + 3 + "," + id + "," + valueStr + ")"; @@ -1927,7 +1918,9 @@ public class HrmImportProcessE9 extends BaseBean { * @return */ public boolean updateWorkData(String workField, String workValue, int id) { - if (workField == null || workField.equals("")) return false; + if (workField == null || "".equals(workField)) { + return false; + } //检查cus_fielddata表中是否存在,对应id人员的工作自定义信息,如果不存在则向数据库添加 String checkWorkInfo = "select id from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=3 and id=" + id; @@ -1975,18 +1968,23 @@ public class HrmImportProcessE9 extends BaseBean { jsonObject.put("fieldvalue", workValues[i]); String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { + if (encryptFieldEntity != null && "1".equals(encryptFieldEntity.getIsEncrypt())) { //是否需要加密 fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); } - if (fieldvalue.startsWith(",")) fieldvalue = fieldvalue.substring(1); - if (fieldvalue.endsWith(",")) fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); - if (!fieldvalue.equals("")) { + if (fieldvalue.startsWith(",")) { + fieldvalue = fieldvalue.substring(1); + } + if (fieldvalue.endsWith(",")) { + fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); + } + if (!"".equals(fieldvalue)) { flag = true; - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) + if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) { setStr.append(",").append(workFields[i]).append("='").append(fieldvalue).append("'"); - else + } else { setStr.append(",").append(workFields[i]).append("=").append(fieldvalue); + } } } @@ -2022,11 +2020,13 @@ public class HrmImportProcessE9 extends BaseBean { String supsubcomidConditon = DbDialectFactory.get(recordSet.getDBType()).isNull("supsubcomid", 0); for (String companyName : subCompanyNames) { - if (StringUtil.isNull(companyName)) continue; + if (StringUtil.isNull(companyName)) { + continue; + } sql = "select id from HrmSubCompany where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(subcompanyname))," + userlanguage + ")))='" + companyName.trim() + "' and " + supsubcomidConditon + "=" + parentId; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { sql = "select id from HrmSubCompany where ltrim(rtrim(convToMultiLang(ltrim(rtrim(subcompanyname))," + userlanguage + ")))='" + companyName.trim() + "' and " + supsubcomidConditon + "=" + parentId; } @@ -2043,8 +2043,9 @@ public class HrmImportProcessE9 extends BaseBean { break; } parentId = currentId; - if (currentId != -1) + if (currentId != -1) { rtxService.addSubCompany(parentId); //同步RTX + } } return currentId; } @@ -2072,13 +2073,13 @@ public class HrmImportProcessE9 extends BaseBean { String supdepidConditon = DbDialectFactory.get(recordSet.getDBType()).isNull("supdepid", 0); for (String s : deptName) { - if (s == null || s.equals("")) { + if (s == null || "".equals(s)) { continue; } sql = "select id from HrmDepartment where subcompanyid1=" + subCompanyId + " and ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(departmentname))," + userlanguage + ")))='" + s.trim() + "' and " + supdepidConditon + "=" + parentId; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { sql = "select id from HrmDepartment where subcompanyid1=" + subCompanyId + " and ltrim(rtrim(convToMultiLang(ltrim(rtrim(departmentname))," + userlanguage + ")))='" + s.trim() + "' and " + supdepidConditon + "=" + parentId; } @@ -2098,68 +2099,93 @@ public class HrmImportProcessE9 extends BaseBean { return currentId; } - ///** - // * 获取岗位id - // * - // * @param jobtitlename 岗位名称 - // * @param jobactivityname 职务 - // * @param jobgroupname 职务类别 - // * @return -1:职务类别不存在,-2:职务不存在,-3:岗位名称不存在 - // */ - //public int getJobTitles(String jobtitlename, String jobactivityname, - // String jobgroupname) { - // RecordSet rs = new RecordSet(); - // RecordSet recordSet = new RecordSet(); - // String sqlInsert; - // - // jobgroupname = Util.convertInput2DB4(jobgroupname); - // jobactivityname = Util.convertInput2DB4(jobactivityname); - // - // /* 获取jobgroupid 职务类别 */ - // String selSql = "select id from HrmJobGroups where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'"; - // if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - // selSql = "select id from HrmJobGroups where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'"; - // } - // - // int jobgroupid = getResultSetId(selSql); - // - // if (jobgroupid == 0) { - // return -1; - // } - // - // /* 获取jobactivityid 职务 */ - // selSql = "select id from HrmJobActivities where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid; - // if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - // selSql = "select id from HrmJobActivities where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid; - // } - // - // int jobactivityid = getResultSetId(selSql); - // - // if (jobactivityid == 0) { - // return -2; - // } - // - // /*获取岗位id*/ - // selSql = "select id from HrmJobTitles where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid; - // if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - // selSql = "select id from HrmJobTitles where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid; - // } - // - // int jobtitle = getResultSetId(selSql); - // - // if (jobtitle == 0) { - // return -3; - // - // } else { - // selSql = "select * from HrmJobTitles where id = '" + jobtitle + "' and jobactivityid = '" + jobactivityid + "' "; - // recordSet.executeSql(selSql); - // if (!recordSet.next()) {//查询这个名称已存在的岗位,对应的职务是否存在。如果对应职务的岗位不存在,则说明岗位对应的职务和职务类别有更新 - // sqlInsert = "update HrmJobTitles set jobactivityid = '" + jobactivityid + "'," + DbFunctionUtil.getUpdateSetSql(rs.getDBType(), 1) + " where id = '" + jobtitle + "' "; - // rs.executeSql(sqlInsert); - // } - // } - // return jobtitle; - //} + /** + * 获取岗位id + * + * @param jobtitlename 岗位名称 + * @param jobactivityname 职务 + * @param jobgroupname 职务类型 + * @return + */ + public int getJobTitles(String jobtitlename, String jobactivityname, + String jobgroupname) { + RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); + String sqlInsert = ""; + + jobgroupname = Util.convertInput2DB4(jobgroupname); + jobactivityname = Util.convertInput2DB4(jobactivityname); + + /* 获取jobgroupid 职务类别 */ + String selSql = "select id from HrmJobGroups where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'"; + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { + selSql = "select id from HrmJobGroups where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobgroupname))," + userlanguage + ")))='" + jobgroupname + "'"; + } + + int jobgroupid = getResultSetId(selSql); + + if (jobgroupid == 0) { + if (jobgroupname.length() == 0) { + selSql = "select max(id) as id from HrmJobGroups"; + jobgroupid = getResultSetId(selSql); + } else { + sqlInsert = "insert into HrmJobGroups (jobgroupname,jobgroupremark ," + DbFunctionUtil.getInsertColumnSql() + ") values('" + + jobgroupname + "','" + jobgroupname + "'," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ")"; // 创建 + execSql(sqlInsert); + jobgroupid = getResultSetId(selSql); + } + } + + /* 获取jobactivityid 职务 */ + selSql = "select id from HrmJobActivities where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid; + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { + selSql = "select id from HrmJobActivities where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobactivityname))," + userlanguage + ")))='" + jobactivityname + "' and jobgroupid=" + jobgroupid; + } + + int jobactivityid = getResultSetId(selSql); + + if (jobactivityid == 0) { + sqlInsert = "insert into HrmJobActivities (jobactivityname,Jobactivitymark,jobgroupid ," + DbFunctionUtil.getInsertColumnSql() + ") values('" + + jobactivityname + "','" + jobactivityname + "'," + jobgroupid + " ," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ")"; // 创建 + execSql(sqlInsert); + jobactivityid = getResultSetId(selSql); + } + + /*获取岗位id*/ + selSql = "select id from HrmJobTitles where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid; + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { + selSql = "select id from HrmJobTitles where ltrim(rtrim(convToMultiLang(ltrim(rtrim(jobtitlemark))," + userlanguage + ")))='" + jobtitlename + "' and jobactivityid=" + jobactivityid; + } + + int jobtitle = getResultSetId(selSql); + + if (jobtitle == 0) { + String jobtitlecode = ""; + try { + jobtitlecode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.JOBTITLES, jobtitlecode); + } catch (Exception e) { + writeLog(e); + } + sqlInsert = "insert into HrmJobTitles (jobtitlename,Jobtitlemark,jobactivityid ," + DbFunctionUtil.getInsertColumnSql() + ", jobtitlecode) values('" + + jobtitlename + "','" + jobtitlename + "'," + jobactivityid + " ," + DbFunctionUtil.getInsertColumnValueSql(recordSet.getDBType(), 1) + ", '" + jobtitlecode + "')"; // 创建 + execSql(sqlInsert); + HrmTriggerUtil.generateJobtitlesPinyin(jobtitlename, null); + jobtitle = getResultSetId(selSql); + + HrmFaceCheckManager.sync(jobtitle + "", HrmFaceCheckManager.getOptInsert(), "hrm_e9_import_getJobtitles", HrmFaceCheckManager.getOaJobtitle()); + + } else { + selSql = "select * from HrmJobTitles where id = '" + jobtitle + "' and jobactivityid = '" + jobactivityid + "' "; + recordSet.executeSql(selSql); + if (!recordSet.next()) {//查询这个名称已存在的岗位,对应的职务是否存在。如果对应职务的岗位不存在,则说明岗位对应的职务和职务类别有更新 + sqlInsert = "update HrmJobTitles set jobactivityid = '" + jobactivityid + "'," + DbFunctionUtil.getUpdateSetSql(rs.getDBType(), 1) + " where id = '" + jobtitle + "' "; + rs.executeSql(sqlInsert); + } + } + return jobtitle; + } + + public static boolean needCheckLicenseForUpdate(ResourceComInfo resourceComInfo, String hrmId, HrmResourceVo vo) { String statusOfHrmId = resourceComInfo.getStatus(hrmId); String loginidOfHrmId = resourceComInfo.getLoginID(hrmId); @@ -2209,10 +2235,10 @@ public class HrmImportProcessE9 extends BaseBean { String managerstr; RecordSet recordSet = new RecordSet(); Map managerInfo = new HashMap<>(); - if (!keyFieldValue.equals("")) { + if (!"".equals(keyFieldValue)) { // String selSql = "select id,managerstr from hrmResource where " + keyField + "='" + keyFieldValue + "'"; String selSql = "select id,managerstr from hrmResource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { selSql = "select id,managerstr from hrmResource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; } recordSet.execute(selSql); @@ -2244,10 +2270,10 @@ public class HrmImportProcessE9 extends BaseBean { int getAssistantid = 0; RecordSet recordSet = new RecordSet(); - if (!keyFieldValue.equals("")) { + if (!"".equals(keyFieldValue)) { // String selSql = "select id from hrmResource where " + keyField + "='" + keyFieldValue + "'"; String selSql = "select id from hrmResource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { selSql = "select id from hrmResource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; } getAssistantid = getResultSetId(selSql); @@ -2265,10 +2291,10 @@ public class HrmImportProcessE9 extends BaseBean { public int getBelongId(String keyFieldValue, String keyField) { int getAssistantid = -1; RecordSet recordSet = new RecordSet(); - if (!keyFieldValue.equals("")) { + if (!"".equals(keyFieldValue)) { // String selSql = "select id from hrmResource where " + keyField + "='" + keyFieldValue + "'"; String selSql = "select id from hrmResource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { + if ("oracle".equalsIgnoreCase(recordSet.getDBType()) || DialectUtil.isMySql(recordSet.getDBType()) || "postgresql".equalsIgnoreCase(recordSet.getDBType())) { selSql = "select id from hrmResource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; } getAssistantid = getResultSetId(selSql); @@ -2284,7 +2310,7 @@ public class HrmImportProcessE9 extends BaseBean { */ public int getLocationid(String locationname) { int locationid = 0; - if (!locationname.equals("")) { + if (!"".equals(locationname)) { locationid = locationMap.getOrDefault(locationname, 0); if (locationid == 0) { String insertSql = "insert into HrmLocations(locationname,locationdesc,countryid) values('" + locationname + "','" + locationname + "',1)"; @@ -2305,7 +2331,7 @@ public class HrmImportProcessE9 extends BaseBean { */ public int getUseKind(String usekindname) { int usekindid = 0; - if (!usekindname.equals("")) { + if (!"".equals(usekindname)) { usekindid = usekindMap.getOrDefault(usekindname, 0); if (usekindid == 0) { String insertSql = "insert into HrmUseKind(name,description) values('" + usekindname + "','" + usekindname + "')"; @@ -2327,7 +2353,7 @@ public class HrmImportProcessE9 extends BaseBean { public int getJobcall(String jobcall) { int jobcalld = 0; - if (!jobcall.equals("")) { + if (!"".equals(jobcall)) { jobcalld = jobcallMap.getOrDefault(jobcall, 0); if (jobcalld == 0) { String insertSql = "insert into HrmJobCall(name) values('" + jobcall + "')"; @@ -2354,13 +2380,14 @@ public class HrmImportProcessE9 extends BaseBean { //return -1; //如果系统不支持多语言,则返回0 - if ((language.equals("English") || language.equals("繁體中文")) && !multilanguage.equalsIgnoreCase("y")) + if (("English".equals(language) || "繁體中文".equals(language)) && !"y".equalsIgnoreCase(multilanguage)) { return 0; + } - if (!language.equals("")) { - if (language.equals("简体中文")) + if (!"".equals(language)) { + if ("简体中文".equals(language)) { systemlanguageid = cnLanguageId; - else { + } else { systemlanguageid = sysLanguage.getOrDefault(language, -1); } } @@ -2375,7 +2402,7 @@ public class HrmImportProcessE9 extends BaseBean { */ public int getBankId(String bank1) { int id = 0; - if (!bank1.equals("")) { + if (!"".equals(bank1)) { String insertSql = "insert into hrmbank(bankname,bankdesc) values('" + bank1 + "','" + bank1 + "')"; execSql(insertSql); String selSql = "select id from hrmbank where bankname='" + bank1 + "'"; @@ -2454,7 +2481,7 @@ public class HrmImportProcessE9 extends BaseBean { */ public int getEducationlevel(String educationlevel) { int educationlevelid = 0; - if (!educationlevel.equals("")) { + if (!"".equals(educationlevel)) { educationlevelid = educationlevelMap.getOrDefault(educationlevel, 0); if (educationlevelid == 0) { String insertSql = "insert into HrmEducationLevel(name,description) values('" + educationlevel + "','" + educationlevel + "')"; @@ -2504,7 +2531,7 @@ public class HrmImportProcessE9 extends BaseBean { RecordSet recordSet = new RecordSet(); String sql; sql = "select id, accounttype,isADAccount,certificatenum,loginid,workcode, ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from hrmResource"; - if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + if ("sqlserver".equalsIgnoreCase(recordSet.getDBType())) { sql = "select id, accounttype,isADAccount,certificatenum,loginid,workcode, ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from hrmResource"; } recordSet.execute(sql); @@ -2585,10 +2612,11 @@ public class HrmImportProcessE9 extends BaseBean { log.setLastname(vo.getLastname()); //用户名 log.setLoginid(vo.getLoginid()); //登录名 log.setOperation(operation); //操作类型 - if (vo.getSubcompanyid1() != null && vo.getDepartmentid() != null) + if (vo.getSubcompanyid1() != null && vo.getDepartmentid() != null) { log.setDepartment(vo.getSubcompanyid1() + ">" + vo.getDepartmentid()); //分部部门 - else + } else { log.setDepartment(""); + } log.setStatus(status); //状态,成功、失败 log.setReason(reason); //原因 @@ -2605,7 +2633,7 @@ public class HrmImportProcessE9 extends BaseBean { relatedName = log.getLastname(); break; } - MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid((long) this.pId).rowNums(this.rowNum + 1 + "").relatedName(relatedName).operateDetail(log.getStatus().equals("成功") ? relatedName + "导入成功!" : log.getReason()).status(log.getStatus().equals("成功") ? "1" : "0").build()); + MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(JclImportHistoryDetailPO.builder().pid((long) this.pId).rowNums(this.rowNum + 1 + "").relatedName(relatedName).operateDetail("成功".equals(log.getStatus()) ? relatedName + "导入成功!" : log.getReason()).status("成功".equals(log.getStatus()) ? "1" : "0").build()); } catch (Exception e) { writeLog(e); } @@ -2614,8 +2642,9 @@ public class HrmImportProcessE9 extends BaseBean { //整数判断 public static boolean isInteger(String str) { - if (str == null) + if (str == null) { return false; + } Pattern pattern = Pattern.compile("[0-9]+"); return pattern.matcher(str).matches(); } @@ -2650,7 +2679,7 @@ public class HrmImportProcessE9 extends BaseBean { } if (reosurceid > 0 && val.length() > 0) { - resultList.add(createLog(vo, this.operateType.equals("add") ? "创建" : "更新", "失败", errorMsg)); + resultList.add(createLog(vo, "add".equals(this.operateType) ? "创建" : "更新", "失败", errorMsg)); return true; } } diff --git a/src/com/engine/organization/util/tree/SearchTreeUtil.java b/src/com/engine/organization/util/tree/SearchTreeUtil.java index 3bc9891a..65dd9617 100644 --- a/src/com/engine/organization/util/tree/SearchTreeUtil.java +++ b/src/com/engine/organization/util/tree/SearchTreeUtil.java @@ -35,7 +35,7 @@ public class SearchTreeUtil { // 排序,设置是否为叶子节点 List collect = treeList.stream().peek(item -> item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs())) - ).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList()); + ).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { treeDatas.addAll(collect); } @@ -87,14 +87,16 @@ public class SearchTreeUtil { * @return */ public static List builderTreeMode(List treeList) { - List sortedList = treeList.stream().sorted(Comparator.comparing(SearchTree::getOrderNum)).collect(Collectors.toList()); - Map> collects = sortedList.stream().collect(Collectors.groupingBy(TreeNode::getPid)); + Map> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid)); Set leafIds = new HashSet<>(); - List collect = sortedList.stream().peek(e -> { - e.setSubs(collects.get(e.getId())); - leafIds.add(e.getId()); - if (CollectionUtils.isNotEmpty(e.getSubs())) { - e.setIsParent(true); + List collect = treeList.stream().peek(e -> { + if (null != collects && CollectionUtils.isNotEmpty(collects.get(e.getId()))) { + List nodes = collects.get(e.getId()).stream().sorted(Comparator.comparing(item -> null == item.getOrderNum() ? 0 : item.getOrderNum())).collect(Collectors.toList()); + e.setSubs(nodes); + leafIds.add(e.getId()); + if (CollectionUtils.isNotEmpty(e.getSubs())) { + e.setIsParent(true); + } } }).collect(Collectors.toList()); return collect.stream().filter(item -> !leafIds.contains(item.getPid())).collect(Collectors.toList()); @@ -113,13 +115,14 @@ public class SearchTreeUtil { boolean isAdd = !childMap.isEmpty(); Set leafIds = new HashSet<>(); List collect = treeList.stream().peek(e -> { - Set treeNodes = new HashSet<>(); + Set treeNodes = new LinkedHashSet<>(); List nodes = parentMap.get(e.getId()); if (CollectionUtils.isNotEmpty(nodes)) { treeNodes.addAll(nodes); } if (isAdd && CollectionUtils.isNotEmpty(childMap.get(e.getId()))) { - treeNodes.addAll(childMap.get(e.getId())); + List searchTrees = childMap.get(e.getId()).stream().sorted(Comparator.comparing(SearchTree::getOrderNum)).collect(Collectors.toList()); + treeNodes.addAll(searchTrees); } if (CollectionUtils.isNotEmpty(e.getSubs())) { treeNodes.addAll(e.getSubs()); @@ -153,4 +156,8 @@ public class SearchTreeUtil { public static boolean isTop(Long pid) { return null == pid; } + + public static boolean isTop(Integer pid) { + return null == pid; + } } diff --git a/src/com/engine/organization/util/word/CustomXWPFDocument.java b/src/com/engine/organization/util/word/CustomXWPFDocument.java new file mode 100644 index 00000000..9c889cba --- /dev/null +++ b/src/com/engine/organization/util/word/CustomXWPFDocument.java @@ -0,0 +1,144 @@ +package com.engine.organization.util.word; + +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlToken; +import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; +import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; + +import java.io.IOException; +import java.io.InputStream; + +public class CustomXWPFDocument extends XWPFDocument { + + public CustomXWPFDocument(InputStream in) throws IOException { + super(in); + } + + public CustomXWPFDocument() { + super(); + } + + public CustomXWPFDocument(OPCPackage pkg) throws IOException { + super(pkg); + } + + /** + * @param id + * @param width 宽 + * @param height 高 + * @param paragraph 段落 + */ + public void createPicture(String blipId,int id, int width, int height, XWPFParagraph paragraph, CustomXWPFDocument doc) { + final int EMU = 9525; + width *= EMU; + height *= EMU; + CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); + String picXml = "" + + "" + + " " + + " " + + " " + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + ""; + + inline.addNewGraphic().addNewGraphicData(); + XmlToken xmlToken = null; + try { + xmlToken = XmlToken.Factory.parse(picXml); + } catch (XmlException xe) { + xe.printStackTrace(); + } + inline.set(xmlToken); + + CTPositiveSize2D extent = inline.addNewExtent(); + extent.setCx(width); + extent.setCy(height); + + CTNonVisualDrawingProps docPr = inline.addNewDocPr(); + docPr.setId(id); + docPr.setName("图片" + blipId); + docPr.setDescr("头像"); + } + + public void createPicture(String blipId, int id, int width, int height, XWPFParagraph paragraph) { + final int EMU = 9525; + width *= EMU; + height *= EMU; + //String blipId = getAllPictures().get(id).getPackageRelationship().getId(); + CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); + + String picXml = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + inline.addNewGraphic().addNewGraphicData(); + XmlToken xmlToken = null; + try { + xmlToken = XmlToken.Factory.parse(picXml); + } catch (XmlException xe) { + xe.printStackTrace(); + } + inline.set(xmlToken); + + CTPositiveSize2D extent = inline.addNewExtent(); + extent.setCx(width); + extent.setCy(height); + + CTNonVisualDrawingProps docPr = inline.addNewDocPr(); + docPr.setId(id); + docPr.setName("图片" + id); + docPr.setDescr("头像"); + } +} \ No newline at end of file diff --git a/src/com/engine/organization/util/word/WordUtil.java b/src/com/engine/organization/util/word/WordUtil.java new file mode 100644 index 00000000..d7e25eec --- /dev/null +++ b/src/com/engine/organization/util/word/WordUtil.java @@ -0,0 +1,323 @@ +package com.engine.organization.util.word; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.xwpf.usermodel.*; +import weaver.file.ImageFileManager; +import weaver.general.Util; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class WordUtil { + + /** + * 替换段落里面的变量 + * + * @param doc 要替换的文档 + * @param params 参数 + * @throws FileNotFoundException + * @throws InvalidFormatException + */ + public void replaceInPara(CustomXWPFDocument doc, Map params) throws InvalidFormatException, FileNotFoundException { + Iterator iterator = doc.getParagraphsIterator(); + XWPFParagraph para; + while (iterator.hasNext()) { + para = iterator.next(); + this.replaceInPara(para, params,doc); + } + } + + /** + * 替换段落里面的变量 + * + * @param para 要替换的段落 + * @param params 参数 + * @throws FileNotFoundException + * @throws InvalidFormatException + */ + public void replaceInPara(XWPFParagraph para, Map params, CustomXWPFDocument doc) throws InvalidFormatException, FileNotFoundException { + List runs; + Matcher matcher; + if (this.matcher(para.getParagraphText()).find()) { + runs = para.getRuns(); + + int start = -1; + int end = -1; + String str = ""; + String text= ""; + for (int i = 0; i < runs.size(); i++) { + text += runs.get(i).toString(); + } + for (int i = 0; i < runs.size(); i++) { + XWPFRun run = runs.get(i); +// System.out.println("------>>>>>>>>>" + text); + if (text.contains("$")) { + start = text.indexOf("$"); + } + if ((start != -1)) { + str += text.substring(text.indexOf("$"), text.length()).trim(); + String paraList=runs.toString(); +// System.out.println("未删除前"+paraList); + Object[] runArr = runs.toArray(); + int size=runs.size(); + int $Index=0; + for (int j = 0; j < runArr.length; j++) { + if (runArr[j].toString().contains("$")) { + $Index=j; + break; + } + } + int startIn=$Index; + while (startIn"+start); +// System.out.println("end--->"+end); +// System.out.println("str---->>>" + str); + + for (String key : params.keySet()) { + if (str.equals(key)) { + if(str.indexOf("@")==-1){ + String value= params.get(key).toString(); + para.createRun().setText(value); + break; + }else{ + String value= params.get(key).toString(); + if (StringUtils.isBlank(value)){ + break; + } + int length = para.getRuns().size(); + if (length > 0) { + for (int i = (length - 1); i >= 0; i--) { + para.removeRun(i); + } + } + //网络图片取文件数据 + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(value)); + InputStream inputStream = manager.getInputStream(); + + byte[] buff = new byte[8000]; + int bytesRead = 0; + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + while(true) { + try { + if (!((bytesRead = inputStream.read(buff)) != -1)) break; + } catch (IOException e) { + e.printStackTrace(); + } + bao.write(buff, 0, bytesRead); + } + byte[] data = bao.toByteArray(); + ByteArrayInputStream byteInputStream = new ByteArrayInputStream(data); + + String blipId = doc.addPictureData(byteInputStream, CustomXWPFDocument.PICTURE_TYPE_PNG); + doc.createPicture(blipId,doc.getNextPicNameNumber(CustomXWPFDocument.PICTURE_TYPE_PNG), 120, 180,para); + break; + } + } + } + + + } + } + + /** + * 替换表格里面的变量 + * + * @param doc 要替换的文档 + * @param params 参数 + * @throws FileNotFoundException + * @throws InvalidFormatException + */ + public void replaceInTable(CustomXWPFDocument doc, Map params) throws InvalidFormatException, FileNotFoundException { + Iterator iterator = doc.getTablesIterator(); + XWPFTable table; + List rows; + List cells; + List paras; + while (iterator.hasNext()) { + table = iterator.next(); + // 根据数据量从10行开始新增 + int sbLengths = (int) params.get("sbDataCounts"); + int jtLengths = (int) params.get("jtDataCounts"); + for (int i = 1; i < sbLengths;i++){ + insertRow(table,9,9+i,i); + } + for (int i = 1; i < jtLengths;i++){ + insertRow(table,12+sbLengths-1,12+sbLengths-1+i,i); + } + rows = table.getRows(); + for (XWPFTableRow row : rows) { + cells = row.getTableCells(); + for (XWPFTableCell cell : cells) { + paras = cell.getParagraphs(); + for (XWPFParagraph para : paras) { + this.replaceInPara(para, params,doc); + } + } + } + } + } + + /** + * insertRow 在word表格中指定位置插入一行,并将某一行的样式复制到新增行 + * @param copyrowIndex 需要复制的行位置 + * @param newrowIndex 需要新增一行的位置 + * @param jgIndex 间隔行 + * */ + public static void insertRow(XWPFTable table, int copyrowIndex, int newrowIndex, int jgIndex) { + // 在表格中指定的位置新增一行 + XWPFTableRow targetRow = table.insertNewTableRow(newrowIndex); + // 获取需要复制行对象 + XWPFTableRow copyRow = table.getRow(copyrowIndex); + //复制行对象 + targetRow.getCtRow().setTrPr(copyRow.getCtRow().getTrPr()); + //或许需要复制的行的列 + List copyCells = copyRow.getTableCells(); + //复制列对象 + XWPFTableCell targetCell = null; + for (int i = 0; i < copyCells.size(); i++) { + XWPFTableCell copyCell = copyCells.get(i); + targetCell = targetRow.addNewTableCell(); + targetCell.getCTTc().setTcPr(copyCell.getCTTc().getTcPr()); + if (copyCell.getParagraphs() != null && copyCell.getParagraphs().size() > 0) { + XWPFParagraph targetParagraph = (XWPFParagraph)targetCell.getParagraphs().get(0); + XWPFParagraph copyParagraph = (XWPFParagraph)copyCell.getParagraphs().get(0); + targetParagraph.getCTP().setPPr(copyParagraph.getCTP().getPPr()); + if (copyParagraph.getRuns() != null && copyParagraph.getRuns().size() > 0) { + XWPFRun cellR = targetParagraph.createRun(); + String copyText = copyParagraph.getText(); + //截取到${c后两位,第一位:0表示社保表,1表示家庭成员表,第二位表示列 + String lastText = copyText.substring(copyText.length()-4,copyText.length()-1); + int num = Util.getIntValue(lastText)+ jgIndex; + String newText = copyText.substring(0,5) + num + "}"; + cellR.setText(newText); + cellR.setBold(((XWPFRun)copyParagraph.getRuns().get(0)).isBold()); + } + } + } + + } + + /** + * 正则匹配字符串 + * + * @param str + * @return + */ + private Matcher matcher(String str) { + Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(str); + return matcher; + } + + /** + * 关闭输入流 + * + * @param is + */ + public void close(InputStream is) { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 关闭输出流 + * + * @param os + */ + public void close(OutputStream os) { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 功能描述:读取线上图片文件流 + * + * @param strUrl + * @return + * @see [相关类/方法](可选) + * @since [产品/模块版本](可选) + */ + public static byte[] getImageData(String strUrl) { + InputStream inStream = null; + try { + // new一个URL对象 + URL url = new URL(strUrl); + // 打开链接 + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + // 设置请求方式为"GET" + conn.setRequestMethod("GET"); + // 超时响应时间为5秒 + conn.setConnectTimeout(10 * 1000); + // 通过输入流获取图片数据 + inStream = conn.getInputStream(); + byte[] data = readInputStream(inStream); + return data; + } catch (Exception e) { + return null; + } finally { + if (inStream != null) { + try { + inStream.close(); + } catch (Exception e2) { + System.out.println("关闭流失败"); + } + } + } + + } + + /** + * 功能描述:读取文件流 + * + * @param inStream + * @return + * @throws Exception + * @see [相关类/方法](可选) + * @since [产品/模块版本](可选) + */ + public static byte[] readInputStream(InputStream inStream) throws Exception { + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + // 创建一个Buffer字符串 + byte[] buffer = new byte[1024]; + // 每次读取的字符串长度,如果为-1,代表全部读取完毕 + int len = 0; + // 使用一个输入流从buffer里把数据读取出来 + while ((len = inStream.read(buffer)) != -1) { + // 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度 + outStream.write(buffer, 0, len); + } + // 关闭输入流 + inStream.close(); + // 把outStream里的数据写入内存 + return outStream.toByteArray(); + } +} \ No newline at end of file diff --git a/src/com/engine/organization/web/CardAccessController.java b/src/com/engine/organization/web/CardAccessController.java index 0775e1b9..2ea30535 100644 --- a/src/com/engine/organization/web/CardAccessController.java +++ b/src/com/engine/organization/web/CardAccessController.java @@ -79,4 +79,17 @@ public class CardAccessController { return ReturnResult.exceptionHandle(e); } } + + @POST + @Path("/saveCardButton") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult saveCardButton(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getCardAccessWrapper(user).saveCardButton(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } } diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index 549789f2..6ee763de 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -3,7 +3,7 @@ package com.engine.organization.web; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.organization.entity.DeleteParam; -import com.engine.organization.entity.company.param.CompSearchParam; +import com.engine.organization.entity.company.param.CompParam; import com.engine.organization.entity.department.param.DepartmentMoveParam; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.CompWrapper; @@ -43,12 +43,12 @@ public class CompController { @POST @Path("/listComp") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult listComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompSearchParam params) { + public ReturnResult listComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompParam params) { try { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).listPage(params)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -63,10 +63,10 @@ public class CompController { @POST @Path("/saveBaseComp") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map params) { + public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - return ReturnResult.successed(getCompWrapper(user).saveBaseComp(params)); + return ReturnResult.successed(getCompWrapper(user).saveBaseComp(ParamUtil.request2Map(request))); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } @@ -83,12 +83,12 @@ public class CompController { @POST @Path("/updateForbiddenTagById") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult updateForbiddenTagById(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompSearchParam param) { + public ReturnResult updateForbiddenTagById(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CompParam param) { try { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).updateForbiddenTagById(param)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -108,7 +108,7 @@ public class CompController { Map map = ParamUtil.request2Map(request); return ReturnResult.successed(getCompWrapper(user).updateComp(map)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -118,7 +118,6 @@ public class CompController { * * @param request * @param response - * @param param * @return */ @POST @@ -129,7 +128,7 @@ public class CompController { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).deleteByIds(param.getIds())); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -146,10 +145,9 @@ public class CompController { public ReturnResult getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - Map map = ParamUtil.request2Map(request); - return ReturnResult.successed(getCompWrapper(user).getSearchCondition(map)); + return ReturnResult.successed(getCompWrapper(user).getSearchCondition()); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -168,7 +166,7 @@ public class CompController { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).getHasRight()); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -185,10 +183,10 @@ public class CompController { public ReturnResult getCompBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - Map map = ParamUtil.request2Map(request); - return ReturnResult.successed(getCompWrapper(user).getCompBaseForm(map)); + Map params = ParamUtil.request2Map(request); + return ReturnResult.successed(getCompWrapper(user).getCompBaseForm(params)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -206,9 +204,10 @@ public class CompController { public ReturnResult getCompSaveForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - return ReturnResult.successed(getCompWrapper(user).getCompSaveForm()); + Map params = ParamUtil.request2Map(request); + return ReturnResult.successed(getCompWrapper(user).getCompSaveForm(params)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -220,7 +219,7 @@ public class CompController { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).getMoveForm()); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } @@ -232,7 +231,7 @@ public class CompController { User user = HrmUserVarify.getUser(request, response); return ReturnResult.successed(getCompWrapper(user).moveCompany(param)); } catch (Exception e) { - return ReturnResult.exceptionHandle(e); + return ReturnResult.exceptionHandle(e); } } diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java index edd39910..bba9f0c9 100644 --- a/src/com/engine/organization/web/DepartmentController.java +++ b/src/com/engine/organization/web/DepartmentController.java @@ -56,7 +56,7 @@ public class DepartmentController { User user = HrmUserVarify.getUser(request, response); Map map = ParamUtil.request2Map(request); String parentDept = (String) map.get("parentDept"); - return ReturnResult.successed(getDepartmentWrapper(user).getJobListByPid(QuerySingleDeptListParam.builder().parentDept(Long.parseLong(parentDept)).build())); + return ReturnResult.successed(getDepartmentWrapper(user).getJobListByPid(QuerySingleDeptListParam.builder().parentDept(Integer.parseInt(parentDept)).build())); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } @@ -105,15 +105,15 @@ public class DepartmentController { * * @param request * @param response - * @param params * @return */ @POST @Path("/saveBaseForm") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map params) { + public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); return ReturnResult.successed(getDepartmentWrapper(user).saveBaseForm(params)); } catch (Exception e) { return ReturnResult.exceptionHandle(e); @@ -253,9 +253,8 @@ public class DepartmentController { public ReturnResult getSaveForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - Map map = ParamUtil.request2Map(request); - DeptSearchParam param = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), DeptSearchParam.class); - return ReturnResult.successed(getDepartmentWrapper(user).getSaveForm(param)); + Map params = ParamUtil.request2Map(request); + return ReturnResult.successed(getDepartmentWrapper(user).getSaveForm(params)); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } @@ -292,9 +291,7 @@ public class DepartmentController { public ReturnResult getMergeForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { try { User user = HrmUserVarify.getUser(request, response); - Map map = ParamUtil.request2Map(request); - String id = (String) map.get("id"); - return ReturnResult.successed(getDepartmentWrapper(user).getMergeForm(Long.parseLong(id))); + return ReturnResult.successed(getDepartmentWrapper(user).getMergeForm()); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } diff --git a/src/com/engine/organization/web/HrmResourceController.java b/src/com/engine/organization/web/HrmResourceController.java index c9d101fd..9862e3e4 100644 --- a/src/com/engine/organization/web/HrmResourceController.java +++ b/src/com/engine/organization/web/HrmResourceController.java @@ -5,11 +5,13 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; -import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam; +import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; +import com.engine.organization.entity.hrmresource.po.SearchTemplatePO; import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.HrmResourceWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.general.Util; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -65,8 +67,7 @@ public class HrmResourceController { try { User user = HrmUserVarify.getUser(request, response); Map map = ParamUtil.request2Map(request); - HrmResourceSearchParam param = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), HrmResourceSearchParam.class); - return ReturnResult.successed(getHrmResourceWrapper(user).listPage(param)); + return ReturnResult.successed(getHrmResourceWrapper(user).listPage(map)); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } @@ -164,7 +165,60 @@ public class HrmResourceController { try { User user = HrmUserVarify.getUser(request, response); Map map = ParamUtil.request2Map(request); - return ReturnResult.successed(getHrmResourceWrapper(user).getSearchCondition(map)); + return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getSearchCondition(map))); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + + @POST + @Path("/saveSearchTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult saveSearchTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplateParam params) { + try { + User user = HrmUserVarify.getUser(request, response); + Integer templateId = getHrmResourceWrapper(user).saveSearchTemplate(params); + return ReturnResult.successed(Util.null2String(templateId)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @POST + @Path("/deleteSearchTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult deleteSearchTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplatePO params) { + try { + User user = HrmUserVarify.getUser(request, response); + getHrmResourceWrapper(user).deleteSearchTemplate(params.getId()); + return ReturnResult.successed(); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @GET + @Path("/getTemplateSelectKeys") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getTemplateSelectKeys(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getTemplateSelectKeys(map))); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @GET + @Path("/getSearchTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getSearchTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getSearchTemplate(map))); } catch (Exception e) { return ReturnResult.exceptionHandle(e); } @@ -225,4 +279,99 @@ public class HrmResourceController { return ReturnResult.exceptionHandle(e); } } + + @POST + @Path("/saveCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult saveCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplateParam params) { + try { + User user = HrmUserVarify.getUser(request, response); + Integer templateId = getHrmResourceWrapper(user).saveCustomTemplate(params); + return ReturnResult.successed(Util.null2String(templateId)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @POST + @Path("/deleteCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult deleteCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplatePO params) { + try { + User user = HrmUserVarify.getUser(request, response); + getHrmResourceWrapper(user).deleteCustomTemplate(params.getId()); + return ReturnResult.successed(); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @GET + @Path("/getCustomTransferData") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getCustomTransferData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getCustomTransferData(map))); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + /** + * 列定制模板管理模板查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + return ReturnResult.successed(getHrmResourceWrapper(user).getCustomTemplate(params)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + /** + * 列定制模板管理模板保存 + * @param request + * @param response + * @return + */ + @POST + @Path("/updateCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult updateCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + Integer templateId = getHrmResourceWrapper(user).updateCustomTemplate(map); + return ReturnResult.successed(Util.null2String(templateId)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + /** + * 列定制保存 + */ + @POST + @Path("/saveColumnsCustomTemplate") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult saveColumnsCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getHrmResourceWrapper(user).saveColumnsCustomTemplate(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + } diff --git a/src/com/engine/organization/web/JclOrgController.java b/src/com/engine/organization/web/JclOrgController.java index 918350f0..ff89c56f 100644 --- a/src/com/engine/organization/web/JclOrgController.java +++ b/src/com/engine/organization/web/JclOrgController.java @@ -72,4 +72,19 @@ public class JclOrgController { return ReturnResult.exceptionHandle(e); } } + + @GET + @Path("/supplementResourceInfo") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult supplementResourceInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + String id = Util.null2String(map.get("id")); + getJclOrgWrapper(user).supplementResourceInfo(Integer.parseInt(id)); + return ReturnResult.successed(); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } } diff --git a/src/com/engine/organization/web/JobController.java b/src/com/engine/organization/web/JobController.java index 8f58ef52..5235a96f 100644 --- a/src/com/engine/organization/web/JobController.java +++ b/src/com/engine/organization/web/JobController.java @@ -232,6 +232,19 @@ public class JobController { } } + @GET + @Path("/refresh") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult refresh(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + getJobWrapper(user).refresh(); + return ReturnResult.successed(); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + /** * 高级搜索条件 * diff --git a/src/com/engine/organization/web/OrgChartController.java b/src/com/engine/organization/web/OrgChartController.java index d63eb0fc..c3bec336 100644 --- a/src/com/engine/organization/web/OrgChartController.java +++ b/src/com/engine/organization/web/OrgChartController.java @@ -3,6 +3,7 @@ package com.engine.organization.web; import com.alibaba.fastjson.JSONObject; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; +import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.OrgChartWrapper; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -17,12 +18,7 @@ import javax.ws.rs.core.MediaType; import java.util.HashMap; import java.util.Map; -/** - * @className: OrgChartController - * @author: dengjp - * @date: 2022/7/7 - * @description: 组织架构图 - **/ + public class OrgChartController { public OrgChartWrapper getOrgChartWrapper(User user) { return ServiceUtil.getService(OrgChartWrapper.class, user); @@ -51,6 +47,28 @@ public class OrgChartController { return JSONObject.toJSONString(apidatas); } + + + @GET + @Path("/getSubCompanyTree") + @Produces(MediaType.APPLICATION_JSON) + public String getSubCompanyTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap<>(); + try { + User user = HrmUserVarify.getUser(request, response); + //实例化Service 并调用业务类处理 + apidatas = getOrgChartWrapper(user).getSubCompanyTree(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + //异常处理 + e.printStackTrace(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", "catch exception : " + e.getMessage()); + } + //数据转换 + return JSONObject.toJSONString(apidatas); + } + /** * 组织架构数据 */ @@ -143,4 +161,21 @@ public class OrgChartController { return JSONObject.toJSONString(apidatas); } + /** + * 异步组织数据 + */ + @GET + @Path("/synchronousData") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult synchronousData(@Context HttpServletRequest request, @Context HttpServletResponse + response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + return ReturnResult.successed(getOrgChartWrapper(user).synchronousData(params)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + } diff --git a/src/com/engine/organization/web/OrgVirtualController.java b/src/com/engine/organization/web/OrgVirtualController.java new file mode 100644 index 00000000..61ad0497 --- /dev/null +++ b/src/com/engine/organization/web/OrgVirtualController.java @@ -0,0 +1,44 @@ +package com.engine.organization.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.OrgVirtualWrapper; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @Author liang.cheng + * @Date 2023/6/27 3:41 PM + * @Description: TODO + * @Version 1.0 + */ +public class OrgVirtualController { + + public OrgVirtualWrapper getVirtualWrapper(User user) { + return ServiceUtil.getService(OrgVirtualWrapper.class, user); + } + + @GET + @Path("/getTable") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult listOrgVirtual(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getVirtualWrapper(user).listPage(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + +} diff --git a/src/com/engine/organization/web/PersonnelResumeController.java b/src/com/engine/organization/web/PersonnelResumeController.java new file mode 100644 index 00000000..6d67f7eb --- /dev/null +++ b/src/com/engine/organization/web/PersonnelResumeController.java @@ -0,0 +1,130 @@ +package com.engine.organization.web; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.api.browser.bean.SearchConditionGroup; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.searchtree.SearchTreeParams; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.PersonnelResumeWrapper; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import javax.ws.rs.core.Response; +import java.io.*; +import java.net.URLEncoder; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +public class PersonnelResumeController { + public PersonnelResumeWrapper getPersonnelResumeWrapper(User user) { + return ServiceUtil.getService(PersonnelResumeWrapper.class, user); + } + + /** + * 左侧树接口 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchTree") + @Produces(MediaType.APPLICATION_JSON) + public Map getSearchTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + SearchTreeParams params = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), SearchTreeParams.class); + return getPersonnelResumeWrapper(user).getSearchTree(params); + } + + @GET + @Path("/hasRight") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult hasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getPersonnelResumeWrapper(user).hasRight()); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + + } + + @GET + @Path("/getResumeList") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getResumeList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + Integer uId = Integer.parseInt(Util.null2String(map.get("id"))); + return ReturnResult.successed(getPersonnelResumeWrapper(user).getResumeList(uId)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + + } + + @GET + @Path("/personnelScreening") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult personnelScreening(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map returnMap = new HashMap<>(); + List addGroups = new ArrayList<>(); + addGroups.add(new SearchConditionGroup("高级搜索条件", true, getPersonnelResumeWrapper(user).personnelScreening())); + returnMap.put("conditions",addGroups); + return ReturnResult.successed(returnMap); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + + } + + /** + * 人员简历下载 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/downloadPerResume") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadPerResume(@Context HttpServletRequest request, @Context HttpServletResponse response) throws Exception { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + // type: 0:合并 1:不合并 + Integer type = Integer.parseInt(Util.null2String(map.get("type"))); + + String realPath = getPersonnelResumeWrapper(user).downloadPerResume(type,response); + File file = new File(realPath); + // 如果文件不存在,提示404 + if (!file.exists()) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + String fileName = URLEncoder.encode(file.getName(), "UTF-8"); + return Response + .ok(file) + .header("Content-disposition", "attachment;filename=" + fileName) + .header("Cache-Control", "no-cache").build(); + } +} diff --git a/src/com/engine/organization/web/VersionManageController.java b/src/com/engine/organization/web/VersionManageController.java new file mode 100644 index 00000000..fd873077 --- /dev/null +++ b/src/com/engine/organization/web/VersionManageController.java @@ -0,0 +1,59 @@ +package com.engine.organization.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.enums.ModuleTypeEnum; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.VersionManageWrapper; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: 组织架构版本管理 + * @Date 2022/12/8 + * @Version V1.0 + **/ +public class VersionManageController { + + private VersionManageWrapper getVersionManageWrapper(User user){ + return ServiceUtil.getService(VersionManageWrapper.class, user); + } + + @POST + @Path("/{moduleTypeEnum}/save") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getTree(@Context HttpServletRequest request, @Context HttpServletResponse response, + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + getVersionManageWrapper(user).save(moduleTypeEnum,params); + return ReturnResult.successed(); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @GET + @Path("/{moduleTypeEnum}/getVersion") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getVersion(@Context HttpServletRequest request, @Context HttpServletResponse response, + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + Map map = getVersionManageWrapper(user).getVersion(moduleTypeEnum,params); + return ReturnResult.successed(map); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } +} diff --git a/src/com/engine/organization/wrapper/CardAccessWrapper.java b/src/com/engine/organization/wrapper/CardAccessWrapper.java index fcfc9605..a4d88489 100644 --- a/src/com/engine/organization/wrapper/CardAccessWrapper.java +++ b/src/com/engine/organization/wrapper/CardAccessWrapper.java @@ -35,4 +35,8 @@ public class CardAccessWrapper extends OrganizationWrapper { public Map getCardButtonTable() { return getCardAccessService(user).getCardButtonTable(); } + + public int saveCardButton(Map params) { + return getCardAccessService(user).saveCardButton(params); + } } diff --git a/src/com/engine/organization/wrapper/CompWrapper.java b/src/com/engine/organization/wrapper/CompWrapper.java index bb4ca578..05709f46 100644 --- a/src/com/engine/organization/wrapper/CompWrapper.java +++ b/src/com/engine/organization/wrapper/CompWrapper.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON; import com.api.browser.bean.SearchConditionGroup; import com.engine.common.util.ServiceUtil; import com.engine.organization.annotation.Log; -import com.engine.organization.entity.company.param.CompSearchParam; +import com.engine.organization.entity.company.param.CompParam; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.param.DepartmentMoveParam; import com.engine.organization.enums.LogModuleNameEnum; @@ -12,13 +12,13 @@ import com.engine.organization.enums.OperateTypeEnum; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.service.CompService; import com.engine.organization.service.impl.CompServiceImpl; -import com.engine.organization.thread.CompanyTriggerRunnable; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationWrapper; import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.lang.StringUtils; import weaver.hrm.User; -import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,7 +43,7 @@ public class CompWrapper extends OrganizationWrapper { * @param params * @return */ - public Map listPage(CompSearchParam params) { + public Map listPage(CompParam params) { return getCompService(user).listPage(params); } @@ -58,8 +58,8 @@ public class CompWrapper extends OrganizationWrapper { public Long saveBaseComp(Map params) { Long companyId = getCompService(user).saveBaseComp(params); writeOperateLog(new Object() { - }.getClass(), params.get("comp_name").toString(), JSON.toJSONString(params), "新增分部"); - new Thread(new CompanyTriggerRunnable(companyId)).start(); + }.getClass(), params.get("subcompanyname").toString(), JSON.toJSONString(params), "新增分部"); + //TODO new Thread(new CompanyTriggerRunnable(companyId)).start(); return companyId; } @@ -69,13 +69,13 @@ public class CompWrapper extends OrganizationWrapper { * @param params */ @Log(operateType = OperateTypeEnum.UPDATE, operateDesc = "更新分部禁用标识", operateModule = LogModuleNameEnum.COMPANY) - public int updateForbiddenTagById(CompSearchParam params) { + public int updateForbiddenTagById(CompParam params) { CompPO compPO = getCompMapper().listById(params.getId()); int updateForbiddenTagById = getCompService(user).updateForbiddenTagById(params); CompPO newCompPO = getCompMapper().listById(params.getId()); writeOperateLog(new Object() { - }.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, newCompPO); - new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); + }.getClass(), compPO.getSubCompanyName(), JSON.toJSONString(params), compPO, newCompPO); + //TODO new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); return updateForbiddenTagById; } @@ -87,13 +87,13 @@ public class CompWrapper extends OrganizationWrapper { */ @Log(operateType = OperateTypeEnum.UPDATE, operateDesc = "更新分部信息", operateModule = LogModuleNameEnum.COMPANY) public Long updateComp(Map params) { - long id = Long.parseLong(params.get("id").toString()); + Integer id = Integer.parseInt(params.get("id").toString()); CompPO compPO = getCompMapper().listById(id); Long companyId = getCompService(user).updateComp(params); CompPO newCompPO = getCompMapper().listById(id); writeOperateLog(new Object() { - }.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, newCompPO); - new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); + }.getClass(), compPO.getSubCompanyName(), JSON.toJSONString(params), compPO, newCompPO); + //TODO new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); return companyId; } @@ -103,15 +103,17 @@ public class CompWrapper extends OrganizationWrapper { * @param ids */ @Log(operateType = OperateTypeEnum.DELETE, operateDesc = "删除分部信息", operateModule = LogModuleNameEnum.COMPANY) - public int deleteByIds(Collection ids) { + public Map deleteByIds(List ids) { + Map params = new HashMap<>(); + params.put("id", StringUtils.join(ids, ",")); List compsByIds = getCompMapper().getCompsByIds(ids); - int deleteByIds = getCompService(user).deleteByIds(ids); + Map map = getCompService(user).deleteByIds(params); for (CompPO compsById : compsByIds) { writeOperateLog(new Object() { - }.getClass(), compsById.getCompName(), JSON.toJSONString(ids), "删除分部信息"); - new CompanyTriggerRunnable(compsById).run(); + }.getClass(), compsById.getSubCompanyName(), JSON.toJSONString(ids), "删除分部信息"); + //TODO new CompanyTriggerRunnable(compsById).run(); } - return deleteByIds; + return map; } /** @@ -122,23 +124,22 @@ public class CompWrapper extends OrganizationWrapper { */ @Log(operateType = OperateTypeEnum.MOVE, operateDesc = "转移分部", operateModule = LogModuleNameEnum.COMPANY) public int moveCompany(DepartmentMoveParam moveParam) { - CompPO compPO = getCompMapper().listById(moveParam.getId()); + CompPO compPO = getCompMapper().listById(moveParam.getId().intValue()); int moveCompany = getCompService(user).moveCompany(moveParam); - CompPO newCompPO = getCompMapper().listById(moveParam.getId()); + CompPO newCompPO = getCompMapper().listById(moveParam.getId().intValue()); writeOperateLog(new Object() { - }.getClass(), compPO.getCompName(), JSON.toJSONString(moveParam), compPO, newCompPO); - new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); + }.getClass(), compPO.getSubCompanyName(), JSON.toJSONString(moveParam), compPO, newCompPO); + //TODO new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start(); return moveCompany; } /** * 获取搜索条件 * - * @param params * @return */ - public Map getSearchCondition(Map params) { - return getCompService(user).getSearchCondition(params); + public Map getSearchCondition() { + return getCompService(user).getSearchCondition(); } /** @@ -165,8 +166,8 @@ public class CompWrapper extends OrganizationWrapper { * * @return */ - public Map getCompSaveForm() { - return getCompService(user).getCompSaveForm(); + public Map getCompSaveForm(Map params) { + return getCompService(user).getCompSaveForm(params); } /** diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java index 5767a9ce..0fb057db 100644 --- a/src/com/engine/organization/wrapper/DepartmentWrapper.java +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -15,15 +15,16 @@ import com.engine.organization.enums.OperateTypeEnum; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.service.DepartmentService; import com.engine.organization.service.impl.DepartmentServiceImpl; -import com.engine.organization.thread.DepartmentTriggerRunnable; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationWrapper; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.response.ReturnResult; +import org.apache.commons.lang.StringUtils; import weaver.hrm.User; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -83,8 +84,8 @@ public class DepartmentWrapper extends OrganizationWrapper { * * @return */ - public Map getSaveForm(DeptSearchParam param) { - return getDepartmentService(user).getSaveForm(param); + public Map getSaveForm(Map params) { + return getDepartmentService(user).getSaveForm(params); } /** @@ -97,8 +98,8 @@ public class DepartmentWrapper extends OrganizationWrapper { public Long saveBaseForm(Map params) { Long departmentId = getDepartmentService(user).saveBaseForm(params); writeOperateLog(new Object() { - }.getClass(), params.get("dept_name").toString(), JSON.toJSONString(params), "新增部门"); - new Thread(new DepartmentTriggerRunnable(departmentId)).start(); + }.getClass(), params.get("departmentname").toString(), JSON.toJSONString(params), "新增部门"); + // TODO new Thread(new DepartmentTriggerRunnable(departmentId)).start(); return departmentId; } @@ -114,8 +115,8 @@ public class DepartmentWrapper extends OrganizationWrapper { int updateForbiddenTagById = getDepartmentService(user).updateForbiddenTagById(params); DepartmentPO newDeptById = getDepartmentMapper().getDeptById(params.getId()); writeOperateLog(new Object() { - }.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, newDeptById); - new Thread(new DepartmentTriggerRunnable(params.getForbiddenTag(),deptById, newDeptById)).start(); + }.getClass(), deptById.getDepartmentName(), JSON.toJSONString(params), deptById, newDeptById); + // new Thread(new DepartmentTriggerRunnable(params.getForbiddenTag(),deptById, newDeptById)).start(); return updateForbiddenTagById; } @@ -127,12 +128,12 @@ public class DepartmentWrapper extends OrganizationWrapper { */ @Log(operateType = OperateTypeEnum.UPDATE, operateDesc = "更新部门", operateModule = LogModuleNameEnum.DEPARTMENT) public Long updateForm(Map params) { - long id = Long.parseLong(params.get("id").toString()); + Integer id = Integer.parseInt(params.get("id").toString()); DepartmentPO deptById = getDepartmentMapper().getDeptById(id); Long departmentId = getDepartmentService(user).updateForm(params); DepartmentPO newDeptById = getDepartmentMapper().getDeptById(id); writeOperateLog(new Object() { - }.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, newDeptById); + }.getClass(), deptById.getDepartmentName(), JSON.toJSONString(params), deptById, newDeptById); return departmentId; } @@ -142,16 +143,18 @@ public class DepartmentWrapper extends OrganizationWrapper { * @param ids */ @Log(operateType = OperateTypeEnum.DELETE, operateDesc = "删除部门", operateModule = LogModuleNameEnum.DEPARTMENT) - public int deleteByIds(Collection ids) { + public Map deleteByIds(Collection ids) { + Map params = new HashMap<>(); + params.put("id", StringUtils.join(ids, ",")); List departmentPOS = getDepartmentMapper().getDeptsByIds(ids); - int deleteByIds = getDepartmentService(user).deleteByIds(ids); + Map map = getDepartmentService(user).deleteByIds(params); for (DepartmentPO departmentPO : departmentPOS) { writeOperateLog(new Object() { - }.getClass(), departmentPO.getDeptName(), JSON.toJSONString(ids), "删除部门"); + }.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(ids), "删除部门"); // 更新组织架构图 - new DepartmentTriggerRunnable(departmentPO).run(); + // TODO new DepartmentTriggerRunnable(departmentPO).run(); } - return deleteByIds; + return map; } /** @@ -204,7 +207,7 @@ public class DepartmentWrapper extends OrganizationWrapper { int copyDepartment = getDepartmentService(user).copyDepartment(copyParam); for (DepartmentPO departmentPO : departmentPOS) { writeOperateLog(new Object() { - }.getClass(), departmentPO.getDeptName(), JSON.toJSONString(copyParam), "复制部门[" + departmentPO.getDeptName() + "]"); + }.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(copyParam), "复制部门[" + departmentPO.getDepartmentName() + "]"); } return copyDepartment; } @@ -212,11 +215,10 @@ public class DepartmentWrapper extends OrganizationWrapper { /** * 获取合并表单 * - * @param id * @return */ - public List getMergeForm(Long id) { - return getDepartmentService(user).getMergeForm(id); + public List getMergeForm() { + return getDepartmentService(user).getMergeForm(); } /** @@ -230,7 +232,7 @@ public class DepartmentWrapper extends OrganizationWrapper { DepartmentPO departmentPO = getDepartmentMapper().getDeptById(mergeParam.getId()); int mergeDepartment = getDepartmentService(user).mergeDepartment(mergeParam); writeOperateLog(new Object() { - }.getClass(), departmentPO.getDeptName(), JSON.toJSONString(mergeParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId())); + }.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(mergeParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId())); return mergeDepartment; } @@ -254,7 +256,7 @@ public class DepartmentWrapper extends OrganizationWrapper { DepartmentPO departmentPO = getDepartmentMapper().getDeptById(moveParam.getId()); int moveDepartment = getDepartmentService(user).moveDepartment(moveParam); writeOperateLog(new Object() { - }.getClass(), departmentPO.getDeptName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId())); + }.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId())); return moveDepartment; } } diff --git a/src/com/engine/organization/wrapper/HrmResourceWrapper.java b/src/com/engine/organization/wrapper/HrmResourceWrapper.java index 93cbbb9f..37f8200b 100644 --- a/src/com/engine/organization/wrapper/HrmResourceWrapper.java +++ b/src/com/engine/organization/wrapper/HrmResourceWrapper.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON; import com.engine.common.util.ServiceUtil; import com.engine.organization.annotation.Log; import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; -import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam; +import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.enums.LogModuleNameEnum; import com.engine.organization.enums.OperateTypeEnum; @@ -30,7 +30,7 @@ public class HrmResourceWrapper extends OrganizationWrapper { return getHrmResourceService(user).getSearchTree(params); } - public Map listPage(HrmResourceSearchParam params) { + public Map listPage(Map params) { return getHrmResourceService(user).listPage(params); } @@ -59,6 +59,18 @@ public class HrmResourceWrapper extends OrganizationWrapper { return getHrmResourceService(user).getSearchCondition(params); } + public Integer saveSearchTemplate(SearchTemplateParam params) { + return getHrmResourceService(user).saveSearchTemplate(params); + } + + public void deleteSearchTemplate(Integer id) { + getHrmResourceService(user).deleteSearchTemplate(id); + } + + public String getTemplateSelectKeys(Map params) { + return getHrmResourceService(user).getTemplateSelectKeys(params); + } + public Map getHasRight() { return getHrmResourceService(user).getHasRight(); } @@ -75,4 +87,31 @@ public class HrmResourceWrapper extends OrganizationWrapper { return getHrmResourceService(user).updateTabForm(params); } + public Map getSearchTemplate(Map params) { + return getHrmResourceService(user).getSearchTemplate(params); + } + + public Integer saveCustomTemplate(SearchTemplateParam params) { + return getHrmResourceService(user).saveCustomTemplate(params); + } + + public Integer updateCustomTemplate(Map params) { + return getHrmResourceService(user).updateCustomTemplate(params); + } + + public void deleteCustomTemplate(Integer id) { + getHrmResourceService(user).deleteCustomTemplate(id); + } + + public Map getCustomTemplate(Map params){ + return getHrmResourceService(user).getCustomTemplate(params); + } + + public Map getCustomTransferData(Map params) { + return getHrmResourceService(user).getCustomTransferData(params); + } + + public Integer saveColumnsCustomTemplate(Map params) { + return getHrmResourceService(user).saveColumnsCustomTemplate(params); + } } diff --git a/src/com/engine/organization/wrapper/JclOrgWrapper.java b/src/com/engine/organization/wrapper/JclOrgWrapper.java index 393729f2..38c83bc0 100644 --- a/src/com/engine/organization/wrapper/JclOrgWrapper.java +++ b/src/com/engine/organization/wrapper/JclOrgWrapper.java @@ -1,10 +1,11 @@ package com.engine.organization.wrapper; -import com.engine.organization.entity.company.po.CompPO; -import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.service.JclOrgService; +import com.engine.organization.service.impl.JclOrgServiceImpl; import com.engine.organization.util.OrganizationWrapper; -import com.engine.organization.util.relation.EcHrmRelationUtil; import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; /** * @author:dxfeng @@ -12,48 +13,56 @@ import org.apache.commons.lang3.StringUtils; * @version: 1.0 */ public class JclOrgWrapper extends OrganizationWrapper { + private JclOrgService getJclOrgService(User user) { + return ServiceUtil.getService(JclOrgServiceImpl.class, user); + } public String getEcOrgId(String jclId, String type) { if (StringUtils.isAnyBlank(jclId, type)) { return null; } - switch (type) { - case "1": - return EcHrmRelationUtil.getEcCompanyId(jclId); - case "2": - return EcHrmRelationUtil.getEcDepartmentId(jclId); - case "3": - default: - return ""; - } + //switch (type) { + // case "1": + // return EcHrmRelationUtil.getEcCompanyId(jclId); + // case "2": + // return EcHrmRelationUtil.getEcDepartmentId(jclId); + // case "3": + // default: + // return ""; + //} + return jclId; } public String getJclOrgId(String ecId, String type) { if (StringUtils.isAnyBlank(ecId, type)) { return null; } - String jclOrgId = ""; - switch (type) { - case "1": - CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecId); - if (null != jclCompanyId) { - jclOrgId = jclCompanyId.getId().toString(); - } - break; - case "2": - DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecId); - if (null != jclDepartmentId) { - jclOrgId = jclDepartmentId.getId().toString(); - } - case "3": - default: - break; - } - return jclOrgId; + //String jclOrgId = ""; + //switch (type) { + // case "1": + // CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecId); + // if (null != jclCompanyId) { + // jclOrgId = jclCompanyId.getId().toString(); + // } + // break; + // case "2": + // DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecId); + // if (null != jclDepartmentId) { + // jclOrgId = jclDepartmentId.getId().toString(); + // } + // case "3": + // default: + // break; + //} + return ecId; } public void syncCusFieldData(String id) { // CusFieldDataTrigger.run(StringUtils.isNotBlank(id) ? Long.parseLong(id) : null); } + + public void supplementResourceInfo(Integer userId) { + getJclOrgService(user).supplementResourceInfo(userId); + } } diff --git a/src/com/engine/organization/wrapper/JobWrapper.java b/src/com/engine/organization/wrapper/JobWrapper.java index 6030abdf..718ca48d 100644 --- a/src/com/engine/organization/wrapper/JobWrapper.java +++ b/src/com/engine/organization/wrapper/JobWrapper.java @@ -11,14 +11,11 @@ import com.engine.organization.entity.job.param.JobMergeParam; import com.engine.organization.entity.job.param.JobSearchParam; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.searchtree.SearchTreeParams; -import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.enums.LogModuleNameEnum; import com.engine.organization.enums.OperateTypeEnum; import com.engine.organization.mapper.job.JobMapper; -import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.service.JobService; import com.engine.organization.service.impl.JobServiceImpl; -import com.engine.organization.thread.JobTriggerRunnable; import com.engine.organization.util.MenuBtn; import com.engine.organization.util.OrganizationFormItemUtil; import com.engine.organization.util.OrganizationWrapper; @@ -113,10 +110,9 @@ public class JobWrapper extends OrganizationWrapper { @Log(operateType = OperateTypeEnum.ADD, operateModule = LogModuleNameEnum.JOB, operateDesc = "新增岗位") public Long saveBaseForm(Map params) { Long jobId = getJobService(user).saveBaseForm(params); + JobPO jobPO = getJobMapper().getJobById(jobId); writeOperateLog(new Object() { - }.getClass(), params.get("job_name").toString(), JSON.toJSONString(params), "新增岗位"); - // 更新组织架构图 - new Thread(new JobTriggerRunnable(jobId)).start(); + }.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(params), "新增岗位"); return jobId; } @@ -133,7 +129,7 @@ public class JobWrapper extends OrganizationWrapper { Long jobId = getJobService(user).updateForm(params); JobPO newJobById = getJobMapper().getJobById(id); writeOperateLog(new Object() { - }.getClass(), jobById.getJobName(), JSON.toJSONString(params), jobById, newJobById); + }.getClass(), jobById.getJobTitleName(), JSON.toJSONString(params), jobById, newJobById); // 更新组织架构图 return jobId; @@ -151,7 +147,7 @@ public class JobWrapper extends OrganizationWrapper { int copyJobItem = getJobService(user).copyJobItem(param.getIds(), param.getDepartment()); for (JobPO jobPO : jobPOS) { writeOperateLog(new Object() { - }.getClass(), jobPO.getJobName(), JSON.toJSONString(param), "复制岗位[" + jobPO.getJobName() + "]"); + }.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(param), "复制岗位[" + jobPO.getJobTitleName() + "]"); } return copyJobItem; } @@ -171,7 +167,7 @@ public class JobWrapper extends OrganizationWrapper { }.getClass(), jobById.getJobNo(), JSON.toJSONString(params), jobById, newJobById); // 更新组织架构图 - new Thread(new JobTriggerRunnable(jobById, newJobById)).start(); + //TODO new Thread(new JobTriggerRunnable(jobById, newJobById)).start(); return updateForbiddenTagById; } @@ -187,9 +183,9 @@ public class JobWrapper extends OrganizationWrapper { int deleteByIds = getJobService(user).deleteByIds(ids); for (JobPO jobPO : jobPOS) { writeOperateLog(new Object() { - }.getClass(), jobPO.getJobName(), JSON.toJSONString(ids), "删除岗位"); + }.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(ids), "删除岗位"); // 更新组织架构图 - new JobTriggerRunnable(jobPO).run(); + // TODO new JobTriggerRunnable(jobPO).run(); } return deleteByIds; } @@ -234,4 +230,8 @@ public class JobWrapper extends OrganizationWrapper { return mergeJob; } + + public void refresh() { + getJobService(user).refresh(); + } } diff --git a/src/com/engine/organization/wrapper/OrgChartWrapper.java b/src/com/engine/organization/wrapper/OrgChartWrapper.java index 8ec94b5d..6388a796 100644 --- a/src/com/engine/organization/wrapper/OrgChartWrapper.java +++ b/src/com/engine/organization/wrapper/OrgChartWrapper.java @@ -24,6 +24,10 @@ public class OrgChartWrapper extends Service { return getOrgChartService(user).getOptionCondition(request2Map, user); } + public Map getSubCompanyTree(Map request2Map, User user) { + return getOrgChartService(user).getSubCompanyTree(request2Map); + } + public Map getCompanyData(Map request2Map, User user) { return getOrgChartService(user).getCompanyData(request2Map, user); } @@ -40,4 +44,8 @@ public class OrgChartWrapper extends Service { return getOrgChartService(user).asyncCompanyData(request2Map, user); } + public String synchronousData(Map request2Map) { + return getOrgChartService(user).synchronousData(request2Map, user); + } + } diff --git a/src/com/engine/organization/wrapper/OrgVirtualWrapper.java b/src/com/engine/organization/wrapper/OrgVirtualWrapper.java new file mode 100644 index 00000000..88e1e5e2 --- /dev/null +++ b/src/com/engine/organization/wrapper/OrgVirtualWrapper.java @@ -0,0 +1,27 @@ +package com.engine.organization.wrapper; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.impl.Service; +import com.engine.organization.service.OrgVirtualService; +import com.engine.organization.service.impl.OrgVirtualServiceImpl; +import weaver.hrm.User; + +import java.util.Map; + +/** + * @Author liang.cheng + * @Date 2023/6/27 3:42 PM + * @Description: TODO + * @Version 1.0 + */ +public class OrgVirtualWrapper extends Service { + + private OrgVirtualService getOrgVirtualService(User user) { + return ServiceUtil.getService(OrgVirtualServiceImpl.class, user); + } + + + public Map listPage(Map params) { + return getOrgVirtualService(user).listPage(params); + } +} diff --git a/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java b/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java new file mode 100644 index 00000000..8ec38cea --- /dev/null +++ b/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java @@ -0,0 +1,45 @@ +package com.engine.organization.wrapper; + +import com.api.browser.bean.SearchConditionItem; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.searchtree.SearchTreeParams; +import com.engine.organization.service.PersonnelResumeService; +import com.engine.organization.service.impl.PersonnelResumeServiceImpl; +import com.engine.organization.util.OrganizationWrapper; +import tebie.applib.api.O; +import weaver.hrm.User; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/12/28 + * @version: 1.0 + */ +public class PersonnelResumeWrapper extends OrganizationWrapper { + private PersonnelResumeService getPersonnelResumeService(User user) { + return ServiceUtil.getService(PersonnelResumeServiceImpl.class, user); + } + + public Map getSearchTree(SearchTreeParams params) { + return getPersonnelResumeService(user).getSearchTree(params); + } + + public Map hasRight() { + return getPersonnelResumeService(user).hasRight(); + } + + public Map getResumeList(Integer uId) { + return getPersonnelResumeService(user).getResumeList(uId); + } + + public String downloadPerResume(Integer type, HttpServletResponse response) throws Exception { + return getPersonnelResumeService(user).downloadPerResume(type, response); + } + + public List personnelScreening() { + return getPersonnelResumeService(user).personnelScreening(); + } +} diff --git a/src/com/engine/organization/wrapper/VersionManageWrapper.java b/src/com/engine/organization/wrapper/VersionManageWrapper.java new file mode 100644 index 00000000..c9b0c9d9 --- /dev/null +++ b/src/com/engine/organization/wrapper/VersionManageWrapper.java @@ -0,0 +1,32 @@ +package com.engine.organization.wrapper; + + +import com.engine.common.util.ServiceUtil; +import com.engine.organization.enums.ModuleTypeEnum; +import com.engine.organization.service.VersionManageService; +import com.engine.organization.service.impl.VersionManageServiceImpl; +import com.engine.organization.util.OrganizationWrapper; +import weaver.hrm.User; + +import java.util.Map; + +/** + * @Author weaver_cl + * @Description: + * @Date 2022/12/8 + * @Version V1.0 + **/ +public class VersionManageWrapper extends OrganizationWrapper { + + private VersionManageService getVersionManageService(User user) { + return ServiceUtil.getService(VersionManageServiceImpl.class, user); + } + + public void save(ModuleTypeEnum moduleTypeEnum, Map params) { + getVersionManageService(user).save(moduleTypeEnum, params, user); + } + + public Map getVersion(ModuleTypeEnum moduleTypeEnum, Map params) { + return getVersionManageService(user).getVersion(moduleTypeEnum, params, user); + } +} diff --git a/src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java b/src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java new file mode 100644 index 00000000..0c7b88c7 --- /dev/null +++ b/src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java @@ -0,0 +1,99 @@ +package weaver.interfaces.organization.cronjob; + +import com.engine.organization.entity.map.JclOrgMap; +import com.engine.organization.entity.staff.po.StaffPO; +import com.engine.organization.mapper.jclorgmap.JclOrgMapper; +import com.engine.organization.mapper.staff.StaffMapper; +import com.engine.organization.util.OrganizationDateUtil; +import com.engine.organization.util.db.MapperProxyFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.sql.Date; +import java.util.List; + +/** + * 定时任务刷新在岗数、编制数 + */ +public class JobAndPlanCron extends BaseCronJob { + + private static final Logger LOGGER = LoggerFactory.getLogger("chartDataLog"); + + char separator = Util.getSeparator(); + + private JclOrgMapper getJclOrgMapMapper(){ + return MapperProxyFactory.getProxy(JclOrgMapper.class); + } + + private StaffMapper getStaffMapper() { + return MapperProxyFactory.getProxy(StaffMapper.class); + } + @Override + public void execute() { + // 计划任务需要处理的逻辑 + RecordSet recordSet = new RecordSet(); + String fType = "3"; + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + List jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType(fType,new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + + for (JclOrgMap jclOrgMap : jclOrgMaps){ + int id = jclOrgMap.getId(); + countJobAndPlans(fType,id,currentDate); + } + } + + /** + * 刷新在岗、编制数 + */ + void countJobAndPlans(String type,int id,String currentDate) { + Date date = new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()); + RecordSet rs = new RecordSet(); + StaffPO staffPO = null; + switch (type) { + case "1": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), String.valueOf(id), null, null); + break; + case "2": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), null, String.valueOf(id), null); + break; + case "3": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), null, null, String.valueOf(id)); + + rs.executeQuery("select count(1) as fonjob from jcl_org_map where ftype=4 and fparentid="+id+" and fdateend>"+currentDate); + if (rs.next()) { + getJclOrgMapMapper().updateMapById(id, null, Integer.valueOf(rs.getString("fonjob")), date); + } + break; + default: + break; + } + if (staffPO != null) { + // 处理自身 + getJclOrgMapMapper().updateMapById(id, staffPO.getStaffNum(), null, date); + } + //处理上级 + String sql = "select fparentid from jcl_org_map where ftype=? and id=? and fdateend>?"; + String typeSql = "select ftype from jcl_org_map where id=? and fdateend>?"; + rs.executeQuery(sql, type, id, currentDate); + String fparentid = null; + String ftype = null; + if (rs.next()) { + fparentid = rs.getString("fparentid"); + rs.executeQuery(typeSql, fparentid, currentDate); + if (rs.next()) { + ftype = rs.getString("ftype"); + } + } + JclOrgMap jclOrgMap = getJclOrgMapMapper().getSumPlanAndJobByFParentId(date, fparentid); + getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), date); + + if (!"-1".equals(fparentid)) { + countJobAndPlans(ftype, Integer.parseInt(fparentid), String.valueOf(currentDate)); + } + } + + +}