铭沣科技统计分析门户接口

统计分析门户标准
Chengliang 2 years ago
parent 2ccfed4f0c
commit 652a96125e

@ -0,0 +1,24 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/28 10:06 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentParam {
private Integer departmentId;
private Integer count;
}

@ -30,7 +30,13 @@ public class OptionVO {
private Integer yInterval;
private TreeSet<String> yData;
private TreeSet<Integer> yData;
private TreeSet<String> legendDataFirst;
private TreeSet<String> legendDataTwo;
private TreeSet<SeriesParam> seriesData;
}

@ -0,0 +1,28 @@
package com.engine.matfron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/28 2:02 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SeriesParam {
private Integer value;
private String name;
private String color;
}

@ -31,4 +31,16 @@ public interface StatisticsPortalService {
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getPortalDepartment();
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/28 11:23 AM
* @param: []
* @return: com.engine.matfron.entity.OptionVO
*/
OptionVO getPortalSubCompany();
OptionVO getPortalEthnic();
}

@ -1,25 +1,26 @@
package com.engine.matfron.service.impl;
import com.engine.core.impl.Service;
import com.engine.matfron.entity.DepartmentParam;
import com.engine.matfron.entity.OptionVO;
import com.engine.matfron.entity.PortalTopVO;
import com.engine.matfron.entity.SeriesParam;
import com.engine.matfron.service.StatisticsPortalService;
import com.engine.matfron.util.CommonDateUtil;
import com.engine.matfron.util.CommonUtils;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import java.util.*;
/**
* @Author liang.cheng
* @Date 2023/9/26 5:52 PM
* @Description: TODO
* @Description:
* @Version 1.0
*/
public class StatisticsPortalServiceImpl extends Service implements StatisticsPortalService {
@ -62,9 +63,88 @@ public class StatisticsPortalServiceImpl extends Service implements StatisticsPo
@Override
public OptionVO getPortalDepartment() {
RecordSet rs = new RecordSet();
TreeSet<String> xData = new TreeSet<>();
TreeSet<Integer> yData = new TreeSet<>();
List<Integer> ids = new ArrayList<>();
rs.executeQuery("select id,departmentname from hrmdepartment where supdepid = 0");
while (rs.next()) {
xData.add(Util.null2String(rs.getString("departmentname")));
ids.add(Util.getIntValue(rs.getString("id")));
}
List<DepartmentParam> deptList = new ArrayList<>();
rs.executeQuery("select departmentid,count(1) AS count from hrmresource where status < 4 and departmentid in ("+StringUtils.join(ids,",")+") group by departmentid");
while (rs.next()) {
deptList.add(DepartmentParam.builder().departmentId(Util.getIntValue(rs.getString("departmentid"))).count(Util.getIntValue(rs.getString("count"))).build());
}
ids.forEach(item -> deptList.forEach(dept -> {
if (dept.getDepartmentId().equals(item)) {
yData.add(dept.getCount());
}else {
yData.add(0);
}
}));
int max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 5);
return OptionVO.builder()
.titleText("一级部门人数统计")
.xData(xData)
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.build();
}
@Override
public OptionVO getPortalSubCompany() {
RecordSet rs = new RecordSet();
TreeSet<Integer> yData = new TreeSet<>();
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
yearMonths.forEach(yearMonth -> {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth));
rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate >= ? and companystartdate <= ",startMonth,endMonth);
rs.next();
Integer sum = Util.getIntValue(rs.getString("sum"),0);
yData.add(sum);
});
int max = Collections.max(yData);
int ceil =(int) Math.ceil((double) max / 5);
ceil = CommonUtils.roundUpToNearestTen(ceil);
int roundedMax = CommonUtils.roundedMax(ceil, 5);
return OptionVO.builder()
.titleText("各月份分部总人数")
.yMin(0)
.yMax(roundedMax)
.yInterval(ceil)
.yData(yData)
.build();
}
@Override
public OptionVO getPortalEthnic() {
RecordSet rs = new RecordSet();
List<String> colorList = Arrays.asList("#6e94f3","#83d8ae","#697695","#8ac9e9");
TreeSet<SeriesParam> seriesData = new TreeSet<>();
rs.executeQuery("select distinct folk,count(1) as count from hrmresource where status < 4 \n" +
" and folk is not null group by folk");
while (rs.next()) {
seriesData.add(SeriesParam.builder().build());
}
return null;
}
}

@ -8,7 +8,9 @@ import java.time.LocalDate;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
@ -80,4 +82,13 @@ public class CommonDateUtil {
}
}
public static List<YearMonth> getYearMonths(LocalDate date) {
List<YearMonth> yearMonths = new ArrayList<>();
for (int month = 1; month <= 12; month++) {
LocalDate firstDayOfMonth = date.withMonth(month);
yearMonths.add(YearMonth.from(firstDayOfMonth));
}
return yearMonths;
}
}

@ -21,4 +21,14 @@ public class CommonUtils {
LocalDate currentDate = LocalDate.now();
return Period.between(birthday, currentDate).getYears();
}
public static int roundUpToNearestTen(int num) {
return (num + 9) / 10 * 10;
}
public static int roundedMax(int ceil,int copies){
return ceil * copies;
}
}

@ -47,5 +47,21 @@ public class StatisticsPortalAction {
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalDepartment);
}
@GET
@Path("/statistics/subcompany")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalSubCompany(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalSubCompany);
}
@GET
@Path("/statistics/ethnic")
@Produces(MediaType.APPLICATION_JSON)
public String getPortalEthnic(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalEthnic);
}
}

@ -2,8 +2,9 @@ package test;
import com.engine.matfron.util.CommonDateUtil;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.Date;
import java.util.*;
/**
* @Author weaver_cl
@ -14,8 +15,7 @@ import java.util.Date;
public class MainTest {
public static void main(String[] args) {
String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now()));
List<YearMonth> yearMonths = CommonDateUtil.getYearMonths(LocalDate.now());
yearMonths.forEach(yearMonth -> System.out.println(yearMonth));
}
}

Loading…
Cancel
Save