Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
ff9fc5f959 | 2 years ago |
|
1cc23736f7 | 2 years ago |
|
7acfd26638 | 2 years ago |
|
0dccc72bd9 | 2 years ago |
|
81a177301b | 2 years ago |
|
f4a31f20d9 | 2 years ago |
@ -1,13 +0,0 @@
|
||||
package com.api.jygf.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Path("/mobile/permission")
|
||||
public class MobilePermissionsAction extends com.engine.jygf.web.MobilePermissionsAction {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.api.thinktrans.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 10:41 AM
|
||||
* @Description: 报表汇总
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Path("/thinktrans/report")
|
||||
public class ReportCollectController extends com.engine.thinktrans.web.ReportCollectController {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.api.thinktrans.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/17 1:57 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Path("/thinktrans/common")
|
||||
public class ReportExportController extends com.engine.thinktrans.web.ReportExportController {
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.engine.jygf.cmd;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.User;
|
||||
import weaver.wechat.util.Utils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class MobilePermissionsCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
private static final String FIELDID = "field100043"; //移动电话自定义字段field100026
|
||||
|
||||
private static final String SCOPE = "HrmCustomFieldByInfoType";
|
||||
|
||||
private static final String SCOPEID = "-1";
|
||||
|
||||
public MobilePermissionsCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
String uid = Utils.null2String(user.getUID());
|
||||
RecordSet rs = new RecordSet();
|
||||
HashSet<String> ids = new HashSet<>();
|
||||
ids.add(uid);
|
||||
rs.executeQuery("select ckr,bckr from uf_yddhqx_dt1");
|
||||
while (rs.next()) {
|
||||
String ckr = Utils.null2String(rs.getString("ckr"));
|
||||
String bckr = Utils.null2String(rs.getString("bckr"));
|
||||
if (Arrays.asList(ckr.split(",")).contains(uid)) {
|
||||
ids.addAll(Arrays.asList(bckr.split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,String> mobileInfo = new HashMap<>();
|
||||
String value = StringUtils.join(ids,",");
|
||||
rs.executeQuery("select id,"+FIELDID+" from cus_fielddata where scope = ? and scopeid = ?" +
|
||||
" and id in ("+value+")",SCOPE,SCOPEID);
|
||||
while (rs.next()){
|
||||
mobileInfo.put(Utils.null2String(rs.getString("id")),rs.getString(FIELDID));
|
||||
}
|
||||
|
||||
data.put("ids",ids);
|
||||
data.put("mobileInfo",mobileInfo);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.engine.jygf.service;
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
public interface MobilePermissionsService {
|
||||
|
||||
Map<String, Object> getPermissionInfo(Map<String, Object> params, User user);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.engine.jygf.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.jygf.cmd.MobilePermissionsCmd;
|
||||
import com.engine.jygf.service.MobilePermissionsService;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class MobilePermissionsServiceImpl extends Service implements MobilePermissionsService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPermissionInfo(Map<String, Object> params, User user) {
|
||||
return commandExecutor.execute(new MobilePermissionsCmd(params,user));
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.engine.jygf.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.jygf.service.MobilePermissionsService;
|
||||
import com.engine.jygf.service.impl.MobilePermissionsServiceImpl;
|
||||
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.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class MobilePermissionsAction {
|
||||
|
||||
public MobilePermissionsService getMobilePermissionsService(User user) {
|
||||
return ServiceUtil.getService(MobilePermissionsServiceImpl.class,user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 晶优光伏 移动电话通过建模控制权限 通讯录显示
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/controller")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getPermissionInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
//实例化Service 并调用业务类处理
|
||||
apidatas = getMobilePermissionsService(user).getPermissionInfo(ParamUtil.request2Map(request), user);
|
||||
} catch (Exception e) {
|
||||
//异常处理
|
||||
apidatas.put("api_status", false);
|
||||
}
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.engine.thinktrans.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/22 2:32 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PersonnelSizeTop<T> {
|
||||
|
||||
private String title;
|
||||
|
||||
private T count;
|
||||
|
||||
private String color;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.engine.thinktrans.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 2:24 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReportChildrenData {
|
||||
|
||||
private List<String> data;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.engine.thinktrans.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 1:34 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReportColumns {
|
||||
|
||||
private String title;
|
||||
|
||||
private String key;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.engine.thinktrans.entity.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/24 10:48 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PersonnelSizeTopParam {
|
||||
|
||||
private Integer year;
|
||||
|
||||
private Integer company;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.engine.thinktrans.entity.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 2:43 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TendencyReportParam {
|
||||
|
||||
private String deptIds;
|
||||
|
||||
private Integer year;
|
||||
|
||||
private String useKind;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.engine.thinktrans.entity.vo;
|
||||
|
||||
import com.engine.thinktrans.entity.ReportChildrenData;
|
||||
import com.engine.thinktrans.entity.ReportColumns;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 11:44 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TendencyReportVO {
|
||||
|
||||
private List<ReportColumns> columns;
|
||||
|
||||
private List<ReportChildrenData> datas;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.engine.thinktrans.exception;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 2:37 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CustomizeRunTimeException extends RuntimeException{
|
||||
|
||||
public CustomizeRunTimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CustomizeRunTimeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CustomizeRunTimeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.engine.thinktrans.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/20 3:48 PM
|
||||
* @Description: 建模表数据分析存储
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface CubeRecordDataService {
|
||||
|
||||
/**
|
||||
* @Description: 离职率统计 uf_lzlbb
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/20 4:11 PM
|
||||
* @param: [year]
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String,Object> dimissionRate(Integer year);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.engine.thinktrans.service;
|
||||
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import com.engine.thinktrans.entity.vo.TendencyReportVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 10:43 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface ReportCollectService {
|
||||
|
||||
/**
|
||||
* @Description: 年度人力趋势报表
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/16 2:39 PM
|
||||
* @param: []
|
||||
* @return: com.engine.thinktrans.entity.vo.TendencyReportVO
|
||||
*/
|
||||
TendencyReportVO getPersonTendency(TendencyReportParam tendencyReportParam);
|
||||
|
||||
/**
|
||||
* @Description: 实时在职人数
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/20 10:05 AM
|
||||
* @param: [param]
|
||||
* @return: com.engine.thinktrans.entity.vo.TendencyReportVO
|
||||
*/
|
||||
TendencyReportVO getOnJobStatistics();
|
||||
|
||||
/**
|
||||
* @Description: 公司人员规模分析表
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/22 10:11 AM
|
||||
* @param: [year]
|
||||
* @return: com.engine.thinktrans.entity.vo.TendencyReportVO
|
||||
*/
|
||||
TendencyReportVO getPersonnelSize(PersonnelSizeTopParam param);
|
||||
|
||||
/**
|
||||
* @Description: 公司人员规模分析表顶部
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/22 2:30 PM
|
||||
* @param: [integer]
|
||||
* @return: Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> getTop(PersonnelSizeTopParam param);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.engine.thinktrans.service;
|
||||
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/17 2:03 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface ReportExportService {
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 年度人力趋势报表
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/17 2:43 PM
|
||||
* @param: [tendencyReportParam]
|
||||
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
*/
|
||||
XSSFWorkbook personTendencyExport(TendencyReportParam tendencyReportParam);
|
||||
|
||||
/**
|
||||
* @Description: 实时在职人数统计
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/20 3:02 PM
|
||||
* @param: []
|
||||
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
*/
|
||||
XSSFWorkbook onJobStatisticsExport();
|
||||
|
||||
/**
|
||||
* @Description: 公司人员规模分析
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/22 3:02 PM
|
||||
* @param: [year]
|
||||
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
*/
|
||||
XSSFWorkbook personnelSizeExport(PersonnelSizeTopParam param);
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.engine.thinktrans.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.thinktrans.service.CubeRecordDataService;
|
||||
import com.engine.thinktrans.util.CommonDateUtil;
|
||||
import com.weaver.general.Util;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
|
||||
import java.time.YearMonth;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/20 3:48 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CubeRecordDataServiceImpl extends Service implements CubeRecordDataService {
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> dimissionRate(Integer year) {
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
|
||||
List<List> datas = new ArrayList<>();
|
||||
List<Integer> deptList = new ArrayList<>();
|
||||
rs.executeQuery("select a.deptid from hrmdepartmentdefined a left join hrmdepartment b on a.deptid =b.id where a.bmcj in (0,1)" +
|
||||
" and (b.canceled = 0 or b.canceled is null)");
|
||||
while (rs.next()) {
|
||||
deptList.add(Util.getIntValue(rs.getString("deptid")));
|
||||
}
|
||||
|
||||
// 合计
|
||||
deptList.add(-9999);
|
||||
|
||||
deptList.forEach(id -> {
|
||||
List<Object> yearList = getYearData(year,id);
|
||||
datas.add(yearList);
|
||||
});
|
||||
|
||||
if (datas.size() > 0) {
|
||||
rs.executeUpdate("delete from uf_lzlbb where nf = ?",year);
|
||||
rs.executeBatchSql("insert into uf_lzlbb(bmmc,nf,bmmc1,lzrs1,zrl1,lzl1,lzrs2,zrl2,lzl2,lzrs3,zrl3,lzl3,lzrs4,zrl4,lzl4,lzrs5,zrl5,lzl5," +
|
||||
" lzrs6,zrl6,lzl6,lzrs7,zrl7,lzl7,lzrs8,zrl8,lzl8,lzrs9,zrl9,lzl9,lzrs10,zrl10,lzl10,lzrs11,zrl11,lzl11,lzrs12,zrl12,lzl12) " +
|
||||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", datas);
|
||||
}
|
||||
|
||||
result.put("count",datas.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private List<Object> getYearData(Integer year, Integer id) {
|
||||
RecordSet rs = new RecordSet();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
List<Object> data = new ArrayList<>();
|
||||
data.add(id);
|
||||
data.add(year);
|
||||
ArrayList<String> allSubDepartment = new ArrayList<>();
|
||||
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(year);
|
||||
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("select count(1) as sum from hrmresource where companystartdate <= ? ");
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select count(1) as dimension from hrmstatushistory h left join hrmresource s on h.resourceid = s.id where h.type_n = 5 " +
|
||||
" and h.changedate >= ? and h.changedate <= ? ");
|
||||
|
||||
if (id != -9999) {
|
||||
data.add(departmentComInfo.getDepartmentName(String.valueOf(id)));
|
||||
departmentComInfo.getAllChildDeptByDepId(allSubDepartment, String.valueOf(id));
|
||||
allSubDepartment.add(String.valueOf(id));
|
||||
String allId = StringUtils.join(allSubDepartment, ",");
|
||||
st.append(" and departmentid in (").append(allId).append(")");
|
||||
sql.append(" and s.departmentid in (").append(allId).append(")");
|
||||
}else {
|
||||
data.add("合计");
|
||||
}
|
||||
|
||||
|
||||
for (YearMonth yearMonth : yearMonths) {
|
||||
int dimension = 0;
|
||||
int sum = 0;
|
||||
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now()));
|
||||
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
|
||||
rs.executeQuery(st.toString(), endMonth);
|
||||
if (rs.next()) {
|
||||
sum = Util.getIntValue(rs.getString("sum"));
|
||||
}
|
||||
rs.executeQuery(sql.toString(), startMonth, endMonth);
|
||||
if (rs.next()) {
|
||||
dimension = Util.getIntValue(rs.getString("dimension"));
|
||||
}
|
||||
float result = sum == 0 ? 0 : ((float)dimension) / sum;
|
||||
double rate = sum == 0 ? 0 : Math.round(result * 100.0) / 100.0;
|
||||
data.add(dimension);
|
||||
data.add(sum);
|
||||
data.add(rate);
|
||||
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,418 @@
|
||||
package com.engine.thinktrans.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.thinktrans.entity.PersonnelSizeTop;
|
||||
import com.engine.thinktrans.entity.ReportChildrenData;
|
||||
import com.engine.thinktrans.entity.ReportColumns;
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import com.engine.thinktrans.entity.vo.TendencyReportVO;
|
||||
import com.engine.thinktrans.service.ReportCollectService;
|
||||
import com.engine.thinktrans.util.CommonDateUtil;
|
||||
import com.weaver.general.Util;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.company.SubCompanyComInfo;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Year;
|
||||
import java.time.YearMonth;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 10:43 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ReportCollectServiceImpl extends Service implements ReportCollectService {
|
||||
|
||||
@Override
|
||||
public TendencyReportVO getPersonTendency(TendencyReportParam tendencyReportParam) {
|
||||
|
||||
List<ReportColumns> columns = getPTReportColumns();
|
||||
List<Integer> deptList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select a.deptid from hrmdepartmentdefined a left join hrmdepartment b on a.deptid =b.id where a.bmcj in (0,1)" +
|
||||
" and (b.canceled = 0 or b.canceled is null)");
|
||||
while (rs.next()) {
|
||||
deptList.add(Util.getIntValue(rs.getString("deptid")));
|
||||
}
|
||||
String deptIds = tendencyReportParam.getDeptIds();
|
||||
if (StringUtils.isNotEmpty(deptIds)) {
|
||||
List<Integer> list = Arrays.stream(deptIds.split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
deptList = list.stream()
|
||||
.filter(deptList::contains)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<ReportChildrenData> datas = new ArrayList<>();
|
||||
List<List<Integer>> countLists = new ArrayList<>();
|
||||
|
||||
deptList.forEach(id -> {
|
||||
List<Integer> countList = new ArrayList<>();
|
||||
ReportChildrenData childrenData = getReportChildrenData(tendencyReportParam,id,countList);
|
||||
datas.add(childrenData);
|
||||
countLists.add(countList);
|
||||
});
|
||||
|
||||
//求和
|
||||
List<Integer> result = summary(countLists);
|
||||
|
||||
List<String> stringList = result.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> sums = new ArrayList<>();
|
||||
sums.add("总数");
|
||||
sums.addAll(stringList);
|
||||
|
||||
datas.add(ReportChildrenData.builder().data(sums).build());
|
||||
return TendencyReportVO.builder()
|
||||
.columns(columns)
|
||||
.datas(datas)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TendencyReportVO getOnJobStatistics() {
|
||||
List<ReportColumns> columns = getOJSReportColumns();
|
||||
List<Integer> deptList = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select a.deptid from hrmdepartmentdefined a left join hrmdepartment b on a.deptid =b.id where a.bmcj in (0,1)" +
|
||||
" and (b.canceled = 0 or b.canceled is null)");
|
||||
while (rs.next()) {
|
||||
deptList.add(Util.getIntValue(rs.getString("deptid")));
|
||||
}
|
||||
|
||||
|
||||
List<ReportChildrenData> datas = new ArrayList<>();
|
||||
List<List<Integer>> countLists = new ArrayList<>();
|
||||
|
||||
deptList.forEach(id -> {
|
||||
List<Integer> countList = new ArrayList<>();
|
||||
ReportChildrenData childrenData = getOnJobChildrenData(id,countList);
|
||||
datas.add(childrenData);
|
||||
countLists.add(countList);
|
||||
});
|
||||
|
||||
//求和
|
||||
List<Integer> result = summary(countLists);
|
||||
|
||||
List<String> stringList = result.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> sums = new ArrayList<>();
|
||||
sums.add("/");
|
||||
sums.add("全公司");
|
||||
sums.addAll(stringList);
|
||||
|
||||
datas.add(ReportChildrenData.builder().data(sums).build());
|
||||
return TendencyReportVO.builder()
|
||||
.columns(columns)
|
||||
.datas(datas)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TendencyReportVO getPersonnelSize(PersonnelSizeTopParam param) {
|
||||
List<ReportColumns> columns = getPSReportColumns();
|
||||
List<String> addList = new ArrayList<>();
|
||||
List<String> addRate = new ArrayList<>();
|
||||
List<ReportChildrenData> datas = getPersonnelSizeData(param,addList,addRate);
|
||||
return TendencyReportVO.builder()
|
||||
.columns(columns)
|
||||
.datas(datas)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTop(PersonnelSizeTopParam param) {
|
||||
Map<String,Object> result = new HashMap<>(4);
|
||||
List<String> addList = new ArrayList<>();
|
||||
List<String> addRate = new ArrayList<>();
|
||||
SubCompanyComInfo comInfo = new SubCompanyComInfo();
|
||||
ArrayList compList = new ArrayList<>();
|
||||
if (param.getCompany() != null) {
|
||||
comInfo.getSubCompanyLists(String.valueOf(param.getCompany()),compList);
|
||||
compList.add(param.getCompany());
|
||||
}
|
||||
|
||||
if (param.getYear() == null) {
|
||||
param.setYear(Year.now().getValue());
|
||||
}
|
||||
getPersonnelSizeData(param,addList,addRate);
|
||||
List<PersonnelSizeTop> pstList = new ArrayList<>();
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String startYear = CommonDateUtil.getYearDayFirst(param.getYear());
|
||||
String endYear = CommonDateUtil.getYearDayEnd(param.getYear());
|
||||
int sumStart = sumsByFirstDate(startYear,compList);
|
||||
int sumEnd = sumsByFirstDate(endYear,compList);
|
||||
int entrySum = sumsByTwoDate(startYear,endYear,compList);
|
||||
int leaveSum = 0;
|
||||
|
||||
rs.executeQuery("select count(1) as leavesum from hrmstatushistory where type_n = 5 and changedate >= ? and changedate <= ?",startYear,endYear);
|
||||
if (rs.next()) {
|
||||
leaveSum = Util.getIntValue(rs.getString("leavesum"));
|
||||
}
|
||||
int addPerson = entrySum - leaveSum;
|
||||
|
||||
String rate = calculateRate(addRate,addPerson,sumStart);
|
||||
|
||||
pstList.add(PersonnelSizeTop.builder().title("年初人数").count(sumStart).color("#67c29a").build());
|
||||
pstList.add(PersonnelSizeTop.builder().title("累计入职人数").count(entrySum).color("#9c5113").build());
|
||||
pstList.add(PersonnelSizeTop.builder().title("累计离职人数").count(leaveSum).color("#e26b0a").build());
|
||||
pstList.add(PersonnelSizeTop.builder().title("年末人数").count(sumEnd).color("#35889c").build());
|
||||
pstList.add(PersonnelSizeTop.builder().title("净增长率").count(rate).color("#f6d262").build());
|
||||
result.put("pstTop",pstList);
|
||||
result.put("list",addList);
|
||||
result.put("rate",addRate);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<ReportChildrenData> getPersonnelSizeData(PersonnelSizeTopParam param, List<String> addList, List<String> addRate) {
|
||||
RecordSet rs = new RecordSet();
|
||||
List<ReportChildrenData> result = new ArrayList<>();
|
||||
if (param.getYear() == null) {
|
||||
param.setYear(Year.now().getValue());
|
||||
}
|
||||
SubCompanyComInfo comInfo = new SubCompanyComInfo();
|
||||
ArrayList compList = new ArrayList<>();
|
||||
if (param.getCompany() != null) {
|
||||
comInfo.getSubCompanyLists(String.valueOf(param.getCompany()),compList);
|
||||
compList.add(param.getCompany());
|
||||
}
|
||||
|
||||
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(param.getYear());
|
||||
for (int i = 0; i < yearMonths.size(); i++) {
|
||||
List<String> data = new ArrayList<>();
|
||||
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonths.get(i)));
|
||||
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonths.get(i)));
|
||||
int sumStart = sumsByFirstDate(startMonth,compList);
|
||||
int sumEnd = sumsByFirstDate(endMonth,compList);
|
||||
int entrySum = sumsByTwoDate(startMonth,endMonth,compList);
|
||||
int leaveSum = 0;
|
||||
data.add(String.format("%d 月",i+1));
|
||||
rs.executeQuery("select count(1) as leavesum from hrmstatushistory where type_n = 5 and changedate >= ? and changedate <= ?",startMonth,endMonth);
|
||||
if (rs.next()) {
|
||||
leaveSum = Util.getIntValue(rs.getString("leavesum"));
|
||||
}
|
||||
int addPerson = entrySum - leaveSum;
|
||||
|
||||
String rate = calculateRate(addRate,addPerson,sumStart);
|
||||
addList.add(String.valueOf(addPerson));
|
||||
|
||||
data.add(String.valueOf(sumStart));
|
||||
data.add(String.valueOf(entrySum));
|
||||
data.add(String.valueOf(leaveSum));
|
||||
data.add(String.valueOf(addPerson));
|
||||
data.add(String.valueOf(sumEnd));
|
||||
data.add(rate);
|
||||
result.add(ReportChildrenData.builder().data(data).build());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<ReportColumns> getPSReportColumns() {
|
||||
List<ReportColumns> columns = new ArrayList<>();
|
||||
columns.add(ReportColumns.builder().title("月份").key("0").build());
|
||||
columns.add(ReportColumns.builder().title("期初人数").key("1").build());
|
||||
columns.add(ReportColumns.builder().title("入职人数").key("2").build());
|
||||
columns.add(ReportColumns.builder().title("离职人数").key("3").build());
|
||||
columns.add(ReportColumns.builder().title("净增长人数").key("4").build());
|
||||
columns.add(ReportColumns.builder().title("期末人数").key("5").build());
|
||||
columns.add(ReportColumns.builder().title("净增长率").key("6").build());
|
||||
return columns;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private ReportChildrenData getOnJobChildrenData(Integer id, List<Integer> countList) {
|
||||
RecordSet rs = new RecordSet();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
List<String> data = new ArrayList<>();
|
||||
data.add(departmentComInfo.getDepartmentCode(String.valueOf(id)));
|
||||
data.add(departmentComInfo.getDepartmentName(String.valueOf(id)));
|
||||
ArrayList<String> allSubDepartment = new ArrayList<>();
|
||||
departmentComInfo.getAllChildDeptByDepId(allSubDepartment, String.valueOf(id));
|
||||
allSubDepartment.add(String.valueOf(id));
|
||||
String allId = StringUtils.join(allSubDepartment, ",");
|
||||
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ? and departmentid in");
|
||||
st.append(" (").append(allId).append(")");
|
||||
yearMonths.forEach(yearMonth -> {
|
||||
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
|
||||
rs.executeQuery(st.toString(),endMonth);
|
||||
if (rs.next()) {
|
||||
Integer sum = Util.getIntValue(rs.getString("sum"),0);
|
||||
data.add(String.valueOf(sum));
|
||||
countList.add(sum);
|
||||
}
|
||||
});
|
||||
return ReportChildrenData.builder().data(data).build();
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
private ReportChildrenData getReportChildrenData(TendencyReportParam param, Integer id,List<Integer> countList) {
|
||||
RecordSet rs = new RecordSet();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
List<String> data = new ArrayList<>();
|
||||
data.add(departmentComInfo.getDepartmentName(String.valueOf(id)));
|
||||
ArrayList<String> allSubDepartment = new ArrayList<>();
|
||||
departmentComInfo.getAllChildDeptByDepId(allSubDepartment, String.valueOf(id));
|
||||
allSubDepartment.add(String.valueOf(id));
|
||||
String allId = StringUtils.join(allSubDepartment, ",");
|
||||
|
||||
if (param.getYear() == null) {
|
||||
param.setYear(Year.now().getValue());
|
||||
}
|
||||
|
||||
String startDate = CommonDateUtil.getYearDayFirst(param.getYear());
|
||||
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(param.getYear());
|
||||
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("select count(1) as sum from hrmresource where status < 4 and companystartdate >= ? and companystartdate <= ? and departmentid in");
|
||||
st.append(" (").append(allId).append(")");
|
||||
if (StringUtils.isNotEmpty(param.getUseKind())) {
|
||||
st.append(" and usekind = ").append(param.getUseKind());
|
||||
}
|
||||
yearMonths.forEach(yearMonth -> {
|
||||
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
|
||||
rs.executeQuery(st.toString(),startDate,endMonth);
|
||||
if (rs.next()) {
|
||||
Integer sum = Util.getIntValue(rs.getString("sum"),0);
|
||||
data.add(String.valueOf(sum));
|
||||
countList.add(sum);
|
||||
}
|
||||
});
|
||||
|
||||
return ReportChildrenData.builder().data(data).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 单日期
|
||||
*/
|
||||
private int sumsByFirstDate(String firstDate,ArrayList compList) {
|
||||
RecordSet rs = new RecordSet();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("select count(1) as sums from hrmresource where status < 4 and companystartdate <= ?");
|
||||
if (CollectionUtils.isNotEmpty(compList)) {
|
||||
sb.append(" and subcompanyid1 in(").append(StringUtils.join(compList,",")).append(")");
|
||||
}
|
||||
rs.executeQuery(sb.toString(),firstDate);
|
||||
rs.next();
|
||||
return Util.getIntValue(rs.getString("sums"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 双日期
|
||||
*/
|
||||
private int sumsByTwoDate(String firstDate,String twoDate,ArrayList compList) {
|
||||
RecordSet rs = new RecordSet();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("select count(1) as sums from hrmresource where companystartdate >= ? and companystartdate <= ?");
|
||||
if (CollectionUtils.isNotEmpty(compList)) {
|
||||
sb.append(" and subcompanyid1 in(").append(StringUtils.join(compList,",")).append(")");
|
||||
}
|
||||
rs.executeQuery(sb.toString(),firstDate,twoDate);
|
||||
rs.next();
|
||||
return Util.getIntValue(rs.getString("sums"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 月份1
|
||||
*/
|
||||
private List<ReportColumns> getPTReportColumns() {
|
||||
List<ReportColumns> columns = new ArrayList<>();
|
||||
columns.add(ReportColumns.builder().title("月份").key("0").build());
|
||||
columns.add(ReportColumns.builder().title("1月").key("1").build());
|
||||
columns.add(ReportColumns.builder().title("2月").key("2").build());
|
||||
columns.add(ReportColumns.builder().title("3月").key("3").build());
|
||||
columns.add(ReportColumns.builder().title("4月").key("4").build());
|
||||
columns.add(ReportColumns.builder().title("5月").key("5").build());
|
||||
columns.add(ReportColumns.builder().title("6月").key("6").build());
|
||||
columns.add(ReportColumns.builder().title("7月").key("7").build());
|
||||
columns.add(ReportColumns.builder().title("8月").key("8").build());
|
||||
columns.add(ReportColumns.builder().title("9月").key("9").build());
|
||||
columns.add(ReportColumns.builder().title("10月").key("10").build());
|
||||
columns.add(ReportColumns.builder().title("11月").key("11").build());
|
||||
columns.add(ReportColumns.builder().title("12月").key("12").build());
|
||||
return columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 月份2
|
||||
*/
|
||||
private List<ReportColumns> getOJSReportColumns() {
|
||||
List<ReportColumns> columns = new ArrayList<>();
|
||||
columns.add(ReportColumns.builder().title("部门编号").key("-1").build());
|
||||
columns.add(ReportColumns.builder().title("部门名称").key("0").build());
|
||||
columns.add(ReportColumns.builder().title("一月").key("1").build());
|
||||
columns.add(ReportColumns.builder().title("二月").key("2").build());
|
||||
columns.add(ReportColumns.builder().title("三月").key("3").build());
|
||||
columns.add(ReportColumns.builder().title("四月").key("4").build());
|
||||
columns.add(ReportColumns.builder().title("五月").key("5").build());
|
||||
columns.add(ReportColumns.builder().title("六月").key("6").build());
|
||||
columns.add(ReportColumns.builder().title("七月").key("7").build());
|
||||
columns.add(ReportColumns.builder().title("八月").key("8").build());
|
||||
columns.add(ReportColumns.builder().title("九月").key("9").build());
|
||||
columns.add(ReportColumns.builder().title("十月").key("10").build());
|
||||
columns.add(ReportColumns.builder().title("十一月").key("11").build());
|
||||
columns.add(ReportColumns.builder().title("十二月").key("12").build());
|
||||
return columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 求和
|
||||
*/
|
||||
private List<Integer> summary(List<List<Integer>> countLists){
|
||||
return countLists.stream()
|
||||
.reduce((a, b) -> {
|
||||
List<Integer> sum = new ArrayList<>();
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
sum.add(a.get(i) + b.get(i));
|
||||
}
|
||||
return sum;
|
||||
})
|
||||
.orElse(new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 求比例
|
||||
*/
|
||||
private String calculateRate(List<String> addRate,int add,int sum) {
|
||||
String rate;
|
||||
if (sum != 0) {
|
||||
double rt = (double) add * 100 / sum;
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
||||
decimalFormat.setRoundingMode(java.math.RoundingMode.HALF_UP);
|
||||
rate = decimalFormat.format(rt) + "%";
|
||||
addRate.add(decimalFormat.format(rt));
|
||||
}else {
|
||||
rate = String.valueOf(add * 100) +"%";
|
||||
addRate.add(String.valueOf(add * 100));
|
||||
}
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.engine.thinktrans.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.thinktrans.entity.ReportChildrenData;
|
||||
import com.engine.thinktrans.entity.ReportColumns;
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import com.engine.thinktrans.entity.vo.TendencyReportVO;
|
||||
import com.engine.thinktrans.service.ReportCollectService;
|
||||
import com.engine.thinktrans.service.ReportExportService;
|
||||
import com.engine.thinktrans.util.ExcelUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/17 2:04 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ReportExportServiceImpl extends Service implements ReportExportService {
|
||||
|
||||
private ReportCollectService getReportCollectService(User user) {
|
||||
return ServiceUtil.getService(ReportCollectServiceImpl.class,user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook personTendencyExport(TendencyReportParam tendencyReportParam) {
|
||||
|
||||
TendencyReportVO personTendency = getReportCollectService(user).getPersonTendency(tendencyReportParam);
|
||||
|
||||
// 1.工作簿名称
|
||||
String sheetName = "年度人力趋势("+tendencyReportParam.getYear()+"年)";
|
||||
// 2.表头(后面动态获取)
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
|
||||
List<ReportColumns> columns = personTendency.getColumns();
|
||||
String[] header = columns.stream()
|
||||
.map(ReportColumns::getTitle)
|
||||
.toArray(String[]::new);
|
||||
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
List<ReportChildrenData> datas = personTendency.getDatas();
|
||||
List<List<Object>> rows = datas.stream()
|
||||
.map(data -> (List<Object>) new ArrayList<Object>(data.getData()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
excelSheetData.addAll(rows);
|
||||
return ExcelUtil.genWorkbook(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook onJobStatisticsExport() {
|
||||
TendencyReportVO personTendency = getReportCollectService(user).getOnJobStatistics();
|
||||
|
||||
// 1.工作簿名称
|
||||
String sheetName = "实时在职人数";
|
||||
// 2.表头(后面动态获取)
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
|
||||
List<ReportColumns> columns = personTendency.getColumns();
|
||||
String[] header = columns.stream()
|
||||
.map(ReportColumns::getTitle)
|
||||
.toArray(String[]::new);
|
||||
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
List<ReportChildrenData> datas = personTendency.getDatas();
|
||||
List<List<Object>> rows = datas.stream()
|
||||
.map(data -> (List<Object>) new ArrayList<Object>(data.getData()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
excelSheetData.addAll(rows);
|
||||
return ExcelUtil.genWorkbook(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook personnelSizeExport(PersonnelSizeTopParam param) {
|
||||
TendencyReportVO personTendency = getReportCollectService(user).getPersonnelSize(param);
|
||||
|
||||
// 1.工作簿名称
|
||||
String sheetName = "公司人员规模分析";
|
||||
// 2.表头(后面动态获取)
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
|
||||
List<ReportColumns> columns = personTendency.getColumns();
|
||||
String[] header = columns.stream()
|
||||
.map(ReportColumns::getTitle)
|
||||
.toArray(String[]::new);
|
||||
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
List<ReportChildrenData> datas = personTendency.getDatas();
|
||||
List<List<Object>> rows = datas.stream()
|
||||
.map(data -> (List<Object>) new ArrayList<Object>(data.getData()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
excelSheetData.addAll(rows);
|
||||
return ExcelUtil.genWorkbook(excelSheetData, sheetName);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.engine.thinktrans.util;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/11/17 2:59 PM
|
||||
*/
|
||||
public class ExcelUtil {
|
||||
|
||||
public static XSSFWorkbook genWorkbook(List<List<Object>> rowList, String sheetName) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 14);
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setFont(font);
|
||||
cellStyle.setWrapText(true);
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
//设置标题
|
||||
Row titleRow = sheet.createRow(0);
|
||||
Cell titleCell = titleRow.createCell(0);
|
||||
titleCell.setCellValue(sheetName);
|
||||
// 设置标题样式
|
||||
CellStyle titleStyle = workbook.createCellStyle();
|
||||
Font titleFont1 = workbook.createFont();
|
||||
titleFont1.setFontHeightInPoints((short) 18);
|
||||
titleFont1.setBold(true);
|
||||
titleFont1.setFontName("宋体");
|
||||
titleStyle.setFont(titleFont1);
|
||||
titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
titleCell.setCellStyle(titleStyle);
|
||||
|
||||
if ("实时在职人数".equals(sheetName)){
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 13));
|
||||
}else if ("公司人员规模分析".equals(sheetName)) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 6));
|
||||
}
|
||||
else {
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 12));
|
||||
}
|
||||
|
||||
|
||||
// 设置表头样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setFontName("宋体");
|
||||
titleFont.setBold(true);
|
||||
titleFont.setFontHeightInPoints((short) 14);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.WHITE1.getIndex());
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
|
||||
|
||||
|
||||
// 自适应宽度
|
||||
//sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(18);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex+2);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(o == null ? "" : o.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.engine.thinktrans.util;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 2:37 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ExceptionUtil {
|
||||
public static String getRealMessage(Throwable e) {
|
||||
while (e != null) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause == null) {
|
||||
return e.getMessage();
|
||||
}
|
||||
e = cause;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.engine.thinktrans.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 5:58 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class OperateUtil {
|
||||
|
||||
public static List<String> sumLists(List<String>... lists) {
|
||||
return Arrays.stream(lists)
|
||||
.flatMap(List::stream)
|
||||
.skip(1)
|
||||
.map(OperateUtil::sumDigits)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static String sumDigits(String str) {
|
||||
int sum = IntStream.range(0, str.length())
|
||||
.map(i -> str.charAt(i) - '0')
|
||||
.sum();
|
||||
return String.valueOf(sum);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.engine.thinktrans.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import com.engine.thinktrans.entity.vo.TendencyReportVO;
|
||||
import com.engine.thinktrans.service.ReportCollectService;
|
||||
import com.engine.thinktrans.service.impl.ReportCollectServiceImpl;
|
||||
import com.engine.thinktrans.util.ResponseResult;
|
||||
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.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/16 10:42 AM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ReportCollectController {
|
||||
|
||||
private ReportCollectService getReportCollectService(User user) {
|
||||
return ServiceUtil.getService(ReportCollectServiceImpl.class,user);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/personTendency")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getPersonTendency(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("deptIds") String deptIds, @QueryParam("year") Integer year, @QueryParam("useKind") String useKind) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
TendencyReportParam tendencyReportParam = TendencyReportParam.builder().deptIds(deptIds).year(year).useKind(useKind).build();
|
||||
return new ResponseResult<TendencyReportParam, TendencyReportVO>(user).run(getReportCollectService(user) :: getPersonTendency,tendencyReportParam);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/onJobStatistics")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getOnJobStatistics(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<String, TendencyReportVO>(user).run(getReportCollectService(user) :: getOnJobStatistics);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/personnelSize")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getPersonnelSize(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam("year") Integer year,@QueryParam("company") Integer company) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
PersonnelSizeTopParam build = PersonnelSizeTopParam.builder().year(year).company(company).build();
|
||||
return new ResponseResult<PersonnelSizeTopParam, TendencyReportVO>(user).run(getReportCollectService(user) :: getPersonnelSize,build);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/top")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getTop(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam("year") Integer year,@QueryParam("company") Integer company) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
PersonnelSizeTopParam build = PersonnelSizeTopParam.builder().year(year).company(company).build();
|
||||
return new ResponseResult<PersonnelSizeTopParam, Map<String,Object>>(user).run(getReportCollectService(user) :: getTop,build);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.engine.thinktrans.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.thinktrans.entity.param.PersonnelSizeTopParam;
|
||||
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||
import com.engine.thinktrans.service.ReportExportService;
|
||||
import com.engine.thinktrans.service.impl.ReportExportServiceImpl;
|
||||
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.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/17 1:57 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ReportExportController {
|
||||
|
||||
private ReportExportService getReportExportService(User user) {
|
||||
return ServiceUtil.getService(ReportExportServiceImpl.class,user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/personTendency/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response personTendencyExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("deptIds") String deptIds, @QueryParam("year") Integer year, @QueryParam("useKind") String useKind) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
TendencyReportParam tendencyReportParam = TendencyReportParam.builder().deptIds(deptIds).year(year).useKind(useKind).build();
|
||||
XSSFWorkbook workbook = getReportExportService(user).personTendencyExport(tendencyReportParam);
|
||||
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();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/onJobStatistics/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response onJobStatisticsExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getReportExportService(user).onJobStatisticsExport();
|
||||
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();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/personnelSize/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response personnelSizeExport(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam("year") Integer year,@QueryParam("company") Integer company) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
PersonnelSizeTopParam build = PersonnelSizeTopParam.builder().year(year).company(company).build();
|
||||
XSSFWorkbook workbook = getReportExportService(user).personnelSizeExport(build);
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package weaver.interfaces.thinktrans.cron;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.thinktrans.service.CubeRecordDataService;
|
||||
import com.engine.thinktrans.service.impl.CubeRecordDataServiceImpl;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.time.Year;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/11/20 5:56 PM
|
||||
* @Description: 离职率
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class DimissionCronJob extends BaseCronJob {
|
||||
|
||||
private CubeRecordDataService getCubeRecordDataService(User user) {
|
||||
return ServiceUtil.getService(CubeRecordDataServiceImpl.class,user);
|
||||
}
|
||||
|
||||
private String year;
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
User user = new User();
|
||||
user.setUid(1);
|
||||
if (year == null) {
|
||||
year = String.valueOf(Year.now().getValue());
|
||||
}
|
||||
getCubeRecordDataService(user).dimissionRate(Integer.valueOf(year));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue