新创元报表 人力年趋势
parent
59e17ca9f5
commit
f4a31f20d9
@ -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 {
|
||||||
|
}
|
@ -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,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,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,22 @@
|
|||||||
|
package com.engine.thinktrans.service;
|
||||||
|
|
||||||
|
import com.engine.thinktrans.entity.param.TendencyReportParam;
|
||||||
|
import com.engine.thinktrans.entity.vo.TendencyReportVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
package com.engine.thinktrans.service.impl;
|
||||||
|
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.thinktrans.entity.ReportChildrenData;
|
||||||
|
import com.engine.thinktrans.entity.ReportColumns;
|
||||||
|
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.engine.thinktrans.util.OperateUtil;
|
||||||
|
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.Year;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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 10:43 AM
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class ReportCollectServiceImpl extends Service implements ReportCollectService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TendencyReportVO getPersonTendency(TendencyReportParam tendencyReportParam) {
|
||||||
|
|
||||||
|
List<ReportColumns> columns = getReportColumns();
|
||||||
|
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)");
|
||||||
|
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 = 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<>());
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<ReportColumns> getReportColumns() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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,43 @@
|
|||||||
|
package com.engine.thinktrans.web;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue