This commit is contained in:
parent
7422bec2e3
commit
6d13c8a996
@ -65,37 +65,23 @@ public class MaterialController {
|
|||||||
public IPage<Material> materials(
|
public IPage<Material> materials(
|
||||||
@Parameter(description = "页码") @RequestParam(required = false, defaultValue = "1") int page,
|
@Parameter(description = "页码") @RequestParam(required = false, defaultValue = "1") int page,
|
||||||
@Parameter(description = "页面大小") @RequestParam(required = false, defaultValue = "10") int size,
|
@Parameter(description = "页面大小") @RequestParam(required = false, defaultValue = "10") int size,
|
||||||
@Parameter(description = "类型") @RequestParam(required = false, defaultValue = "") Integer type,
|
@Parameter(description = "类型") @RequestParam(required = false, defaultValue = "") String type,
|
||||||
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key) {
|
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key) {
|
||||||
boolean hasLike = Strings.isNotBlank(key);
|
String[] types = StringUtils.isNotBlank(type) ? type.split(",") : new String[0];
|
||||||
key = String.format("%%%s%%", key);
|
Page<Material> result = materialService.getPage(Page.of(page, size), List.of(types),key);
|
||||||
Page<Material> result = materialService.page(Page.of(page, size), Wrappers.<Material>lambdaQuery()
|
|
||||||
.like(hasLike, Material::getName, key)
|
|
||||||
.or()
|
|
||||||
.like(hasLike, Material::getCode, key)
|
|
||||||
.or()
|
|
||||||
.like(hasLike, Material::getType, key)
|
|
||||||
.orderByDesc(Material::getUpdatedTime));
|
|
||||||
result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType())));
|
result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType())));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("material/download-excel")
|
@GetMapping("material/download-excel")
|
||||||
@Operation(summary = "导出物料列表")
|
@Operation(summary = "导出物料列表")
|
||||||
public void downloadExcel(@Parameter(description = "类型") @RequestParam(required = false, defaultValue = "") Integer type,
|
public void downloadExcel(@Parameter(description = "类型") @RequestParam(required = false, defaultValue = "") String type,
|
||||||
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key,
|
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
boolean hasLike = Strings.isNotBlank(key);
|
String[] types = StringUtils.isNotBlank(type) ? type.split(",") : new String[0];
|
||||||
key = String.format("%%%s%%", key);
|
Page<Material> result = materialService.getPage(Page.of(1, 10000), List.of(types),key);
|
||||||
List<Material> result = materialService.list(Wrappers.<Material>lambdaQuery()
|
result.getRecords().forEach(item -> item.setTypeName(typeService.getTypeName(item.getType())));
|
||||||
.like(hasLike, Material::getName, key)
|
ExcelUtil.exportExcel(response, "物料列表-" + System.currentTimeMillis(), "库存", Material.class, result.getRecords());
|
||||||
.or()
|
|
||||||
.like(hasLike, Material::getCode, key)
|
|
||||||
.or()
|
|
||||||
.like(hasLike, Material::getType, key)
|
|
||||||
.orderByDesc(Material::getUpdatedTime));
|
|
||||||
result.forEach(item -> item.setTypeName(typeService.getTypeName(item.getType())));
|
|
||||||
ExcelUtil.exportExcel(response, "物料列表-" + System.currentTimeMillis(), "库存", Material.class, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("material/list")
|
@PostMapping("material/list")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tech.riemann.ims.mapper.material;
|
package tech.riemann.ims.mapper.material;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import tech.riemann.ims.entity.material.Material;
|
import tech.riemann.ims.entity.material.Material;
|
||||||
|
|
||||||
@ -12,4 +13,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface MaterialMapper extends BaseMapper<Material> {
|
public interface MaterialMapper extends BaseMapper<Material> {
|
||||||
List<Material> queryLikeRight( @Param("types") List<String> types);
|
List<Material> queryLikeRight( @Param("types") List<String> types);
|
||||||
|
|
||||||
|
Page<Material> getPage(Page<Object> page, List<String> types, String key);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package tech.riemann.ims.service.material;
|
package tech.riemann.ims.service.material;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.nutz.spring.boot.service.interfaces.IdNameEntityService;
|
import org.nutz.spring.boot.service.interfaces.IdNameEntityService;
|
||||||
import tech.riemann.ims.entity.material.Material;
|
import tech.riemann.ims.entity.material.Material;
|
||||||
@ -13,4 +14,6 @@ import java.util.List;
|
|||||||
public interface IMaterialService extends IService<Material>, IdNameEntityService<Material> {
|
public interface IMaterialService extends IService<Material>, IdNameEntityService<Material> {
|
||||||
|
|
||||||
List<Material> queryLikeRight(List<String> types);
|
List<Material> queryLikeRight(List<String> types);
|
||||||
|
|
||||||
|
Page<Material> getPage(Page<Object> page, List<String> types, String key);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package tech.riemann.ims.service.material.impl;
|
package tech.riemann.ims.service.material.impl;
|
||||||
|
|
||||||
|
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
@ -28,4 +29,9 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|||||||
public List<Material> queryLikeRight(List<String> types) {
|
public List<Material> queryLikeRight(List<String> types) {
|
||||||
return baseMapper.queryLikeRight(types);
|
return baseMapper.queryLikeRight(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Material> getPage(Page<Object> page, List<String> types, String key) {
|
||||||
|
return baseMapper.getPage(page, types, key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,40 @@
|
|||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getPage" resultType="tech.riemann.ims.entity.material.Material">
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
m_code AS `code`,
|
||||||
|
m_name AS `name`,
|
||||||
|
m_assign_rule AS `assignRule`,
|
||||||
|
m_type AS `type`,
|
||||||
|
m_price AS `price`,
|
||||||
|
m_spec AS `spec`,
|
||||||
|
m_stock AS `stock`,
|
||||||
|
m_description AS `description`,
|
||||||
|
created_time,
|
||||||
|
updated_time,
|
||||||
|
created_by,
|
||||||
|
updated_by
|
||||||
|
FROM
|
||||||
|
t_material
|
||||||
|
<where>
|
||||||
|
<if test="types != null and types.size() > 0">
|
||||||
|
and (
|
||||||
|
<foreach collection="types" item="item" separator="or">
|
||||||
|
( m_type like concat(#{item},'%') )
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="key != null and key.trim().length() > 0">
|
||||||
|
and (
|
||||||
|
m_code like concat('%',#{key},'%')
|
||||||
|
or m_name like concat('%',#{key},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by updated_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user