Compare commits

...

10 Commits

@ -7,6 +7,7 @@ import com.engine.organization.entity.job.vo.SingleJobTreeVO;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.List;
import java.util.Map;
@ -160,4 +161,12 @@ public interface DepartmentService {
*/
int moveDepartment(DepartmentMoveParam moveParam);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/21 11:37 AM
* @param: []
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
*/
XSSFWorkbook departmentExport();
}

@ -39,6 +39,7 @@ 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.excel.ExcelUtil;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.page.PageUtil;
@ -46,6 +47,8 @@ import com.engine.organization.util.tree.SearchTreeUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
@ -173,6 +176,22 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public Long saveBaseForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
/*
*
* ;
* ;
*/
String enableDate = Util.null2String(params.get("qyrq"));
String disableDate = Util.null2String(params.get("fcrq"));
String currentDate = DateUtil.getCurrentDate();
OrganizationAssert.notBlank(enableDate, "启用日期必填");
OrganizationAssert.isTrue(DateUtil.compDate(currentDate, enableDate) >= 0, "启用日期需大于等于当前日期");
if (StringUtils.isNotBlank(disableDate)) {
OrganizationAssert.isTrue(DateUtil.compDate(enableDate, disableDate) > 0, "启用日期需小于封存日期");
}
Map<String, Object> 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());
@ -206,6 +225,27 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
OrganizationAssert.isFalse(disableIds.contains(Integer.parseInt(supDepId)), "上级部门不能选择部门本身及其下级部门");
}
// 汉桑需求二开,启用日期、封存日期校验
String enableDate = Util.null2String(params.get("qyrq"));
String disableDate = Util.null2String(params.get("fcrq"));
String currentDate = DateUtil.getCurrentDate();
OrganizationAssert.notBlank(enableDate, "启用日期必填");
String oldEnableDate = "";
RecordSet rs = new RecordSet();
rs.executeQuery("select qyrq,fcrq from hrmdepartmentdefined where deptid = ?", ecDepartmentId);
if (rs.next()) {
oldEnableDate = rs.getString("qyrq");
}
if (!oldEnableDate.equals(enableDate)) {
OrganizationAssert.isTrue(DateUtil.compDate(currentDate, enableDate) >= 0, "启用日期需大于等于当前日期");
}
if (StringUtils.isNotBlank(disableDate)) {
OrganizationAssert.isTrue(DateUtil.compDate(enableDate, disableDate) > 0, "启用日期需小于封存日期");
}
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync();
return (long) ecDepartmentId;
@ -658,6 +698,58 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return 1;
}
@Override
public XSSFWorkbook departmentExport() {
String orderSql = PageInfoSortUtil.getSortSql("", " showorder ");
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
Map<Integer, DepartmentPO> poMaps = allList.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
List<DepartmentListDTO> dtoList = allList.stream().map(e ->
DepartmentListDTO
.builder()
.id(e.getId())
.departmentMark(e.getDepartmentMark())
.departmentName(e.getDepartmentName())
.departmentCode(e.getDepartmentCode())
.subCompanyName(0 == e.getSubCompanyId1() ? "" : MapperProxyFactory.getProxy(CompMapper.class).listById(e.getSubCompanyId1()).getSubCompanyName())
.supDepName(null == poMaps.get(e.getSupDepId()) ? "" : poMaps.get(e.getSupDepId()).getDepartmentName())
.bmfzr(DepartmentBO.getEmployeeNameById(e.getId()))
.canceled(null == e.getCanceled() ? 0 : e.getCanceled())
.build()).collect(Collectors.toList());
// 1.工作簿名称
String sheetName = HrmI18nUtil.getI18nLabel(85368, "部门档案数据");
// 2.表头(后面动态获取)
List<List<Object>> excelSheetData = new ArrayList<>();
String[] header = {
HrmI18nUtil.getI18nLabel( -93270, "部门名称"),
HrmI18nUtil.getI18nLabel( -93272, "编号"),
HrmI18nUtil.getI18nLabel( -93274, "部门简称"),
HrmI18nUtil.getI18nLabel( -93275, "所属分部"),
HrmI18nUtil.getI18nLabel( -93278, "上级部门"),
HrmI18nUtil.getI18nLabel( -93279, "部门负责人"),
HrmI18nUtil.getI18nLabel( -93280, "启用状态")
};
excelSheetData.add(Arrays.asList(header));
//数据
List<List<Object>> rows = new LinkedList<>();
for (DepartmentListDTO vo : dtoList) {
List<Object> row = new LinkedList<>();
row.add(vo.getDepartmentCode());
row.add(vo.getDepartmentName());
row.add(vo.getDepartmentMark());
row.add(vo.getSubCompanyName());
row.add(vo.getSupDepName());
row.add(vo.getBmfzr());
row.add(vo.getCanceled() == 0 ? "启用" : "未启用");
rows.add(row);
}
excelSheetData.addAll(rows);
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
}
/**
* id
*

@ -93,16 +93,16 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel
anchorList.add(Anchor.builder().id(formItem.getId()).title(formItem.getTitle()).build());
}
// 添加拓展页面信息
List<ResourceBaseTab> resourceBaseTabList = getPersonnelCardMapper().getResourceBaseTabList();
for (ResourceBaseTab resourceBaseTab : resourceBaseTabList) {
anchorList.add(Anchor.builder().id("tab" + resourceBaseTab.getId()).title(resourceBaseTab.getGroupName()).build());
}
//List<ResourceBaseTab> resourceBaseTabList = getPersonnelCardMapper().getResourceBaseTabList();
//for (ResourceBaseTab resourceBaseTab : resourceBaseTabList) {
// anchorList.add(Anchor.builder().id("tab" + resourceBaseTab.getId()).title(resourceBaseTab.getGroupName()).build());
//}
resultMap.put("buttons", getButtonList(userInfo.getEcId()));
resultMap.put("user", userInfo);
resultMap.put("statistical", statistical);
resultMap.put("formItems", formItemList);
resultMap.put("anchorList", anchorList);
resultMap.put("iframeList", getIframeList());
resultMap.put("iframeList", new ArrayList<>());
return resultMap;
}

@ -22,6 +22,7 @@ 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.Util;
import weaver.hrm.User;
@ -60,7 +61,8 @@ public class DepartmentImport {
List<FieldTransferParam> fieldDatas = importFields.stream().map(item -> FieldTransferParam.builder().id(item.getFieldId().toString()).name(item.getLabelName()).build()).collect(Collectors.toList());
returnMaps.put("data", fieldDatas);
// 设置必填字段
List<String> selectedKeys = importFields.stream().filter(item -> null != item.getIsSystem() && 1 == item.getIsSystem() && 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList());
// List<String> selectedKeys = importFields.stream().filter(item -> null != item.getIsSystem() && 1 == item.getIsSystem() && 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList());
List<String> selectedKeys = importFields.stream().filter(item -> 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList());
returnMaps.put("selectedKeys", selectedKeys);
return returnMaps;
}
@ -174,6 +176,8 @@ public class DepartmentImport {
Integer parentCompanyId = null;
Integer parentDepartmentId = null;
String departmentName = "";
String enableDate = "";
String disableDate = "";
historyDetailPO.setRowNums(String.valueOf(i + 1));
for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) {
@ -209,7 +213,7 @@ public class DepartmentImport {
} else if (StringUtils.isBlank(cellValue)) {
reallyValue = "";
} else {
reallyValue = HrmFieldManagerForService.getReallyFieldvalue(infoPO.getJsonObject(cellValue), null != infoPO.getIsSystem() && 1 == infoPO.getIsSystem());
reallyValue = HrmFieldManagerForService.getReallyFieldvalue(infoPO.getJsonObject(cellValue), true);
}
} catch (Exception e) {
historyDetailPO.setOperateDetail(cellValue + "转换失败");
@ -279,13 +283,51 @@ public class DepartmentImport {
map.put("departmentmark", departmentName);
map.put("departmentname", departmentName);
}
if ("qyrq".equals(infoPO.getFieldName())) {
enableDate = cellValue;
}
if ("fcrq".equals(infoPO.getFieldName())) {
disableDate = cellValue;
}
}
}
// 校验、数据交互
if (i == 0) {
continue;
}
/*
*
* ;
* ;
*/
if (StringUtils.isNotBlank(enableDate)) {
String currentDate = DateUtil.getCurrentDate();
if (DateUtil.compDate(currentDate, enableDate) < 0) {
historyDetailPO.setOperateDetail("启用日期需大于等于当前日期");
historyDetailPO.setStatus("0");
OrgImportUtil.saveImportDetailLog(historyDetailPO);
continue;
}
}
if (StringUtils.isNotBlank(disableDate)) {
if (DateUtil.compDate(enableDate, disableDate) <= 0) {
historyDetailPO.setOperateDetail("启用日期需小于封存日期");
historyDetailPO.setStatus("0");
OrgImportUtil.saveImportDetailLog(historyDetailPO);
continue;
}
}
if ("add".equals(operateType)) {
if (StringUtils.isBlank(enableDate)) {
historyDetailPO.setOperateDetail("启用日期为必填项");
historyDetailPO.setStatus("0");
OrgImportUtil.saveImportDetailLog(historyDetailPO);
continue;
}
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map, false).sync();
if (OrgImportUtil.isThrowError(syncMap)) {
// 查询UUID

@ -485,7 +485,7 @@ public class HrmImportProcessE9 extends BaseBean {
} else if ("".equals(vo.getEmail().trim())) {
hrm.setEmail("");
} else {
Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(?)$");
Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(?)$");
Matcher matcher = pattern.matcher(vo.getEmail());
if (!matcher.matches()) {
resultList.add(createLog(vo, "创建", "失败", SystemEnv.getHtmlLabelName(24570, userlanguage)));
@ -1048,7 +1048,7 @@ public class HrmImportProcessE9 extends BaseBean {
} else if ("".equals(vo.getEmail().trim())) {
hrm.setEmail("");
} else {
Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(?)$");
Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(?)$");
Matcher matcher = pattern.matcher(vo.getEmail());
if (!matcher.matches()) {
resultList.add(createLog(vo, "更新", "失败", SystemEnv.getHtmlLabelName(24570, userlanguage)));
@ -2530,9 +2530,9 @@ public class HrmImportProcessE9 extends BaseBean {
public void getKeyMap(String keyField) {
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";
sql = "select status,id, accounttype,isADAccount,certificatenum,loginid,workcode, ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from hrmResource";
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";
sql = "select status,id, accounttype,isADAccount,certificatenum,loginid,workcode, ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from hrmResource";
}
recordSet.execute(sql);
String cerNum;
@ -2556,7 +2556,11 @@ public class HrmImportProcessE9 extends BaseBean {
String accounttype = recordSet.getString("accounttype");
if (!"1".equalsIgnoreCase(accounttype)) {
if (StringUtil.isNotNull(cerNum)) {
certificateNums.put(StringUtil.vString(cerNum), recordSet.getInt("id"));
String status = Util.null2String(recordSet.getString("status"));
// 离职状态的身份证号不做重复校验
if (StringUtils.isNotBlank(status) && 4 < Integer.parseInt(status)) {
certificateNums.put(StringUtil.vString(cerNum), recordSet.getInt("id"));
}
}
}
}

@ -2,6 +2,7 @@ package com.engine.organization.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alipay.oceanbase.jdbc.StringUtils;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.DeleteParam;
@ -10,18 +11,25 @@ import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.util.response.ReturnResult;
import com.engine.organization.wrapper.DepartmentWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author weaver_cl
@ -333,4 +341,28 @@ public class DepartmentController {
}
}
@GET
@Path("/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response departmentExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getDepartmentWrapper(user).departmentExport();
String time = LocalDate.now().toString();
String fileName = "部门导出" + time;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
}
}

@ -21,6 +21,7 @@ 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 org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.util.Collection;
@ -259,4 +260,9 @@ public class DepartmentWrapper extends OrganizationWrapper {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment;
}
public XSSFWorkbook departmentExport() {
return getDepartmentService(user).departmentExport();
}
}

Loading…
Cancel
Save