铭沣科技统计分析门户接口
parent
8f69331512
commit
2ccfed4f0c
@ -1,10 +1,14 @@
|
|||||||
package com.api.matfron.web;
|
package com.api.matfron.web;
|
||||||
|
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author liang.cheng
|
* @Author liang.cheng
|
||||||
* @Date 2023/9/26 5:49 PM
|
* @Date 2023/9/26 5:49 PM
|
||||||
* @Description: 铭沣科技统计分析门户接口
|
* @Description: 铭沣科技统计分析门户接口
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
public class StatisticsPortalAction {
|
|
||||||
|
@Path("/matfron/portal/element")
|
||||||
|
public class StatisticsPortalAction extends com.engine.matfron.web.StatisticsPortalAction {
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.engine.matfron.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2023/9/27 5:30 PM
|
||||||
|
* @Description: echarts option
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class OptionVO {
|
||||||
|
|
||||||
|
private String titleText;
|
||||||
|
|
||||||
|
private TreeSet<String> xData;
|
||||||
|
|
||||||
|
private Integer yMin;
|
||||||
|
|
||||||
|
private Integer yMax;
|
||||||
|
|
||||||
|
private Integer yInterval;
|
||||||
|
|
||||||
|
private TreeSet<String> yData;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.engine.matfron.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2023/9/27 3:45 PM
|
||||||
|
* @Description:
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PortalTopVO<T> {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private T count;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.engine.matfron.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2023/2/21
|
||||||
|
* @Version V1.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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,34 @@
|
|||||||
package com.engine.matfron.service;
|
package com.engine.matfron.service;
|
||||||
|
|
||||||
|
import com.engine.matfron.entity.OptionVO;
|
||||||
|
import com.engine.matfron.entity.PortalTopVO;
|
||||||
|
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author liang.cheng
|
* @Author liang.cheng
|
||||||
* @Date 2023/9/26 5:51 PM
|
* @Date 2023/9/26 5:51 PM
|
||||||
* @Description: TODO
|
* @Description: 统计分析门户
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
public interface StatisticsPortalService {
|
public interface StatisticsPortalService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 门户顶部
|
||||||
|
* @Author: liang.cheng
|
||||||
|
* @Date: 2023/9/27 4:02 PM
|
||||||
|
* @param: []
|
||||||
|
* @return: com.engine.matfron.entity.PortalTopVO
|
||||||
|
*/
|
||||||
|
TreeSet<PortalTopVO> getPortalTop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 一级部门人数统计
|
||||||
|
* @Author: liang.cheng
|
||||||
|
* @Date: 2023/9/27 5:40 PM
|
||||||
|
* @param: []
|
||||||
|
* @return: com.engine.matfron.entity.OptionVO
|
||||||
|
*/
|
||||||
|
OptionVO getPortalDepartment();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,175 @@
|
|||||||
|
package com.engine.matfron.util;
|
||||||
|
|
||||||
|
import com.engine.matfron.exception.CustomizeRunTimeException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @description:
|
||||||
|
* @Date 2022/4/26
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public abstract class CommonAssert {
|
||||||
|
/**
|
||||||
|
* 判断入参不为null
|
||||||
|
*
|
||||||
|
* @param object 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notNull(Object object, String message) {
|
||||||
|
if (object == null) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断入参不为null
|
||||||
|
*
|
||||||
|
* @param string 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notNull(String string, String message) {
|
||||||
|
if (StringUtils.isBlank(string)) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断多个入参不为null
|
||||||
|
*
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
* @param objects 待检查参数
|
||||||
|
*/
|
||||||
|
public static void notNull(String message, Object... objects) {
|
||||||
|
for (Object obj : objects) {
|
||||||
|
if (obj == null) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断入参为null
|
||||||
|
*
|
||||||
|
* @param object 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void isNull(Object object, String message) {
|
||||||
|
if (object != null) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断集合是否为空
|
||||||
|
*
|
||||||
|
* @param collection 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void isEmpty(Collection<?> collection, String message) {
|
||||||
|
if (!CollectionUtils.isEmpty(collection)) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断集合不为空
|
||||||
|
*
|
||||||
|
* @param collection 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notEmpty(Collection<?> collection, String message) {
|
||||||
|
if (CollectionUtils.isEmpty(collection)) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数组是否为空
|
||||||
|
*
|
||||||
|
* @param arr 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notEmpty(Object[] arr, String message) {
|
||||||
|
if (ObjectUtils.isEmpty(arr)) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断map是否为空
|
||||||
|
*
|
||||||
|
* @param map 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notEmpty(Map<?, ?> map, String message) {
|
||||||
|
if (CollectionUtils.isEmpty(map)) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数组元素是否为空
|
||||||
|
*
|
||||||
|
* @param arr 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void notNullElement(Object[] arr, String message) {
|
||||||
|
if (arr != null) {
|
||||||
|
for (Object obj : arr) {
|
||||||
|
if (obj == null) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断boolean
|
||||||
|
*
|
||||||
|
* @param expression 待检查参数
|
||||||
|
* @param message 检查失败返回的异常信息
|
||||||
|
*/
|
||||||
|
public static void isTrue(boolean expression, String message) {
|
||||||
|
if (!expression) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isFalse(boolean expression, String message) {
|
||||||
|
if (expression) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isBlank(CharSequence cs, String message) {
|
||||||
|
int strLen;
|
||||||
|
if (cs != null && (strLen = cs.length()) != 0) {
|
||||||
|
for (int i = 0; i < strLen; ++i) {
|
||||||
|
if (!Character.isWhitespace(cs.charAt(i))) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notBlank(CharSequence cs, String message) {
|
||||||
|
int strLen;
|
||||||
|
if (cs != null && (strLen = cs.length()) != 0) {
|
||||||
|
for (int i = 0; i < strLen; ++i) {
|
||||||
|
if (Character.isWhitespace(cs.charAt(i))) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cs == null || cs.length() == 0) {
|
||||||
|
throw new CustomizeRunTimeException(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.engine.matfron.util;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2023/9/27 4:52 PM
|
||||||
|
* @Description: TODO
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class CommonUtils {
|
||||||
|
|
||||||
|
public static LocalDate parseLocalDate(String dateString) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
return LocalDate.parse(dateString, formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int calculateAge(LocalDate birthday) {
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
return Period.between(birthday, currentDate).getYears();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.engine.matfron.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2023/2/21
|
||||||
|
* @Version V1.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 "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,51 @@
|
|||||||
package com.engine.matfron.web;
|
package com.engine.matfron.web;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.matfron.entity.OptionVO;
|
||||||
|
import com.engine.matfron.entity.PortalTopVO;
|
||||||
|
import com.engine.matfron.service.StatisticsPortalService;
|
||||||
|
import com.engine.matfron.service.impl.StatisticsPortalServiceImpl;
|
||||||
|
import com.engine.matfron.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.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author liang.cheng
|
* @Author liang.cheng
|
||||||
* @Date 2023/9/26 5:51 PM
|
* @Date 2023/9/26 5:51 PM
|
||||||
* @Description: TODO
|
* @Description:
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
*/
|
*/
|
||||||
public class StatisticsPortalAction {
|
public class StatisticsPortalAction {
|
||||||
|
|
||||||
|
private StatisticsPortalService getCommonDutyService(User user) {
|
||||||
|
return ServiceUtil.getService(StatisticsPortalServiceImpl.class,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/statistics/top")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<String, TreeSet<PortalTopVO>>(user).run(getCommonDutyService(user) :: getPortalTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/statistics/department")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String getPortalDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<String, OptionVO>(user).run(getCommonDutyService(user) :: getPortalDepartment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue