From 6af0092549a9ed337e4a47cb3ae8670dfe78d712 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Thu, 25 Jul 2024 16:56:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=88=97=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExportCommonServiceImpl.java | 34 ++++++++++++++----- .../transmethod/HrmResourceTransMethod.java | 33 ++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java index 5c2b1369..d755dfbf 100644 --- a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java @@ -14,12 +14,14 @@ import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.department.bo.DepartmentBO; import com.engine.organization.entity.department.dto.DepartmentListDTO; import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplatePO; import com.engine.organization.entity.hrmresource.po.SearchTemplatePO; import com.engine.organization.entity.hrmresource.vo.HrmResourceVO; import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.entity.staff.vo.StaffTableVO; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.resource.HrmResourceMapper; +import com.engine.organization.mapper.resource.JclOrgCustomTemplateMapper; import com.engine.organization.mapper.resource.ResourceMapper; import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffPlanMapper; @@ -141,18 +143,31 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ HrmResourceServiceImpl hrmResourceService = ServiceUtil.getService(HrmResourceServiceImpl.class,user); List allConditions = hrmResourceService.getAllConditions(); - List columnList; + JclOrgCustomTemplatePO jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).queryIsusedTemp("1", String.valueOf(user.getUID())); - // 查询当前台账定制列 - SearchTemplatePO usedCustomTemplate = MapperProxyFactory.getProxy(HrmResourceMapper.class).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"; - columnList = Arrays.asList(selectKeys.split(",")); + //2.是否存在通用模板 + if (null == jclOrgCustomTemplatePO) { + jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).queryOverAll(); + } + + String columns = ""; + if (jclOrgCustomTemplatePO != null) { + if (org.apache.commons.lang3.StringUtils.isNotBlank(jclOrgCustomTemplatePO.getBasicFields())) { + columns = jclOrgCustomTemplatePO.getBasicFields(); + } + if (org.apache.commons.lang3.StringUtils.isNotBlank(jclOrgCustomTemplatePO.getPersonalFields())) { + columns = columns + "," + jclOrgCustomTemplatePO.getPersonalFields(); + } + if (org.apache.commons.lang3.StringUtils.isNotBlank(jclOrgCustomTemplatePO.getWorkFields())) { + columns = columns + "," + jclOrgCustomTemplatePO.getWorkFields(); + } } else { - columnList = hrmResourceService.getSelectKeys(usedCustomTemplate); + //初次使用,无模板初始值 + 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()); @@ -168,7 +183,8 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ weaTableColumn.setText(MapperProxyFactory.getProxy(HrmResourceMapper.class).queryLabelName(fieldName, scopeId, user.getLanguage())); weaTableColumn.setColumn(hrmResourceService.buildTableSql(columnName).replace(".", "_")); weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE); - weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue"); + // 导出专用转换,去除html标签 + weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValueExp"); weaTableColumn.setOtherpara(columnName); weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%"); if (weaTableColumn.getDisplay().getBoolVal()) { diff --git a/src/com/engine/organization/transmethod/HrmResourceTransMethod.java b/src/com/engine/organization/transmethod/HrmResourceTransMethod.java index 35ae848f..c3313fd0 100644 --- a/src/com/engine/organization/transmethod/HrmResourceTransMethod.java +++ b/src/com/engine/organization/transmethod/HrmResourceTransMethod.java @@ -16,6 +16,13 @@ import weaver.hrm.definedfield.HrmFieldManager; */ public class HrmResourceTransMethod { + /** + * 字段展示内容转换,列表用 + * + * @param id + * @param para + * @return + */ public static String getFieldTrueValue(String id, String para) { HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", Integer.parseInt(para.split("_")[0])); String fieldName = para.substring(para.lastIndexOf("_") + 1); @@ -32,6 +39,32 @@ public class HrmResourceTransMethod { } } + /** + * 字段展示内容转换,导出用 + * + * @param id + * @param para + * @return + */ + public static String getFieldTrueValueExp(String id, String para) { + HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", Integer.parseInt(para.split("_")[0])); + String fieldName = para.substring(para.lastIndexOf("_") + 1); + JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName); + User user = new User(); + user.setUid(1); + try { + if (hfm.isBaseField(fieldName) && "jobactivity".equals(fieldName)) { + hrmFieldConf.put("type", 282); + } + String fieldvalue = hfm.getFieldvalue(null, user, null, hrmFieldConf.getString("dmlurl"), hrmFieldConf.getInt("id"), hrmFieldConf.getInt("fieldhtmltype"), hrmFieldConf.getInt("type"), id, 0, fieldName); + // fieldvalue去除Html内容 + fieldvalue = fieldvalue.replaceAll("<[^>]*>", "").replaceAll(" ", ""); + return fieldvalue; + } catch (Exception e) { + return ""; + } + } + public static String getDepartmentName(String departmentId) { return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(Integer.parseInt(departmentId)); }