From 60a874874e04c453e135f31202c4666e701ce0dd Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 6 Mar 2023 17:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B1=89=E6=A1=91=E9=83=A8=E9=97=A8=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E4=BA=8C=E5=BC=80=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E5=90=AF=E7=94=A8=E6=97=B6=E9=97=B4=E3=80=81=E5=B0=81?= =?UTF-8?q?=E5=AD=98=E6=97=B6=E9=97=B4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DepartmentServiceImpl.java | 17 ++++++++ .../util/saveimport/DepartmentImport.java | 41 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 955c0b36..28e64257 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -46,6 +46,7 @@ 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 weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.Util; @@ -173,6 +174,22 @@ public class DepartmentServiceImpl extends Service implements DepartmentService @Override public Long saveBaseForm(Map 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 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()); diff --git a/src/com/engine/organization/util/saveimport/DepartmentImport.java b/src/com/engine/organization/util/saveimport/DepartmentImport.java index 2b7b5baf..7977bc05 100644 --- a/src/com/engine/organization/util/saveimport/DepartmentImport.java +++ b/src/com/engine/organization/util/saveimport/DepartmentImport.java @@ -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; @@ -175,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++) { @@ -280,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 syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map, false).sync(); if (OrgImportUtil.isThrowError(syncMap)) { // 查询UUID