岗位导入

pull/170/MERGE^2
dxfeng 3 years ago
parent bc151f7648
commit d5447c8e59

@ -30,16 +30,16 @@ public class JobBO {
return null; return null;
} }
CompPO jclCompany = EcHrmRelationUtil.getJclCompanyId(null == param.getEcCompany() ? Util.null2String(param.getSubcompanyid1()) : param.getEcCompany().toString()); CompPO jclCompany = EcHrmRelationUtil.getJclCompanyId(null == param.getEcCompany() ? Util.null2String(param.getSubcompanyid1()) : param.getEcCompany().toString());
DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(null == param.getEcDepartment() ? Util.null2String(param.getDepartmentid()): param.getEcDepartment().toString()); DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(null == param.getEcDepartment() ? Util.null2String(param.getDepartmentid()) : param.getEcDepartment().toString());
return JobPO return JobPO
.builder() .builder()
.id(param.getId() == null ? 0 : param.getId()) .id(param.getId() == null ? 0 : param.getId())
.jobNo(param.getJobNo()) .jobNo(param.getJobNo())
.jobName(param.getJobName()) .jobName(param.getJobName())
.ecCompany(null == param.getEcCompany() ? param.getSubcompanyid1() : param.getEcCompany()) .ecCompany(param.getEcCompany())
.ecDepartment(null == param.getEcDepartment() ? param.getDepartmentid() : param.getEcDepartment()) .ecDepartment(param.getEcDepartment())
.parentComp(null == jclCompany ? null : jclCompany.getId()) .parentComp(null == jclCompany ? param.getSubcompanyid1() : jclCompany.getId())
.parentDept(null == jclDepartment ? null : jclDepartment.getId()) .parentDept(null == jclDepartment ? param.getDepartmentid() : jclDepartment.getId())
.sequenceId(param.getSequenceId()) .sequenceId(param.getSequenceId())
.schemeId(param.getSchemeId()) .schemeId(param.getSchemeId())
.parentJob(param.getParentJob()) .parentJob(param.getParentJob())

