岗位序列导入功能
This commit is contained in:
parent
2d46b33600
commit
ace84c3d09
|
|
@ -2,6 +2,7 @@ package com.engine.organization.enums;
|
|||
|
||||
import com.engine.organization.exception.OrganizationRunTimeException;
|
||||
import com.engine.organization.util.saveimport.PostInfoImportUtil;
|
||||
import com.engine.organization.util.saveimport.SequenceImportUtil;
|
||||
import com.engine.organization.util.saveimport.StaffInfoImportUtil;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -29,6 +30,20 @@ public enum OrgImportEnum implements OrgImportAdapter {
|
|||
return StaffInfoImportUtil.importForm(user);
|
||||
}
|
||||
},
|
||||
SEQUENCE("sequence"){
|
||||
@Override
|
||||
public Map<String, Object> orgImport(Map<String, Object> params, User user) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
String excelFile = (String) params.get("excelfile");
|
||||
resultMap.put("pId", SequenceImportUtil.saveImport("add", excelFile, user));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> orgForm(User user) {
|
||||
return SequenceImportUtil.importForm(user);
|
||||
}
|
||||
},
|
||||
POSTINFO("postInfo"){
|
||||
@Override
|
||||
public Map<String, Object> orgImport(Map<String, Object> params, User user) {
|
||||
|
|
@ -45,6 +60,7 @@ public enum OrgImportEnum implements OrgImportAdapter {
|
|||
};
|
||||
|
||||
|
||||
|
||||
private String tableName;
|
||||
|
||||
OrgImportEnum(String tableName) {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public interface SchemeMapper {
|
|||
|
||||
List<SchemePO> getSchemesByIds(@Param("ids")Collection<Long> ids);
|
||||
|
||||
|
||||
List<Integer> selectBySubcompanyId(@Param("subCompanyIds") Collection<Integer> subCompanyIds);
|
||||
|
||||
List<SchemePO> selectByParams(@Param("subCompanyId") Integer subCompanyId,@Param("schemeName") String schemeName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,4 +276,10 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectByParams" parameterType="com.engine.organization.entity.scheme.po.SchemePO" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_scheme t where subcompanyid = #{subCompanyId} AND scheme_name = #{schemeName} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -45,6 +45,13 @@ public interface ImportCommonService {
|
|||
|
||||
Map<String,Object> saveCommonImport(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* @Description: 通用导入表单模板
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2024/3/11 4:05 PM
|
||||
* @param: [importModule]
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String, Object> getCommonForm(String importModule);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ 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.field.StaticFieldName;
|
||||
import com.engine.organization.util.saveimport.CompanyImport;
|
||||
import com.engine.organization.util.saveimport.DepartmentImport;
|
||||
import com.engine.organization.util.saveimport.OrgImportUtil;
|
||||
|
|
@ -117,6 +118,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
excludeFields.add("companyworkyear");
|
||||
excludeFields.add("textfield1");
|
||||
excludeFields.add("textfield2");
|
||||
// 职等职级
|
||||
excludeFields.add("3" + StaticFieldName.zdzjFieldName);
|
||||
|
||||
return ResourceImport.getImportFields(user, excludeFields);
|
||||
case "joblevel":
|
||||
|
|
@ -329,10 +332,17 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
item.put("value", value);
|
||||
itemList.add(item);
|
||||
}
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("index", 3);
|
||||
item.put("value", "多个职等之间使用英文状态下逗号”,“隔开");
|
||||
Map<String, Object> item = new HashMap<String, Object>(2){{
|
||||
put("index", 3);
|
||||
put("value", "多个职等之间使用英文状态下逗号”,“隔开");
|
||||
}};
|
||||
Map<String, Object> item1 = new HashMap<String, Object>(2){{
|
||||
put("index", 4);
|
||||
put("value", "《等级方案、职等、职级》名称存在重复情况下暂时不支持导入功能");
|
||||
}};
|
||||
itemList.add(item);
|
||||
itemList.add(item1);
|
||||
|
||||
groupItem.put("items", itemList);
|
||||
lsGroup.add(groupItem);
|
||||
return lsGroup;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ public class SchemeServiceImpl extends Service implements SchemeService {
|
|||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||||
List<SchemePO> list = getSchemeMapper().listByNo(Util.null2String(param.getSchemeNo()));
|
||||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||||
List<SchemePO> schemePOS = getSchemeMapper().selectByParams(param.getSubcompanyid(), param.getSchemeName());
|
||||
OrganizationAssert.isEmpty(schemePOS, "同一分部下方案名称不允许重复");
|
||||
SchemePO schemePO = SchemeDTO.convertParamToPO(param, (long) user.getUID());
|
||||
return getSchemeMapper().insertIgnoreNull(schemePO);
|
||||
}
|
||||
|
|
@ -80,6 +82,8 @@ public class SchemeServiceImpl extends Service implements SchemeService {
|
|||
List<SchemePO> list = getSchemeMapper().listByNo(Util.null2String(schemePO.getSchemeNo()));
|
||||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||||
}
|
||||
List<SchemePO> schemePOS = getSchemeMapper().selectByParams(param.getSubcompanyid(), param.getSchemeName());
|
||||
OrganizationAssert.isEmpty(schemePOS, "同一分部下方案名称不允许重复");
|
||||
return getSchemeMapper().updateScheme(schemePO);
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +128,7 @@ public class SchemeServiceImpl extends Service implements SchemeService {
|
|||
schemeNameCondition.setRules("required|string");
|
||||
SearchConditionItem schemeNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "方案编号", "schemeNo");
|
||||
schemeNoCondition.setRules("required|string");
|
||||
SearchConditionItem subCompanyIdItem = OrganizationFormItemUtil.browserItem(user, 2, 17, 2, false, "所属分部", "164", "subCompanyId", "");
|
||||
SearchConditionItem subCompanyIdItem = OrganizationFormItemUtil.browserItem(user, 2, 17, 3, false, "所属分部", "164", "subCompanyId", "");
|
||||
SearchConditionItem textareaItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 200, "方案说明", "schemeDescription");
|
||||
|
||||
// 编辑状态下赋值操作
|
||||
|
|
|
|||
|
|
@ -19,11 +19,18 @@ import com.engine.organization.util.*;
|
|||
import com.engine.organization.util.db.DBType;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.detach.DetachUtil;
|
||||
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.StringUtil;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
|
@ -35,6 +42,40 @@ import java.util.*;
|
|||
*/
|
||||
public class SequenceServiceImpl extends Service implements SequenceService {
|
||||
|
||||
// 判断岗位序列导入模板是否存在,不存在则创建该文件
|
||||
static {
|
||||
try {
|
||||
String outPutPath = GCONST.getRootPath() + File.separator + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + "sequence.xls";
|
||||
File excelPathFile = new File(outPutPath);
|
||||
if (!excelPathFile.exists()) {
|
||||
String columns = "编号,名称,等级方案,方案所属分部,描述说明";
|
||||
String[] split = columns.split(",");
|
||||
List<Object> columnList = new ArrayList<>(Arrays.asList(split));
|
||||
// 创建导入模板
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
excelSheetData.add(columnList);
|
||||
XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, "sequence");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String RIGHT_NAME = "Sequence:All";
|
||||
|
||||
private SequenceMapper getSequenceMapper() {
|
||||
|
|
@ -162,7 +203,10 @@ public class SequenceServiceImpl extends Service implements SequenceService {
|
|||
|
||||
@Override
|
||||
public Map<String, List<MenuBtn>> getHasRight() {
|
||||
return MenuBtn.getCommonBtnDatas();
|
||||
Map<String, List<MenuBtn>> commonBtnDatas = MenuBtn.getCommonBtnDatas();
|
||||
commonBtnDatas.get("topMenu").add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("importFile").menuIcon("icon-coms-leading-in").menuName("批量导入").type("BTN_BatchImport").build());
|
||||
commonBtnDatas.get("rightMenu").add(MenuBtn.builder().isBatch("1").isTop("0").menuFun("importFile").menuIcon("icon-coms-leading-in").menuName("批量导入").type("BTN_BatchImport").build());
|
||||
return commonBtnDatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class PostInfoImportUtil {
|
|||
|
||||
}
|
||||
public static Long saveImport(String operateType, String excelFile, User user) {
|
||||
Long importHistoryId = OrgImportUtil.saveImportLog("staff_info", operateType, user);
|
||||
Long importHistoryId = OrgImportUtil.saveImportLog("post_info", operateType, user);
|
||||
JclImportHistoryDetailPO historyDetailPO;
|
||||
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
package com.engine.organization.util.saveimport;
|
||||
|
||||
|
||||
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
||||
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO;
|
||||
|
||||
import com.engine.organization.entity.scheme.po.SchemePO;
|
||||
import com.engine.organization.entity.sequence.po.SequencePO;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.scheme.SchemeMapper;
|
||||
import com.engine.organization.mapper.sequence.SequenceMapper;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* @Description: 岗位序列
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2024/3/12 2:17 PM
|
||||
* @param:
|
||||
* @return:
|
||||
*/
|
||||
public class SequenceImportUtil {
|
||||
static Map<String, ExtendInfoPO> importFieldsMap;
|
||||
|
||||
static {
|
||||
importFieldsMap = new HashMap<>();
|
||||
importFieldsMap.put("编号", ExtendInfoPO.builder().tableName("jcl_org_sequence").fieldName("sequence_no").fieldNameDesc("编号").isrequired(1).controlType(1).browserType("1").customValue("[\"input\",\"text\",\"100\"]").build());
|
||||
importFieldsMap.put("名称", ExtendInfoPO.builder().tableName("jcl_org_sequence").fieldName("sequence_name").fieldNameDesc("名称").isrequired(1).controlType(1).browserType("1").customValue("[\"input\",\"text\",\"100\"]").build());
|
||||
importFieldsMap.put("等级方案", ExtendInfoPO.builder().tableName("jcl_org_sequence").fieldName("scheme_name").fieldNameDesc("等级方案").isrequired(1).controlType(1).browserType("3").customValue("[\"input\",\"text\",\"100\"]").build());
|
||||
importFieldsMap.put("方案所属分部", ExtendInfoPO.builder().tableName("jcl_org_sequence").fieldName("subcompanyname").fieldNameDesc("方案所属分部").isrequired(1).controlType(1).browserType("3").customValue("[\"input\",\"text\",\"100\"]").build());
|
||||
importFieldsMap.put("描述说明", ExtendInfoPO.builder().tableName("jcl_org_sequence").fieldName("description").fieldNameDesc("描述说明").isrequired(0).controlType(1).browserType("1").customValue("[\"input\",\"text\",\"100\"]").build());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Long saveImport(String operateType, String excelFile, User user) {
|
||||
Long importHistoryId = OrgImportUtil.saveImportLog("sequence_info", 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();
|
||||
OrganizationAssert.isTrue(lastRow > 0, "文件数据为空");
|
||||
short lastCellNum = sheetAt.getRow(0).getLastCellNum();
|
||||
List<ExtendInfoPO> extendInfoPOS = new ArrayList<>();
|
||||
Date currDate = new Date();
|
||||
// 遍历每一行数据
|
||||
nextRow:
|
||||
for (int i = 0; i <= lastRow; i++) {
|
||||
historyDetailPO = new JclImportHistoryDetailPO();
|
||||
historyDetailPO.setPid(importHistoryId);
|
||||
XSSFRow row = sheetAt.getRow(i);
|
||||
if (null == row) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 组装待处理数据
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
Integer parentCompanyId = null;
|
||||
|
||||
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) {
|
||||
// 首行 初始化字段信息
|
||||
ExtendInfoPO extendInfoPO = importFieldsMap.get(cellValue);
|
||||
extendInfoPOS.add(extendInfoPO);
|
||||
} else {
|
||||
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
||||
// 数据校验
|
||||
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
|
||||
historyDetailPO.setRelatedName("");
|
||||
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue nextRow;
|
||||
}
|
||||
|
||||
Object reallyValue = cellValue;
|
||||
|
||||
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("subcompanyid", Util.null2String(parentCompanyId));
|
||||
}
|
||||
|
||||
// 编号是否重复
|
||||
if ("sequence_no".equals(infoPO.getFieldName())){
|
||||
List<SequencePO> sequencePOS = MapperProxyFactory.getProxy(SequenceMapper.class).listByNo(Util.null2String(reallyValue));
|
||||
if(sequencePOS.size()>0){
|
||||
historyDetailPO.setRelatedName("");
|
||||
historyDetailPO.setOperateDetail("编号:" + reallyValue + ",编号不允许重复");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue nextRow;
|
||||
}
|
||||
}
|
||||
|
||||
map.put(infoPO.getFieldName(), reallyValue);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
String subCompanyName = (String) map.get("scheme_name");
|
||||
String subCompanyId = (String) map.get("subcompanyid");
|
||||
|
||||
List<SchemePO> schemePOS = MapperProxyFactory.getProxy(SchemeMapper.class).selectByParams(Integer.parseInt(subCompanyId), subCompanyName);
|
||||
if (schemePOS.size() == 0){
|
||||
historyDetailPO.setRelatedName("");
|
||||
historyDetailPO.setOperateDetail("第"+i+"行,所属分部下的等级方案不存在");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue nextRow;
|
||||
}
|
||||
|
||||
SequencePO build = SequencePO.builder()
|
||||
.sequenceNo((String) map.get("sequence_no"))
|
||||
.sequenceName((String) map.get("sequence_name"))
|
||||
.schemeId(schemePOS.get(0).getId())
|
||||
.description((String) map.get("description"))
|
||||
.build();
|
||||
MapperProxyFactory.getProxy(SequenceMapper.class).insertIgnoreNull(build);
|
||||
historyDetailPO.setOperateDetail("添加成功");
|
||||
historyDetailPO.setStatus("1");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
}
|
||||
|
||||
return importHistoryId;
|
||||
}
|
||||
|
||||
|
||||
public static List<Map<String, Object>> importForm(User user) {
|
||||
// 返回导入数据
|
||||
List<Map<String, Object>> lsGroup = new ArrayList<>();
|
||||
Map<String, Object> groupItem = new HashMap<>(3);
|
||||
List<Object> itemList = new ArrayList<>();
|
||||
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage())));
|
||||
groupItem.put("defaultshow", true);
|
||||
List<Integer> lsPromptLabel = new ArrayList<>();
|
||||
lsPromptLabel.add(34275);
|
||||
lsPromptLabel.add(125452);
|
||||
|
||||
for (int i = 0; i < lsPromptLabel.size(); i++) {
|
||||
Map<String, Object> 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", "/hrm/import/template/sequence.xls");
|
||||
}
|
||||
item.put("value", value);
|
||||
itemList.add(item);
|
||||
}
|
||||
Map<String,Object> map = new HashMap<String,Object>(2){{
|
||||
put("index",3);
|
||||
put("value","分部的层级关系用字符>分割。");
|
||||
}};
|
||||
itemList.add(map);
|
||||
groupItem.put("items", itemList);
|
||||
lsGroup.add(groupItem);
|
||||
return lsGroup;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @description: 岗位序列
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/05/12
|
||||
* @version: 1.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue