添加货品分类信息增加ancestors属性
This commit is contained in:
parent
ad8e9f4991
commit
ac955351e2
@ -65,13 +65,7 @@ public class StuffDetailController {
|
|||||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
Result<IPage<StuffDetail>> result = new Result<IPage<StuffDetail>>();
|
return stuffDetailService.queryPageList(stuffDetail,pageNo,pageSize,req);
|
||||||
QueryWrapper<StuffDetail> queryWrapper = QueryGenerator.initQueryWrapper(stuffDetail, req.getParameterMap());
|
|
||||||
Page<StuffDetail> page = new Page<StuffDetail>(pageNo, pageSize);
|
|
||||||
IPage<StuffDetail> pageList = stuffDetailService.page(page, queryWrapper);
|
|
||||||
result.setSuccess(true);
|
|
||||||
result.setResult(pageList);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -110,7 +110,17 @@ public class StuffTypeController {
|
|||||||
public Result<StuffType> add(@RequestBody StuffType stuffType) {
|
public Result<StuffType> add(@RequestBody StuffType stuffType) {
|
||||||
Result<StuffType> result = new Result<StuffType>();
|
Result<StuffType> result = new Result<StuffType>();
|
||||||
try {
|
try {
|
||||||
|
boolean top = stuffType.getParentId() == null || stuffType.getParentId() == 0;
|
||||||
|
if (top) {
|
||||||
|
stuffType.setParentId(0L);
|
||||||
|
stuffType.setAncestors("0");
|
||||||
|
}
|
||||||
stuffTypeService.save(stuffType);
|
stuffTypeService.save(stuffType);
|
||||||
|
if (!top) {
|
||||||
|
StuffType p = stuffTypeService.getById(stuffType.getParentId());
|
||||||
|
stuffType.setAncestors(p.getAncestors() + "," + p.getId());
|
||||||
|
stuffTypeService.updateById(stuffType);
|
||||||
|
}
|
||||||
result.success("添加成功!");
|
result.success("添加成功!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.zhgd.xmgl.modules.stuff.entity;
|
package com.zhgd.xmgl.modules.stuff.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
@ -11,6 +12,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
|||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 货品
|
* @Description: 货品
|
||||||
@ -35,7 +37,7 @@ public class StuffDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@Excel(name = "货品分类id", width = 15)
|
@Excel(name = "货品分类id", width = 15)
|
||||||
@ApiModelProperty(value = "货品分类id")
|
@ApiModelProperty(value = "货品分类id")
|
||||||
private java.lang.Integer stuffTypeId;
|
private java.lang.Long stuffTypeId;
|
||||||
/**
|
/**
|
||||||
* 货号
|
* 货号
|
||||||
*/
|
*/
|
||||||
@ -118,4 +120,26 @@ public class StuffDetail implements Serializable {
|
|||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ApiModelProperty(value = "更新时间")
|
@ApiModelProperty(value = "更新时间")
|
||||||
private java.util.Date updateTime;
|
private java.util.Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数量")
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "仓库id")
|
||||||
|
private Long stuffWarehouseId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "仓库名称")
|
||||||
|
private String warehouseNames;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "开始时间")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "结束时间")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,10 @@ public class StuffType implements Serializable {
|
|||||||
@ApiModelProperty(value = "项目sn")
|
@ApiModelProperty(value = "项目sn")
|
||||||
private java.lang.String projectSn;
|
private java.lang.String projectSn;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "祖级列表")
|
||||||
|
private java.lang.String ancestors;
|
||||||
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<StuffType> children;
|
private List<StuffType> children;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package com.zhgd.xmgl.modules.stuff.mapper;
|
package com.zhgd.xmgl.modules.stuff.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
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.stuff.entity.StuffDetail;
|
import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 货品
|
* @Description: 货品
|
||||||
@ -13,4 +18,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface StuffDetailMapper extends BaseMapper<StuffDetail> {
|
public interface StuffDetailMapper extends BaseMapper<StuffDetail> {
|
||||||
|
|
||||||
|
IPage<StuffDetail> queryPageList(StuffDetail stuffDetail, Page<StuffDetail> page,@Param(Constants.WRAPPER) QueryWrapper<StuffDetail> queryWrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,4 +2,15 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.stuff.mapper.StuffDetailMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.stuff.mapper.StuffDetailMapper">
|
||||||
|
|
||||||
|
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.stuff.entity.StuffDetail">
|
||||||
|
SELECT
|
||||||
|
sd.*,
|
||||||
|
GROUP_CONCAT(sw.warehouse_name) warehouse_names
|
||||||
|
FROM
|
||||||
|
stuff_detail sd
|
||||||
|
LEFT JOIN stuff_warehouse_stuff_detail swsd ON swsd.stuff_detail_id = sd.id
|
||||||
|
LEFT JOIN `stuff_warehouse` sw ON swsd.stuff_warehouse_id = sw.id
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
GROUP BY sd.id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
package com.zhgd.xmgl.modules.stuff.service;
|
package com.zhgd.xmgl.modules.stuff.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 货品
|
* @Description: 货品
|
||||||
* @author: pds
|
* @author: pds
|
||||||
@ -11,4 +15,5 @@ import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
|||||||
*/
|
*/
|
||||||
public interface IStuffDetailService extends IService<StuffDetail> {
|
public interface IStuffDetailService extends IService<StuffDetail> {
|
||||||
|
|
||||||
|
Result<IPage<StuffDetail>> queryPageList(StuffDetail stuffDetail, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,20 @@
|
|||||||
package com.zhgd.xmgl.modules.stuff.service.impl;
|
package com.zhgd.xmgl.modules.stuff.service.impl;
|
||||||
|
|
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
import com.zhgd.xmgl.modules.stuff.entity.StuffDetail;
|
||||||
import com.zhgd.xmgl.modules.stuff.mapper.StuffDetailMapper;
|
import com.zhgd.xmgl.modules.stuff.mapper.StuffDetailMapper;
|
||||||
import com.zhgd.xmgl.modules.stuff.service.IStuffDetailService;
|
import com.zhgd.xmgl.modules.stuff.service.IStuffDetailService;
|
||||||
|
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 货品
|
* @Description: 货品
|
||||||
* @author: pds
|
* @author: pds
|
||||||
@ -14,5 +23,29 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class StuffDetailServiceImpl extends ServiceImpl<StuffDetailMapper, StuffDetail> implements IStuffDetailService {
|
public class StuffDetailServiceImpl extends ServiceImpl<StuffDetailMapper, StuffDetail> implements IStuffDetailService {
|
||||||
|
@Autowired
|
||||||
|
StuffDetailMapper stuffDetailMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<IPage<StuffDetail>> queryPageList(StuffDetail stuffDetail, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||||
|
Result<IPage<StuffDetail>> result = new Result<>();
|
||||||
|
QueryWrapper<StuffDetail> queryWrapper = new QueryWrapper<>();
|
||||||
|
String stuffDetailAlias = "sd.";
|
||||||
|
String warehouseAlias = "sw.";
|
||||||
|
queryWrapper
|
||||||
|
.eq(StringUtils.isNotBlank(stuffDetail.getProjectSn()), stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getProjectSn), stuffDetail.getProjectSn())
|
||||||
|
.eq(stuffDetail.getStuffTypeId() != null, stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getStuffTypeId), stuffDetail.getStuffTypeId())
|
||||||
|
.eq(stuffDetail.getStuffWarehouseId() != null, warehouseAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getStuffWarehouseId), stuffDetail.getStuffWarehouseId())
|
||||||
|
.le(stuffDetail.getEndTime() != null, stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getUpdateTime), stuffDetail.getEndTime())
|
||||||
|
.ge(stuffDetail.getStartTime() != null, stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getUpdateTime), stuffDetail.getStartTime())
|
||||||
|
.like(StringUtils.isNotBlank(stuffDetail.getStuffNumber()), stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getStuffNumber), stuffDetail.getStuffNumber())
|
||||||
|
.like(StringUtils.isNotBlank(stuffDetail.getLookupCode()), stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getLookupCode), stuffDetail.getLookupCode())
|
||||||
|
.like(StringUtils.isNotBlank(stuffDetail.getName()), stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getName), stuffDetail.getName())
|
||||||
|
.like(StringUtils.isNotBlank(stuffDetail.getSpecification()), stuffDetailAlias + ReflectionUtil.getFieldNameToUlc(StuffDetail::getSpecification), stuffDetail.getSpecification());
|
||||||
|
Page<StuffDetail> page = new Page<StuffDetail>(pageNo, pageSize);
|
||||||
|
IPage<StuffDetail> pageList = stuffDetailMapper.queryPageList(stuffDetail, page, queryWrapper);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(pageList);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.xmgl.util;
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
@ -20,6 +21,14 @@ public class ReflectionUtil {
|
|||||||
|
|
||||||
private static Map<SerializableFunction<?, ?>, Field> cache = new ConcurrentHashMap<>();
|
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> String getFieldNameToUlc(SerializableFunction<T, R> function) {
|
||||||
|
return StrUtil.toUnderlineCase(getFieldName(function));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 方法引用获取属性名
|
* 方法引用获取属性名
|
||||||
*
|
*
|
||||||
@ -33,10 +42,6 @@ public class ReflectionUtil {
|
|||||||
return field.getName();
|
return field.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
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> Field getField(SerializableFunction<T, R> function) {
|
public static <T, R> Field getField(SerializableFunction<T, R> function) {
|
||||||
return cache.computeIfAbsent(function, ReflectionUtil::findField);
|
return cache.computeIfAbsent(function, ReflectionUtil::findField);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user