导出列根据模板生成

pull/274/head
dxfeng 9 months ago
parent af6b076584
commit 6af0092549

@ -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<SearchConditionGroup> allConditions = hrmResourceService.getAllConditions();
List<String> 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<String> 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()) {

@ -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("&nbsp", "");
return fieldvalue;
} catch (Exception e) {
return "";
}
}
public static String getDepartmentName(String departmentId) {
return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(Integer.parseInt(departmentId));
}

Loading…
Cancel
Save