@ -14,7 +14,7 @@ import java.util.List;
*/ */
public interface ExtendInfoMapper { public interface ExtendInfoMapper {
List<ExtendInfoPO> listFields(@Param("extendType") String extendType, @Param("extendGroupId") String extendGroupId, @Param("tableName") String tableName, @Param("operateType") String operateType); List<ExtendInfoPO> listFields(@Param("extendType") String extendType, @Param("extendGroupId") String extendGroupId, @Param("tableName") String tableName, @Param("operateType") String operateType, @Param("isEnable") String isEnable);
int countFieldsByGroupId(@Param("tableName") String tableName, @Param("groupId") Long groupId); int countFieldsByGroupId(@Param("tableName") String tableName, @Param("groupId") Long groupId);

@ -244,7 +244,7 @@
<include refid="baseColumns"/> <include refid="baseColumns"/>
FROM FROM
jcl_field_extendinfo t jcl_field_extendinfo t
WHERE t.delete_type = 0 WHERE t.delete_type = 0 and t.isenable = 1
<if test=" extendType != null and extendType != '' "> <if test=" extendType != null and extendType != '' ">
and extend_type = #{extendType} and extend_type = #{extendType}
</if> </if>
@ -257,7 +257,10 @@
<if test=" operateType != null and operateType !='' "> <if test=" operateType != null and operateType !='' ">
and ${operateType}_show = 1 and ${operateType}_show = 1
</if> </if>
order by show_order <if test=" isEnable != null and isEnable != '' ">
and isenable = #{isEnable}
</if>
order by extend_group_id,show_order
</select> </select>
<select id="countFieldsByGroupId" resultType="java.lang.Integer"> <select id="countFieldsByGroupId" resultType="java.lang.Integer">
select count(1) select count(1)
@ -288,7 +291,7 @@
select select
<include refid="baseColumns"/> <include refid="baseColumns"/>
from jcl_field_extendinfo t from jcl_field_extendinfo t
where t.delete_type = 0 and t.extend_type = #{extendType} where t.delete_type = 0 and t.isenable = 1 and t.extend_type = #{extendType}
and t.field_name_desc = #{labelName} and t.field_name_desc = #{labelName}
</select> </select>

@ -225,6 +225,12 @@
<if test=" jobPO.parentDept != null "> <if test=" jobPO.parentDept != null ">
and t.parent_dept = #{jobPO.parentDept} and t.parent_dept = #{jobPO.parentDept}
</if> </if>
<if test=" jobPO.ecCompany != null ">
and t.ec_company = #{jobPO.ecCompany}
</if>
<if test=" jobPO.ecDepartment != null ">
and t.ec_department = #{jobPO.ecDepartment}
</if>
<if test=" jobPO.sequenceId != null "> <if test=" jobPO.sequenceId != null ">
and t.sequence_id = #{jobPO.sequenceId} and t.sequence_id = #{jobPO.sequenceId}
</if> </if>
@ -342,7 +348,7 @@
from jcl_org_job from jcl_org_job
where delete_type = 0 and job_name = #{jobName} where delete_type = 0 and job_name = #{jobName}
and parent_comp = #{parentCompany} and parent_comp = #{parentCompany}
and parent_dept = #{parentDepartment} <include refid="nullparentDept"/>
<include refid="nullparentJob"/> <include refid="nullparentJob"/>
</select> </select>
<select id="getJobsByIds" resultMap="BaseResultMap"> <select id="getJobsByIds" resultMap="BaseResultMap">
@ -387,6 +393,20 @@
and NVL(parent_job,0) = and NVL(parent_job,0) =
#{parentJob} #{parentJob}
</sql> </sql>
<sql id="nullparentDept">
and ifnull(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="nullparentDept" databaseId="sqlserver">
and isnull(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="nullparentDept" databaseId="oracle">
and NVL(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="likeSQL"> <sql id="likeSQL">

@ -61,7 +61,7 @@ public class ExtServiceImpl extends Service implements ExtService {
// 2编辑 1查看 // 2编辑 1查看
OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); OrganizationAssert.notNull(groupId, "请选择对应的拓展页");
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ExtendInfoOperateType.EDIT.getValue()); List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ExtendInfoOperateType.EDIT.getValue(), "");
String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(",")); String fields = infoPOList.stream().map(ExtendInfoPO::getFieldName).collect(Collectors.joining(","));
if (StringUtils.isEmpty(fields)) { if (StringUtils.isEmpty(fields)) {
return conditionItems; return conditionItems;
@ -96,7 +96,7 @@ public class ExtServiceImpl extends Service implements ExtService {
// 2编辑 1查看 // 2编辑 1查看
OrganizationAssert.notNull(groupId, "请选择对应的拓展页"); OrganizationAssert.notNull(groupId, "请选择对应的拓展页");
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ExtendInfoOperateType.ADD.getValue()); List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ExtendInfoOperateType.ADD.getValue(), "");
// 组装拓展页内容 // 组装拓展页内容
List<String> readOnlyFieldList = Arrays.asList(readOnlyFields); List<String> readOnlyFieldList = Arrays.asList(readOnlyFields);
for (ExtendInfoPO extendInfoPO : infoPOList) { for (ExtendInfoPO extendInfoPO : infoPOList) {
@ -133,7 +133,7 @@ public class ExtServiceImpl extends Service implements ExtService {
// 查询明细表 // 查询明细表
List<ExtendGroupPO> extendGroupList = getExtendGroupMapper().listGroupByPid(groupId); List<ExtendGroupPO> extendGroupList = getExtendGroupMapper().listGroupByPid(groupId);
for (ExtendGroupPO extendGroup : extendGroupList) { for (ExtendGroupPO extendGroup : extendGroupList) {
infoPOList.addAll(getExtendInfoMapper().listFields(extendType, extendGroup.getId() + "", tableName, "")); infoPOList.addAll(getExtendInfoMapper().listFields(extendType, extendGroup.getId() + "", tableName, "", ""));
} }
// 查询所有分布模块,拓展明细表信息 // 查询所有分布模块,拓展明细表信息
Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
@ -171,8 +171,8 @@ public class ExtServiceImpl extends Service implements ExtService {
*/ */
public List<TopTab> getTabInfo(String extendType, String tableName) { public List<TopTab> getTabInfo(String extendType, String tableName) {
List<TopTab> topTabs = new ArrayList<>(); List<TopTab> topTabs = new ArrayList<>();
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, ExtendInfoOperateType.EDIT.getValue()); List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, ExtendInfoOperateType.EDIT.getValue(), "");
List<ExtendInfoPO> infoPOList1 = getExtendInfoMapper().listFields(extendType, "", tableName.toLowerCase().replace("ext", ""), ExtendInfoOperateType.EDIT.getValue()); List<ExtendInfoPO> infoPOList1 = getExtendInfoMapper().listFields(extendType, "", tableName.toLowerCase().replace("ext", ""), ExtendInfoOperateType.EDIT.getValue(), "");
infoPOList.addAll(infoPOList1); infoPOList.addAll(infoPOList1);
List<Long> ids = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList()); List<Long> ids = infoPOList.stream().map(ExtendInfoPO::getExtendGroupId).collect(Collectors.toList());
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByIds(ids); List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByIds(ids);
@ -192,7 +192,7 @@ public class ExtServiceImpl extends Service implements ExtService {
@Override @Override
public Long updateExtForm(User user, String extendType, String tableName, Map<String, Object> params, String groupId, Long id) { public Long updateExtForm(User user, String extendType, String tableName, Map<String, Object> params, String groupId, Long id) {
List<ExtendInfoPO> extInfoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, ""); List<ExtendInfoPO> extInfoPOList = getExtendInfoMapper().listFields(extendType, groupId, tableName, "", "");
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 遍历Map // 遍历Map
Map<String, ExtendInfoPO> collect = extInfoPOList.stream().collect(Collectors.toMap(ExtendInfoPO::getFieldName, item -> item)); Map<String, ExtendInfoPO> collect = extInfoPOList.stream().collect(Collectors.toMap(ExtendInfoPO::getFieldName, item -> item));
@ -245,7 +245,7 @@ public class ExtServiceImpl extends Service implements ExtService {
@Override @Override
public void updateExtDT(User user, String extendType, String tableName, Map<String, Object> params, Long id) { public void updateExtDT(User user, String extendType, String tableName, Map<String, Object> params, Long id) {
List<ExtendInfoPO> dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, ""); List<ExtendInfoPO> dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "", "");
List<Long> groupIds = dtInfoPOList.stream().map(ExtendInfoPO::getExtendGroupId).distinct().collect(Collectors.toList()); List<Long> groupIds = dtInfoPOList.stream().map(ExtendInfoPO::getExtendGroupId).distinct().collect(Collectors.toList());
Map<Long, List<ExtendInfoPO>> poMaps = dtInfoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId)); Map<Long, List<ExtendInfoPO>> poMaps = dtInfoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
// 删除原有明细表数据 // 删除原有明细表数据

@ -241,7 +241,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
Long groupType = param.getGroupType(); Long groupType = param.getGroupType();
ExtendGroupPO extendGroupPO = getExtendGroupMapper().getGroupById(groupType); ExtendGroupPO extendGroupPO = getExtendGroupMapper().getGroupById(groupType);
String tableName = ExtendGroupBO.getTableNameByGroupPO(extendGroupPO); String tableName = ExtendGroupBO.getTableNameByGroupPO(extendGroupPO);
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("", param.getGroupId().toString(), tableName, ""); List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields("", param.getGroupId().toString(), tableName, "","");
for (ExtendInfoPO extendInfoPO : infoPOList) { for (ExtendInfoPO extendInfoPO : infoPOList) {
Long fieldId = extendInfoPO.getId(); Long fieldId = extendInfoPO.getId();
String fieldName = extendInfoPO.getFieldName(); String fieldName = extendInfoPO.getFieldName();
@ -436,7 +436,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
//明细表删除字段信息、删除表结构 //明细表删除字段信息、删除表结构
ExtendGroupPO extendGroupPO = getExtendGroupMapper().getGroupById(id); ExtendGroupPO extendGroupPO = getExtendGroupMapper().getGroupById(id);
MapperProxyFactory.getProxy(ExtendGroupMapper.class).delete(id); MapperProxyFactory.getProxy(ExtendGroupMapper.class).delete(id);
List<ExtendInfoPO> extendInfoList = getExtendInfoMapper().listFields(extendGroupPO.getExtendType().toString(), extendGroupPO.getId().toString(), ExtendGroupBO.getTableNameByGroupPO(extendGroupPO), ""); List<ExtendInfoPO> extendInfoList = getExtendInfoMapper().listFields(extendGroupPO.getExtendType().toString(), extendGroupPO.getId().toString(), ExtendGroupBO.getTableNameByGroupPO(extendGroupPO), "","");
List<Long> ids = extendInfoList.stream().map(ExtendInfoPO::getId).collect(Collectors.toList()); List<Long> ids = extendInfoList.stream().map(ExtendInfoPO::getId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
// 删除数据 // 删除数据

@ -18,6 +18,8 @@ import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO;
import com.engine.organization.entity.jclimport.po.JclImportHistoryPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryPO;
import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO; import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO;
import com.engine.organization.enums.LogModuleNameEnum;
import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtMapper;
@ -26,9 +28,11 @@ import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper;
import com.engine.organization.mapper.jclimport.JclImportHistoryMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryMapper;
import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.service.ImportCommonService; import com.engine.organization.service.ImportCommonService;
import com.engine.organization.thread.OrganizationRunable;
import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.excel.ExcelUtil; import com.engine.organization.util.excel.ExcelUtil;
import com.engine.organization.util.relation.EcHrmRelationUtil;
import com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil; import com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil;
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil; import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
import com.engine.organization.util.saveimport.SaveImportProcessUtil; import com.engine.organization.util.saveimport.SaveImportProcessUtil;
@ -167,6 +171,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
break; break;
case "jobtitle": case "jobtitle":
extendType = "3"; extendType = "3";
exculdeFields.add("parent_job");
tableName = "JCL_ORG_JOB"; tableName = "JCL_ORG_JOB";
break; break;
case "resource": case "resource":
@ -184,7 +189,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (StringUtils.isAnyEmpty(extendType, tableName)) { if (StringUtils.isAnyEmpty(extendType, tableName)) {
return returnMaps; return returnMaps;
} }
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, ""); List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "", "1");
List<ExtendInfoPO> filterList = infoPOList.stream().filter(item -> !exculdeFields.contains(item.getFieldName()) && 6 != item.getControlType()).collect(Collectors.toList()); List<ExtendInfoPO> filterList = infoPOList.stream().filter(item -> !exculdeFields.contains(item.getFieldName()) && 6 != item.getControlType()).collect(Collectors.toList());
List<FieldTypeTreeParam> fieldDatas = filterList.stream().map(item -> FieldTypeTreeParam.builder().id(item.getId()).name(item.getFieldNameDesc()).build()).collect(Collectors.toList()); List<FieldTypeTreeParam> fieldDatas = filterList.stream().map(item -> FieldTypeTreeParam.builder().id(item.getId()).name(item.getFieldNameDesc()).build()).collect(Collectors.toList());
List<Long> selectedKeys = filterList.stream().filter(item -> (0 == item.getIsSystemDefault()) && 1 == item.getIsrequired()).map(ExtendInfoPO::getId).collect(Collectors.toList()); List<Long> selectedKeys = filterList.stream().filter(item -> (0 == item.getIsSystemDefault()) && 1 == item.getIsrequired()).map(ExtendInfoPO::getId).collect(Collectors.toList());
@ -242,6 +247,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
returnMap.put("pId", departmentImport(operateType, excelFile, 2L)); returnMap.put("pId", departmentImport(operateType, excelFile, 2L));
break; break;
case "jobtitle": case "jobtitle":
returnMap.put("pId", jobImport(operateType, excelFile, 3L));
break; break;
case "resource": case "resource":
// TODO // TODO
@ -259,7 +265,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
@Override @Override
public Map<String, Object> getImportResult(Map<String, Object> params) { public Map<String, Object> getImportResult(Map<String, Object> params) {
String pId = (String) params.get("pId"); String pId = (String) params.get("pId");
Map<String, Object> resultMap = new HashMap<>();
// 刷新引用状态 // 刷新引用状态
OrganizationWeaTable<JclImportHistoryDetailVO> table = new OrganizationWeaTable<>(user, JclImportHistoryDetailVO.class); OrganizationWeaTable<JclImportHistoryDetailVO> table = new OrganizationWeaTable<>(user, JclImportHistoryDetailVO.class);
String sqlWhere = " where status = '0' and pId = '" + pId + "'"; String sqlWhere = " where status = '0' and pId = '" + pId + "'";
@ -267,7 +272,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
WeaResultMsg result = new WeaResultMsg(false); WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult()); result.putAll(table.makeDataResult());
result.success(); result.success();
resultMap.putAll(result.getResultMap()); Map<String, Object> resultMap = new HashMap<>(result.getResultMap());
resultMap.put("importStatus", "over"); resultMap.put("importStatus", "over");
resultMap.put("succnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("1", pId)); resultMap.put("succnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("1", pId));
resultMap.put("failnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("0", pId)); resultMap.put("failnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("0", pId));
@ -277,10 +282,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
/** /**
* *
*
* @param templatePath
* @return
* @throws IOException
*/ */
private List<Object> getCompanyImportForm(String templatePath) throws IOException { private List<Object> getCompanyImportForm(String templatePath) throws IOException {
@ -437,7 +438,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
groupItem = new HashMap<>(); groupItem = new HashMap<>();
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage()))); groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage())));
groupItem.put("defaultshow", true); groupItem.put("defaultshow", true);
List<Integer> lsPromptLabel = new ArrayList<Integer>(); //提示信息 List<Integer> lsPromptLabel = new ArrayList<>(); //提示信息
lsPromptLabel.add(34275); lsPromptLabel.add(34275);
lsPromptLabel.add(125452); lsPromptLabel.add(125452);
@ -460,9 +461,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
/** /**
* *
*
* @param operateType
* @param excelFile
*/ */
private Long companyImport(String operateType, String excelFile, Long extendType) { private Long companyImport(String operateType, String excelFile, Long extendType) {
Long importHistoryId = saveImportLog("company", operateType); Long importHistoryId = saveImportLog("company", operateType);
@ -568,7 +566,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
historyDetailPO.setOperateDetail("数据已存在"); historyDetailPO.setOperateDetail("数据已存在");
historyDetailPO.setStatus("0"); historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
continue nextRow; continue;
} }
// 自动编号 // 自动编号
compNo = CompServiceImpl.repeatDetermine(compNo); compNo = CompServiceImpl.repeatDetermine(compNo);
@ -580,7 +578,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) { if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) {
map.put("forbidden_tag", 0); map.put("forbidden_tag", 0);
} }
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build()); ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
map.put("id", infoParams.getId());
new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map).run();
historyDetailPO.setOperateDetail("添加成功"); historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1"); historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -595,6 +596,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (checkRepeatNo(compNo, extendType, companyId)) { if (checkRepeatNo(compNo, extendType, companyId)) {
map.put("update_time", new Date()); map.put("update_time", new Date());
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(companyId).tableName("JCL_ORG_COMP").params(map).build()); MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(companyId).tableName("JCL_ORG_COMP").params(map).build());
map.put("id", companyId);
new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map).run();
historyDetailPO.setOperateDetail("更新成功"); historyDetailPO.setOperateDetail("更新成功");
historyDetailPO.setStatus("1"); historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -667,7 +670,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
// 数据校验 // 数据校验
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) { if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
// TODO 记录日志
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项"); historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
historyDetailPO.setStatus("0"); historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -684,7 +686,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
continue nextRow; continue nextRow;
} }
if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"parent_comp".equals(infoPO.getFieldName())) { if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"parent_comp".equals(infoPO.getFieldName())) {
// TODO 记录日志
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据"); historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
historyDetailPO.setStatus("0"); historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -701,8 +702,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
continue nextRow; continue nextRow;
} }
for (int index = 0; index < split.length; index++) { for (String s : split) {
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId); parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId);
if (null == parentCompanyId) { if (null == parentCompanyId) {
historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据"); historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据");
historyDetailPO.setStatus("0"); historyDetailPO.setStatus("0");
@ -713,7 +714,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
} }
} }
// 部门名称、上级部门
if ("dept_name".equals(infoPO.getFieldName())) { if ("dept_name".equals(infoPO.getFieldName())) {
if (null == parentCompanyId) { if (null == parentCompanyId) {
historyDetailPO.setOperateDetail(cellValue + "所属分部未找到"); historyDetailPO.setOperateDetail(cellValue + "所属分部未找到");
@ -751,7 +751,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (i == 0) { if (i == 0) {
continue; continue;
} }
// TODO
String deptNo = (String) map.get("dept_no"); String deptNo = (String) map.get("dept_no");
Long departmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(departmentName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId); Long departmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(departmentName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId);
if ("add".equals(operateType)) { if ("add".equals(operateType)) {
@ -759,7 +758,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
historyDetailPO.setOperateDetail("数据已存在"); historyDetailPO.setOperateDetail("数据已存在");
historyDetailPO.setStatus("0"); historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
continue nextRow; continue;
} }
// 自动编号 // 自动编号
deptNo = DepartmentServiceImpl.repeatDetermine(deptNo); deptNo = DepartmentServiceImpl.repeatDetermine(deptNo);
@ -771,7 +770,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) { if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) {
map.put("forbidden_tag", 0); map.put("forbidden_tag", 0);
} }
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_DEPT").params(map).build()); ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_DEPT").params(map).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
map.put("id", infoParams.getId());
new OrganizationRunable(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).run();
historyDetailPO.setOperateDetail("添加成功"); historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1"); historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -786,6 +788,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (checkRepeatNo(deptNo, extendType, departmentId)) { if (checkRepeatNo(deptNo, extendType, departmentId)) {
map.put("update_time", new Date()); map.put("update_time", new Date());
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(departmentId).tableName("JCL_ORG_DEPT").params(map).build()); MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(departmentId).tableName("JCL_ORG_DEPT").params(map).build());
map.put("id", departmentId);
new OrganizationRunable(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).run();
historyDetailPO.setOperateDetail("更新成功"); historyDetailPO.setOperateDetail("更新成功");
historyDetailPO.setStatus("1"); historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO); saveImportDetailLog(historyDetailPO);
@ -804,6 +808,231 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
return importHistoryId; return importHistoryId;
} }
/**
*
*
* @param operateType
* @param excelFile
* @param extendType
* @return
*/
private Long jobImport(String operateType, String excelFile, Long extendType) {
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<ExtendInfoPO> extendInfoPOS = new ArrayList<>();
OrganizationAssert.isTrue(lastRow > 1, "导入数据为空");
// 遍历每一行数据
nextRow:
for (int i = 0; i <= lastRow; i++) {
historyDetailPO = new JclImportHistoryDetailPO();
historyDetailPO.setPid(importHistoryId);
XSSFRow row = sheetAt.getRow(i);
// 组装待处理数据
Map<String, Object> 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 < row.getLastCellNum(); cellIndex++) {
XSSFCell cell = row.getCell((short) cellIndex);
if (cell == null) {
continue;
}
String cellValue = getCellValue(cell).trim();
if (i == 0) {
// 首行 初始化字段信息
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(extendType, 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 > 1) {
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 > 1) {
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 == parentCompanyId) {
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 > 1) {
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;
}
}
}
// TODO
map.put("parent_comp", parentCompanyId);
map.put("parent_dept", parentDepartmentId);
map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(parentCompanyId + ""));
if (null != parentDepartmentId) {
map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(parentDepartmentId + ""));
}
map.put("parent_job", parentJobId);
jobName = split[split.length - 1];
map.put("job_name", jobName);
}
}
}
// 校验、数据交互
if (i == 0) {
continue;
}
// TODO
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);
}
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_JOB").params(map).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
map.put("id", infoParams.getId());
new OrganizationRunable(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, map).run();
historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO);
} else if ("update".equals(operateType)) {
// 查询对应ID
if (StringUtils.isNotBlank(jobNo)) {
if (jobId == null) {
historyDetailPO.setOperateDetail("未找到对应数据");
historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO);
}
if (checkRepeatNo(jobNo, extendType, jobId)) {
map.put("update_time", new Date());
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(jobId).tableName("JCL_ORG_JOB").params(map).build());
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
map.put("id", jobId);
new OrganizationRunable(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, map).run();
historyDetailPO.setOperateDetail("更新成功");
historyDetailPO.setStatus("1");
saveImportDetailLog(historyDetailPO);
} else {
historyDetailPO.setOperateDetail(jobNo + "编号已存在");
historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO);
}
} else {
historyDetailPO.setOperateDetail("编号为空,更新失败");
historyDetailPO.setStatus("0");
saveImportDetailLog(historyDetailPO);
}
}
}
return importHistoryId;
}
/** /**
* *
@ -822,7 +1051,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
case NUMERIC: case NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式 if (HSSFDateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式 cellValue = sft.format(cell.getDateCellValue()); // 读取日期格式
} else { } else {
cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字
if (cellValue.endsWith(".0")) if (cellValue.endsWith(".0"))
@ -872,7 +1101,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
jsonObject.put("fieldhtmltype", extendInfo.getControlType()); jsonObject.put("fieldhtmltype", extendInfo.getControlType());
jsonObject.put("type", extendInfo.getBrowserType()); jsonObject.put("type", extendInfo.getBrowserType());
jsonObject.put("fieldvalue", cellValue); jsonObject.put("fieldvalue", cellValue);
if ("162".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) { if ("161".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) {
jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue())); jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue()));
} else { } else {
jsonObject.put("dmlurl", extendInfo.getBrowserType()); jsonObject.put("dmlurl", extendInfo.getBrowserType());
@ -971,8 +1200,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
if (!excelPathFile.exists()) { if (!excelPathFile.exists()) {
String substring = excelPath.substring(0, excelPath.lastIndexOf(File.separator)); String substring = excelPath.substring(0, excelPath.lastIndexOf(File.separator));
File file = new File(substring); File file = new File(substring);
file.mkdirs(); if (file.mkdirs()) {
excelPathFile.createNewFile(); boolean newFile = excelPathFile.createNewFile();
if (!newFile) {
throw new IOException(excelPath + "文件创建失败");
}
}
} }
FileOutputStream out = new FileOutputStream(excelPathFile); FileOutputStream out = new FileOutputStream(excelPathFile);
sheets.write(out); sheets.write(out);

@ -93,14 +93,14 @@ public class JobServiceImpl extends Service implements JobService {
private static final String RIGHT_NAME = "Job:All"; private static final String RIGHT_NAME = "Job:All";
private static final String JOB_ACTIVITY_ID; public static final String JOB_ACTIVITY_ID;
/** /**
* titleID * titleID
*/ */
private static final Long GROUP_ID = 3L; private static final Long GROUP_ID = 3L;
private JobMapper getJobMapper() { private static JobMapper getJobMapper() {
return MapperProxyFactory.getProxy(JobMapper.class); return MapperProxyFactory.getProxy(JobMapper.class);
} }
@ -574,8 +574,11 @@ public class JobServiceImpl extends Service implements JobService {
&& null == jobPO.getParentDept() && null == jobPO.getParentDept()
&& null == jobPO.getSequenceId() && null == jobPO.getSequenceId()
&& null == jobPO.getSchemeId() && null == jobPO.getSchemeId()
&& null == jobPO.getIsKey()) && null == jobPO.getIsKey()
&& null == jobPO.getForbiddenTag(); && null == jobPO.getForbiddenTag()
&& null == jobPO.getEcCompany()
&& null == jobPO.getEcDepartment()
);
} }
/** /**
@ -583,7 +586,7 @@ public class JobServiceImpl extends Service implements JobService {
* *
* @return * @return
*/ */
private String repeatDetermine(String jobNo) { public static String repeatDetermine(String jobNo) {
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.JOBTITLES.getValue()); CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.JOBTITLES.getValue());
if (StringUtils.isNotBlank(jobNo)) { if (StringUtils.isNotBlank(jobNo)) {
jobNo = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobNo); jobNo = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobNo);
@ -602,7 +605,7 @@ public class JobServiceImpl extends Service implements JobService {
* *
* @return * @return
*/ */
private String autoCreateCompanyNo() { private static String autoCreateCompanyNo() {
String generateCode = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, ""); String generateCode = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, "");
List<JobPO> list = getJobMapper().listByNo(Util.null2String(generateCode)); List<JobPO> list = getJobMapper().listByNo(Util.null2String(generateCode));
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {

@ -897,7 +897,7 @@ public class HrmResourceImportAdaptUtil {
StringBuilder baseField = new StringBuilder(); StringBuilder baseField = new StringBuilder();
StringBuilder baseFieldLabel = new StringBuilder(); StringBuilder baseFieldLabel = new StringBuilder();
String fieldHtmlType; String fieldHtmlType;
List<ExtendInfoPO> infoPOList = MapperProxyFactory.getProxy(ExtendInfoMapper.class).listFields("4", "", "JCL_ORG_HRMRESOURCE", ""); List<ExtendInfoPO> infoPOList = MapperProxyFactory.getProxy(ExtendInfoMapper.class).listFields("4", "", "JCL_ORG_HRMRESOURCE", "","");
for (ExtendInfoPO extendInfoPO : infoPOList) { for (ExtendInfoPO extendInfoPO : infoPOList) {
fieldHtmlType = extendInfoPO.getControlType().toString(); fieldHtmlType = extendInfoPO.getControlType().toString();
if (fieldHtmlType.equals("1") || fieldHtmlType.equals("2") || fieldHtmlType.equals("3") if (fieldHtmlType.equals("1") || fieldHtmlType.equals("2") || fieldHtmlType.equals("3")

Loading…
Cancel
Save