物料管理-编辑/新增出入库和物料信息
This commit is contained in:
parent
75527b3dbb
commit
72145d1e9b
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -16,6 +17,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class QueryGenerator {
|
||||
@ -76,7 +78,11 @@ public class QueryGenerator {
|
||||
* @return
|
||||
*/
|
||||
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap, List<String> excludeFields) {
|
||||
return initQueryWrapper(searchObj, parameterMap, excludeFields, null);
|
||||
return initQueryWrapper(searchObj, parameterMap, excludeFields, null, false);
|
||||
}
|
||||
|
||||
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap, List<String> excludeFields, List<String> likeFields) {
|
||||
return initQueryWrapper(searchObj, parameterMap, excludeFields, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,12 +92,13 @@ public class QueryGenerator {
|
||||
* @param parameterMap
|
||||
* @param excludeFields 排除属性(eg:ReflectionUtil.getFieldNameList)
|
||||
* @param likeFields like属性
|
||||
* @param enableAlias 开启likeFields的别名
|
||||
* @return
|
||||
*/
|
||||
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap, List<String> excludeFields, List<String> likeFields) {
|
||||
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap, List<String> excludeFields, List<String> likeFields, boolean enableAlias) {
|
||||
long start = System.currentTimeMillis();
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
|
||||
installMplus(queryWrapper, searchObj, parameterMap, excludeFields, likeFields);
|
||||
installMplus(queryWrapper, searchObj, parameterMap, excludeFields, likeFields, enableAlias);
|
||||
log.info("---查询条件构造器初始化完成,耗时:" + (System.currentTimeMillis() - start) + "毫秒----");
|
||||
return queryWrapper;
|
||||
}
|
||||
@ -105,10 +112,10 @@ public class QueryGenerator {
|
||||
* @param excludeFields 排除属性
|
||||
*/
|
||||
public static void installMplus(QueryWrapper<?> queryWrapper, Object searchObj, Map<String, String[]> parameterMap, List<String> excludeFields) {
|
||||
installMplus(queryWrapper, searchObj, parameterMap, excludeFields, null);
|
||||
installMplus(queryWrapper, searchObj, parameterMap, excludeFields, null, false);
|
||||
}
|
||||
|
||||
public static void installMplus(QueryWrapper<?> queryWrapper, Object searchObj, Map<String, String[]> parameterMap, List<String> excludeFields, List<String> likeFields) {
|
||||
public static void installMplus(QueryWrapper<?> queryWrapper, Object searchObj, Map<String, String[]> parameterMap, List<String> excludeFields, List<String> likeFields, boolean enableAlias) {
|
||||
|
||||
/*
|
||||
* 注意:权限查询由前端配置数据规则 当一个人有多个所属部门时候 可以在规则配置包含条件 orgCode 包含 #{sys_org_code}
|
||||
@ -119,6 +126,14 @@ public class QueryGenerator {
|
||||
//区间条件组装 模糊查询 高级查询组装 简单排序 权限查询
|
||||
PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(searchObj);
|
||||
|
||||
Map<String, String> fieldNameAndAliasMap = null;
|
||||
if (likeFields != null) {
|
||||
if (enableAlias) {
|
||||
fieldNameAndAliasMap = likeFields.stream().collect(Collectors.toMap(s -> StringUtils.substringAfter(s, "."), s -> StringUtils.substringBefore(s, ".")));
|
||||
} else {
|
||||
fieldNameAndAliasMap = likeFields.stream().collect(Collectors.toMap(s -> s, s -> s));
|
||||
}
|
||||
}
|
||||
|
||||
String name, type;
|
||||
for (int i = 0; i < origDescriptors.length; i++) {
|
||||
@ -131,9 +146,9 @@ public class QueryGenerator {
|
||||
}
|
||||
|
||||
//模糊查询
|
||||
if (likeFields != null && likeFields.contains(name)) {
|
||||
if (fieldNameAndAliasMap != null && fieldNameAndAliasMap.get(name) != null) {
|
||||
Object v = PropertyUtils.getSimpleProperty(searchObj, name);
|
||||
queryWrapper.like(v != null, StrUtil.toUnderlineCase(name), v);
|
||||
queryWrapper.like(v != null, enableAlias ? fieldNameAndAliasMap.get(name) + "." + StrUtil.toUnderlineCase(name) : StrUtil.toUnderlineCase(name), v);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -443,5 +458,4 @@ public class QueryGenerator {
|
||||
|| "sort".equals(name) || "order".equals(name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,18 +4,15 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import com.zhgd.xmgl.modules.gt.service.IGtMaterialInOutWarehouseService;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
@ -67,20 +64,7 @@ public class GtMaterialInOutWarehouseController {
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<GtMaterialInOutWarehouse>> result = new Result<IPage<GtMaterialInOutWarehouse>>();
|
||||
QueryWrapper<GtMaterialInOutWarehouse> queryWrapper = QueryGenerator.initQueryWrapper(gtMaterialInOutWarehouse, req.getParameterMap()
|
||||
, null, ReflectionUtil.getFieldNameList(GtMaterialInOutWarehouse::getNumber, GtMaterialInOutWarehouse::getCategory, GtMaterialInOutWarehouse::getVendor,
|
||||
GtMaterialInOutWarehouse::getLotNumber, GtMaterialInOutWarehouse::getWarehouse, GtMaterialInOutWarehouse::getDepartment, GtMaterialInOutWarehouse::getHandler
|
||||
, GtMaterialInOutWarehouse::getCustomer));
|
||||
queryWrapper.lambda()
|
||||
.ge(gtMaterialInOutWarehouse.getCreateTime() != null, GtMaterialInOutWarehouse::getUpdateTime, gtMaterialInOutWarehouse.getCreateTime())
|
||||
.le(gtMaterialInOutWarehouse.getEndTime() != null, GtMaterialInOutWarehouse::getUpdateTime, gtMaterialInOutWarehouse.getEndTime())
|
||||
.orderByDesc(GtMaterialInOutWarehouse::getId);
|
||||
Page<GtMaterialInOutWarehouse> page = new Page<GtMaterialInOutWarehouse>(pageNo, pageSize);
|
||||
IPage<GtMaterialInOutWarehouse> pageList = gtMaterialInOutWarehouseService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
return gtMaterialInOutWarehouseService.queryPageList(gtMaterialInOutWarehouse, pageNo, pageSize, req);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,6 +127,30 @@ public class GtMaterialInOutWarehouseController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加出入库和物料信息
|
||||
*
|
||||
* @param gtMaterialInOutWarehouse
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 添加出入库和物料信息", notes = "添加出入库和物料信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/addWithMaterial")
|
||||
public Result<GtMaterialInOutWarehouse> addWithMaterial(@RequestBody GtMaterialInOutWarehouse gtMaterialInOutWarehouse) {
|
||||
return gtMaterialInOutWarehouseService.addWithMaterial(gtMaterialInOutWarehouse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑出入库和物料信息
|
||||
*
|
||||
* @param gtMaterialInOutWarehouse
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 编辑出入库和物料信息", notes = "编辑出入库和物料信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/editWithMaterial")
|
||||
public Result<GtMaterialInOutWarehouse> editWithMaterial(@RequestBody GtMaterialInOutWarehouse gtMaterialInOutWarehouse) {
|
||||
return gtMaterialInOutWarehouseService.editWithMaterial(gtMaterialInOutWarehouse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
|
||||
@ -2,6 +2,8 @@ package com.zhgd.xmgl.modules.gt.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -108,10 +110,21 @@ public class GtMaterialInOutWarehouse implements Serializable {
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Date endTime;
|
||||
@ApiModelProperty(value = "助查码")
|
||||
@TableField(exist = false)
|
||||
private java.lang.String lookupCode;
|
||||
@ApiModelProperty(value = "货号")
|
||||
@TableField(exist = false)
|
||||
private java.lang.String stuffNumber;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "物料列表")
|
||||
private List<GtMaterialPointCheckIntoWarehouseDetail> materialList;
|
||||
}
|
||||
|
||||
@ -1,16 +1,22 @@
|
||||
package com.zhgd.xmgl.modules.gt.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Description: 出入库
|
||||
* @author: pds
|
||||
* @date: 2023-04-18
|
||||
* @date: 2023-04-18
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface GtMaterialInOutWarehouseMapper extends BaseMapper<GtMaterialInOutWarehouse> {
|
||||
|
||||
IPage<GtMaterialInOutWarehouse> queryPageList(Page<GtMaterialInOutWarehouse> page, @Param(Constants.WRAPPER) QueryWrapper<GtMaterialInOutWarehouse> queryWrapper);
|
||||
}
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhgd.xmgl.modules.gt.mapper.GtMaterialInOutWarehouseMapper">
|
||||
|
||||
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse">
|
||||
SELECT
|
||||
DISTINCT io.*
|
||||
FROM
|
||||
`gt_material_in_out_warehouse` io
|
||||
LEFT JOIN gt_material_point_check_into_warehouse_detail d ON d.gt_material_in_out_warehouse_id = io.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -1,14 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.gt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Description: 出入库
|
||||
* @author: pds
|
||||
* @date: 2023-04-18
|
||||
* @date: 2023-04-18
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface IGtMaterialInOutWarehouseService extends IService<GtMaterialInOutWarehouse> {
|
||||
|
||||
Result<IPage<GtMaterialInOutWarehouse>> queryPageList(GtMaterialInOutWarehouse gtMaterialInOutWarehouse, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
|
||||
Result<GtMaterialInOutWarehouse> addWithMaterial(GtMaterialInOutWarehouse gtMaterialInOutWarehouse);
|
||||
|
||||
Result<GtMaterialInOutWarehouse> editWithMaterial(GtMaterialInOutWarehouse gtMaterialInOutWarehouse);
|
||||
}
|
||||
|
||||
@ -1,19 +1,99 @@
|
||||
package com.zhgd.xmgl.modules.gt.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialPointCheckIntoWarehouseDetail;
|
||||
import com.zhgd.xmgl.modules.gt.mapper.GtMaterialInOutWarehouseMapper;
|
||||
import com.zhgd.xmgl.modules.gt.service.IGtMaterialInOutWarehouseService;
|
||||
import com.zhgd.xmgl.modules.gt.service.IGtMaterialPointCheckIntoWarehouseDetailService;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 出入库
|
||||
* @author: pds
|
||||
* @date: 2023-04-18
|
||||
* @date: 2023-04-18
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl<GtMaterialInOutWarehouseMapper, GtMaterialInOutWarehouse> implements IGtMaterialInOutWarehouseService {
|
||||
@Autowired
|
||||
IGtMaterialPointCheckIntoWarehouseDetailService materialPointCheckIntoWarehouseDetailService;
|
||||
@Autowired
|
||||
GtMaterialInOutWarehouseMapper gtMaterialInOutWarehouseMapper;
|
||||
|
||||
@Override
|
||||
public Result<IPage<GtMaterialInOutWarehouse>> queryPageList(GtMaterialInOutWarehouse gtMaterialInOutWarehouse, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<GtMaterialInOutWarehouse>> result = new Result<IPage<GtMaterialInOutWarehouse>>();
|
||||
List<String> fieldNameList = ReflectionUtil.getFieldNameList("io", GtMaterialInOutWarehouse::getNumber, GtMaterialInOutWarehouse::getCategory, GtMaterialInOutWarehouse::getVendor,
|
||||
GtMaterialInOutWarehouse::getLotNumber, GtMaterialInOutWarehouse::getWarehouse, GtMaterialInOutWarehouse::getDepartment, GtMaterialInOutWarehouse::getHandler
|
||||
, GtMaterialInOutWarehouse::getCustomer);
|
||||
fieldNameList.addAll(ReflectionUtil.getFieldNameList("d", GtMaterialInOutWarehouse::getLookupCode, GtMaterialInOutWarehouse::getStuffNumber));
|
||||
QueryWrapper<GtMaterialInOutWarehouse> queryWrapper = QueryGenerator.initQueryWrapper(gtMaterialInOutWarehouse, req.getParameterMap()
|
||||
, null, fieldNameList, true);
|
||||
|
||||
queryWrapper.lambda()
|
||||
.ge(gtMaterialInOutWarehouse.getStartTime() != null, GtMaterialInOutWarehouse::getUpdateTime, gtMaterialInOutWarehouse.getStartTime())
|
||||
.le(gtMaterialInOutWarehouse.getEndTime() != null, GtMaterialInOutWarehouse::getUpdateTime, gtMaterialInOutWarehouse.getEndTime())
|
||||
.orderByDesc(GtMaterialInOutWarehouse::getId);
|
||||
Page<GtMaterialInOutWarehouse> page = new Page<GtMaterialInOutWarehouse>(pageNo, pageSize);
|
||||
IPage<GtMaterialInOutWarehouse> pageList = gtMaterialInOutWarehouseMapper.queryPageList(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<GtMaterialInOutWarehouse> addWithMaterial(GtMaterialInOutWarehouse gtMaterialInOutWarehouse) {
|
||||
Result<GtMaterialInOutWarehouse> result = new Result<GtMaterialInOutWarehouse>();
|
||||
try {
|
||||
save(gtMaterialInOutWarehouse);
|
||||
List<GtMaterialPointCheckIntoWarehouseDetail> materialList = gtMaterialInOutWarehouse.getMaterialList();
|
||||
materialList.stream().forEach(o -> o.setGtMaterialInOutWarehouseId(gtMaterialInOutWarehouse.getId()));
|
||||
if (CollUtil.isNotEmpty(materialList)) {
|
||||
materialPointCheckIntoWarehouseDetailService.saveBatch(materialList);
|
||||
}
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<GtMaterialInOutWarehouse> editWithMaterial(GtMaterialInOutWarehouse gtMaterialInOutWarehouse) {
|
||||
Result<GtMaterialInOutWarehouse> result = new Result<GtMaterialInOutWarehouse>();
|
||||
GtMaterialInOutWarehouse gtMaterialInOutWarehouseEntity = getById(gtMaterialInOutWarehouse.getId());
|
||||
if (gtMaterialInOutWarehouseEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
updateById(gtMaterialInOutWarehouse);
|
||||
materialPointCheckIntoWarehouseDetailService.remove(new LambdaQueryWrapper<GtMaterialPointCheckIntoWarehouseDetail>()
|
||||
.eq(GtMaterialPointCheckIntoWarehouseDetail::getGtMaterialInOutWarehouseId, gtMaterialInOutWarehouse.getId()));
|
||||
List<GtMaterialPointCheckIntoWarehouseDetail> materialList = gtMaterialInOutWarehouse.getMaterialList();
|
||||
if (CollUtil.isNotEmpty(materialList)) {
|
||||
materialPointCheckIntoWarehouseDetailService.saveBatch(materialList);
|
||||
}
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@ -13,7 +8,6 @@ import java.beans.Introspector;
|
||||
import java.lang.invoke.SerializedLambda;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -23,30 +17,16 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 方法引用获取属性名工具类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class ReflectionUtil {
|
||||
private String alias;
|
||||
private List<SerializableFunction<T, R>> functions;
|
||||
|
||||
private static Map<SerializableFunction<?, ?>, Field> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public static <T, R> List<String> getFieldNameList(SerializableFunction<T, R>... functions) {
|
||||
return Arrays.stream(functions).map(ReflectionUtil::getFieldName).collect(Collectors.toList());
|
||||
public static <T, R> List<String> getFieldNameList(String alias, SerializableFunction<T, R>... functions) {
|
||||
return Arrays.stream(functions).map(function -> alias + "." + getFieldName(function)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T, R> List<String> getFieldNameListWithAlias(List<ReflectionUtil> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<String> l = new ArrayList<>();
|
||||
for (ReflectionUtil reflectionUtil : list) {
|
||||
for (SerializableFunction<org.apache.poi.ss.formula.functions.T, com.baomidou.mybatisplus.extension.api.R> function : reflectionUtil.getFunctions()) {
|
||||
String fieldName = getFieldName(function);
|
||||
l.add(reflectionUtil.getAlias() + "." + fieldName);
|
||||
}
|
||||
}
|
||||
return l;
|
||||
public static <T, R> List<String> getFieldNameList(SerializableFunction<T, R>... functions) {
|
||||
return Arrays.stream(functions).map(ReflectionUtil::getFieldName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T, R> String getFieldNameToUlc(SerializableFunction<T, R> function) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user