|
|
|
@ -1,7 +1,17 @@
|
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
|
import com.cloudstore.dev.api.service.Service_DevTable;
|
|
|
|
|
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
|
|
|
|
|
import com.engine.organization.mapper.resource.HrmResourceMapper;
|
|
|
|
|
import com.engine.organization.mapper.resource.ResourceMapper;
|
|
|
|
|
import com.engine.organization.service.ExportCommonService;
|
|
|
|
|
import com.engine.organization.util.HrmI18nUtil;
|
|
|
|
@ -10,11 +20,13 @@ import com.engine.organization.util.detach.DetachUtil;
|
|
|
|
|
import com.engine.organization.util.excel.ExcelUtil;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -73,5 +85,107 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ
|
|
|
|
|
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public XSSFWorkbook resourceExport(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
List<String> headerList = new ArrayList<>();
|
|
|
|
|
List<Object> headerNameList = new ArrayList<>();
|
|
|
|
|
OrganizationWeaTable<HrmResourceVO> table = new OrganizationWeaTable<>(user, HrmResourceVO.class);
|
|
|
|
|
String sqlWhere = " where 1 = 1 and t.status < 4 and (t.accounttype is null or t.accounttype != 1)";
|
|
|
|
|
// 分权查询
|
|
|
|
|
DetachUtil detachUtil = new DetachUtil(user);
|
|
|
|
|
String parentCompanyIds = detachUtil.getJclRoleLevels();
|
|
|
|
|
if (detachUtil.isDETACH()) {
|
|
|
|
|
sqlWhere += " and t.subcompanyid1 in(" + parentCompanyIds + ")";
|
|
|
|
|
}
|
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
|
List<WeaTableColumn> weaTableColumnList = new ArrayList<>();
|
|
|
|
|
String columns = "";
|
|
|
|
|
List<String> fields = new ArrayList<>();
|
|
|
|
|
HrmResourceServiceImpl hrmResourceService = new HrmResourceServiceImpl();
|
|
|
|
|
List<SearchConditionGroup> allConditions = hrmResourceService.getAllConditions();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//初次使用,无模板初始值
|
|
|
|
|
columns = "-1_hrm_departmentid,-1_hrm_jobtitle,3_cus_field20,-1_hrm_jobactivity,-1_hrm_lastname,-1_hrm_sex,1_hrm_certificatenum,1_hrm_birthday,-1_hrm_jobcall,-1_cus_field7,1_cus_field18,-1_hrm_mobile,1_hrm_folk,1_hrm_nativeplace,1_hrm_regresidentplace,1_hrm_maritalstatus,1_hrm_policy,1_hrm_educationlevel,1_hrm_degree,1_cus_field8,1_cus_field9,1_cus_field10,1_cus_field11,1_cus_field12,3_hrm_companystartdate,3_hrm_probationenddate,3_hrm_startdate,3_hrm_enddate,1_cus_field14,1_cus_field15,3_cus_field21,-1_hrm_status,-1_cus_field6,3_cus_field19,-1_hrm_workcode";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> columnList = Arrays.asList(columns.split(","));
|
|
|
|
|
BigDecimal decimal = new BigDecimal(100 / columnList.size());
|
|
|
|
|
for (SearchConditionGroup allCondition : allConditions) {
|
|
|
|
|
List<SearchConditionItem> items = allCondition.getItems();
|
|
|
|
|
for (SearchConditionItem item : items) {
|
|
|
|
|
String columnName = item.getDomkey()[0];
|
|
|
|
|
fields.add(hrmResourceService.buildTableSql(columnName) + " as " + hrmResourceService.buildTableSql(columnName).replace(".", "_"));
|
|
|
|
|
|
|
|
|
|
String scopeId = columnName.split("_")[0];
|
|
|
|
|
String fieldName = columnName.substring(columnName.lastIndexOf("_") + 1);
|
|
|
|
|
WeaTableColumn weaTableColumn = new WeaTableColumn();
|
|
|
|
|
weaTableColumn.setText(MapperProxyFactory.getProxy(HrmResourceMapper.class).queryLabelName(fieldName, scopeId));
|
|
|
|
|
weaTableColumn.setColumn(hrmResourceService.buildTableSql(columnName).replace(".", "_"));
|
|
|
|
|
weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE);
|
|
|
|
|
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
|
|
|
|
|
weaTableColumn.setOtherpara(columnName);
|
|
|
|
|
weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%");
|
|
|
|
|
if (weaTableColumn.getDisplay().getBoolVal()) {
|
|
|
|
|
weaTableColumnList.add(weaTableColumn);
|
|
|
|
|
headerList.add(weaTableColumn.getColumn());
|
|
|
|
|
headerNameList.add(weaTableColumn.getText());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 增加id字段,跳转人员卡片
|
|
|
|
|
WeaTableColumn weaTableColumn = new WeaTableColumn();
|
|
|
|
|
weaTableColumn.setColumn("id");
|
|
|
|
|
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
|
|
|
|
|
weaTableColumnList.add(weaTableColumn);
|
|
|
|
|
fields.add("t.id");
|
|
|
|
|
|
|
|
|
|
// 增加分部字段
|
|
|
|
|
WeaTableColumn weaTableColumn1 = new WeaTableColumn();
|
|
|
|
|
weaTableColumn1.setText("公司(分部)");
|
|
|
|
|
weaTableColumn1.setColumn("subcompanyid1");
|
|
|
|
|
weaTableColumn1.setDisplay(WeaBoolAttr.TRUE);
|
|
|
|
|
weaTableColumn1.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getCompanyName");
|
|
|
|
|
fields.add("t.subcompanyid1");
|
|
|
|
|
headerList.add(0, weaTableColumn1.getColumn());
|
|
|
|
|
headerNameList.add(0, weaTableColumn1.getText());
|
|
|
|
|
weaTableColumnList.add(0, weaTableColumn1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table.setBackfields(StringUtils.join(fields, ","));
|
|
|
|
|
table.setColumns(weaTableColumnList);
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
|
result.success();
|
|
|
|
|
Map<String, Object> resultMap = result.getResultMap();
|
|
|
|
|
String dataKey = Util.null2String(resultMap.get("datas"));
|
|
|
|
|
|
|
|
|
|
String getcounts = new Service_DevTable().getcounts(request, response, dataKey);
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(getcounts);
|
|
|
|
|
String count = jsonObject.getString("count");
|
|
|
|
|
|
|
|
|
|
String datas = new Service_DevTable().datas(request, response, dataKey, count, "[]", "", "", "1", "");
|
|
|
|
|
jsonObject = JSON.parseObject(datas);
|
|
|
|
|
List<Map<String, Object>> datas1 = (List<Map<String, Object>>) jsonObject.get("datas");
|
|
|
|
|
|
|
|
|
|
List<List<Object>> rows = new LinkedList<>();
|
|
|
|
|
for (Map<String, Object> map : datas1) {
|
|
|
|
|
List<Object> row = new LinkedList<>();
|
|
|
|
|
for (String s : headerList) {
|
|
|
|
|
JSONObject o = (JSONObject) map;
|
|
|
|
|
String value = o.getString(s + "span");
|
|
|
|
|
row.add(value);
|
|
|
|
|
}
|
|
|
|
|
rows.add(row);
|
|
|
|
|
}
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
excelSheetData.add(headerNameList);
|
|
|
|
|
|
|
|
|
|
excelSheetData.addAll(rows);
|
|
|
|
|
String sheetName = HrmI18nUtil.getI18nLabel(85368, "人员档案数据");
|
|
|
|
|
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|