添加物料管理,新建、编辑、删除、批量删除、查询、重置
parent
2b2470c36e
commit
126b905a86
|
|
@ -60,7 +60,7 @@ public class AdminCacheConst extends CacheKeyConst {
|
|||
public static class Base {
|
||||
public static final String AREA_ENTITY = "area_cache";
|
||||
public static final String LOCATION_ENTITY = "location_cache";
|
||||
|
||||
public static final String ITEM_ENTITY = "item_cache";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class AreaController {
|
|||
@PostMapping("/area/queryPage")
|
||||
@SaCheckPermission("area:query")
|
||||
public ResponseDTO<PageResult<AreaVO>> queryPage(@RequestBody @Valid AreaQueryForm queryForm) {
|
||||
return areaQueryService.queryPage(queryForm);
|
||||
return ResponseDTO.ok(areaQueryService.queryPage(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加 @author hj")
|
||||
|
|
|
|||
|
|
@ -10,4 +10,7 @@ public class AreaSelect {
|
|||
|
||||
@Schema(description = "库区名称集合")
|
||||
List<String> areaNames;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
Boolean disabledFlag;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.lab1024.sa.admin.module.business.base.area.domain.form.AreaQueryForm;
|
|||
import net.lab1024.sa.admin.module.business.base.area.domain.form.AreaSelect;
|
||||
import net.lab1024.sa.admin.module.business.base.area.domain.vo.AreaVO;
|
||||
import net.lab1024.sa.admin.module.business.base.area.manager.AreaManager;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
|
|
@ -35,28 +36,37 @@ public class AreaQueryService {
|
|||
* @param queryForm 查询参数
|
||||
* @return PageResult<AreaVO>
|
||||
*/
|
||||
public ResponseDTO<PageResult<AreaVO>> queryPage(AreaQueryForm queryForm) {
|
||||
public PageResult<AreaVO> queryPage(AreaQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<AreaVO> list = areaDao.queryPage(page, queryForm);
|
||||
PageResult<AreaVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
return ResponseDTO.ok(pageResult);
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库区信息
|
||||
* 库区下拉查询
|
||||
*
|
||||
* @param areaSelect 入参
|
||||
* @return List<AreaEntity>
|
||||
*/
|
||||
public List<AreaEntity> queryArea(AreaSelect areaSelect) {
|
||||
LambdaQueryWrapper<AreaEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AreaEntity::getDisabledFlag, Boolean.TRUE);
|
||||
if (areaSelect != null && areaSelect.getAreaNames() != null) {
|
||||
//是否启用
|
||||
if (areaSelect.getDisabledFlag() != null) {
|
||||
queryWrapper.eq(AreaEntity::getDisabledFlag, areaSelect.getDisabledFlag());
|
||||
}
|
||||
//库区名称
|
||||
if (CollectionUtils.isNotEmpty(areaSelect.getAreaNames())) {
|
||||
queryWrapper.in(AreaEntity::getAreaName, areaSelect.getAreaNames());
|
||||
}
|
||||
return areaDao.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据库区id集合查询库区信息
|
||||
*
|
||||
* @param areaIdList 库区id集合
|
||||
* @return Map<Long, AreaEntity>
|
||||
*/
|
||||
public Map<Long, AreaEntity> queryAreaList(List<Long> areaIdList) {
|
||||
if (CollectionUtils.isEmpty(areaIdList)) {
|
||||
return Collections.emptyMap();
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ public class AreaService {
|
|||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param addForm 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> add(AreaAddForm addForm) {
|
||||
AreaEntity existingArea = areaQueryService.queryByAreaName(addForm.getAreaName());
|
||||
|
|
@ -59,8 +62,8 @@ public class AreaService {
|
|||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param updateForm
|
||||
* @return
|
||||
* @param updateForm 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> update(AreaUpdateForm updateForm) {
|
||||
AreaEntity existingArea = areaQueryService.queryByAreaName(updateForm.getAreaName());
|
||||
|
|
@ -77,8 +80,8 @@ public class AreaService {
|
|||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param idList
|
||||
* @return
|
||||
* @param idList 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
|
|
@ -101,7 +104,7 @@ public class AreaService {
|
|||
|
||||
//删除库区
|
||||
if (CollectionUtils.isNotEmpty(idsToDelete)) {
|
||||
areaDao.deleteBatchIds(idsToDelete);
|
||||
areaManager.removeBatchByIds(idsToDelete);
|
||||
//更新缓存
|
||||
areaManager.removeCache();
|
||||
}
|
||||
|
|
@ -114,6 +117,9 @@ public class AreaService {
|
|||
|
||||
/**
|
||||
* 单个删除
|
||||
*
|
||||
* @param areaId 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> delete(Long areaId) {
|
||||
if (null == areaId) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.controller;
|
||||
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemAddForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemSelect;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemUpdateForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.vo.ItemVO;
|
||||
import net.lab1024.sa.admin.module.business.base.item.service.ItemQueryService;
|
||||
import net.lab1024.sa.admin.module.business.base.item.service.ItemService;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationSelect;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.RequestUser;
|
||||
import net.lab1024.sa.base.common.domain.ValidateList;
|
||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
|
@ -15,6 +22,8 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料信息 Controller
|
||||
*
|
||||
|
|
@ -30,17 +39,23 @@ public class ItemController {
|
|||
@Resource
|
||||
private ItemService itemService;
|
||||
|
||||
@Resource
|
||||
private ItemQueryService itemQueryService;
|
||||
|
||||
@Operation(summary = "分页查询 @author 霍锦")
|
||||
@PostMapping("/item/queryPage")
|
||||
@SaCheckPermission("item:query")
|
||||
public ResponseDTO<PageResult<ItemVO>> queryPage(@RequestBody @Valid ItemQueryForm queryForm) {
|
||||
return ResponseDTO.ok(itemService.queryPage(queryForm));
|
||||
return ResponseDTO.ok(itemQueryService.queryPage(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加 @author 霍锦")
|
||||
@PostMapping("/item/add")
|
||||
@SaCheckPermission("item:add")
|
||||
public ResponseDTO<String> add(@RequestBody @Valid ItemAddForm addForm) {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
addForm.setCreateUserId(requestUser.getUserId());
|
||||
addForm.setCreateUserName(requestUser.getUserName());
|
||||
return itemService.add(addForm);
|
||||
}
|
||||
|
||||
|
|
@ -64,4 +79,10 @@ public class ItemController {
|
|||
public ResponseDTO<String> batchDelete(@RequestParam Long itemId) {
|
||||
return itemService.delete(itemId);
|
||||
}
|
||||
|
||||
@Operation(summary = "物料下拉查询")
|
||||
@PostMapping("/item/queryItem")
|
||||
public ResponseDTO<List<ItemEntity>> queryItem(@RequestBody ItemSelect itemSelect) {
|
||||
return ResponseDTO.ok(itemQueryService.queryItem(itemSelect));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -17,10 +21,6 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ItemAddForm {
|
||||
|
||||
@Schema(description = "物料id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "物料id 不能为空")
|
||||
private Long itemId;
|
||||
|
||||
@Schema(description = "物料编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "物料编码 不能为空")
|
||||
private String itemCode;
|
||||
|
|
@ -29,28 +29,28 @@ public class ItemAddForm {
|
|||
@NotBlank(message = "物料名称 不能为空")
|
||||
private String itemName;
|
||||
|
||||
@Schema(description = "是否禁用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否禁用 不能为空")
|
||||
private Boolean disabledFlag;
|
||||
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "单位 不能为空")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "物料类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "物料类型 不能为空")
|
||||
private String itemType;
|
||||
|
||||
@Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "创建人ID 不能为空")
|
||||
@Schema(description = "包装系数")
|
||||
@NotNull(message = "商品价格不能为空")
|
||||
@DecimalMin(value = "1", message = "包装系数最低1")
|
||||
private BigDecimal packFactor;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
@NotNull(message = "禁用状态不能为空")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(hidden = true)
|
||||
private Long createUserId;
|
||||
|
||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "创建人 不能为空")
|
||||
@Schema(hidden = true)
|
||||
private String createUserName;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "创建时间 不能为空")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "更新时间 不能为空")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -17,10 +17,9 @@ import lombok.EqualsAndHashCode;
|
|||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ItemQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
private String itemCode;
|
||||
|
||||
@Schema(description = "物料名称")
|
||||
private String itemName;
|
||||
@Schema(description = "物料")
|
||||
private Long itemId;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean disabledFlag;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ItemSelect {
|
||||
@Schema(description = "是否启用")
|
||||
Boolean disabledFlag;
|
||||
}
|
||||
|
|
@ -15,42 +15,11 @@ import lombok.Data;
|
|||
*/
|
||||
|
||||
@Data
|
||||
public class ItemUpdateForm {
|
||||
public class ItemUpdateForm extends ItemAddForm{
|
||||
|
||||
@Schema(description = "物料id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "物料id 不能为空")
|
||||
private Long itemId;
|
||||
|
||||
@Schema(description = "物料编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "物料编码 不能为空")
|
||||
private String itemCode;
|
||||
|
||||
@Schema(description = "物料名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "物料名称 不能为空")
|
||||
private String itemName;
|
||||
|
||||
@Schema(description = "是否禁用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否禁用 不能为空")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "物料类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "物料类型 不能为空")
|
||||
private String itemType;
|
||||
|
||||
@Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "创建人ID 不能为空")
|
||||
private Long createUserId;
|
||||
|
||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "创建人 不能为空")
|
||||
private String createUserName;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "创建时间 不能为空")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "更新时间 不能为空")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.manager;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.admin.constant.AdminCacheConst;
|
||||
import net.lab1024.sa.admin.module.business.base.area.dao.AreaDao;
|
||||
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.item.dao.ItemDao;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
@ -14,7 +21,25 @@ import org.springframework.stereotype.Service;
|
|||
* @Copyright 友仓
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ItemManager extends ServiceImpl<ItemDao, ItemEntity> {
|
||||
@Resource
|
||||
private ItemDao itemDao;
|
||||
|
||||
/**
|
||||
* 根据类目id 移除缓存
|
||||
*/
|
||||
@CacheEvict(value = {AdminCacheConst.Base.ITEM_ENTITY}, allEntries = true)
|
||||
public void removeCache() {
|
||||
log.info("clear ITEM_ENTITY");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢类目
|
||||
*/
|
||||
@Cacheable(AdminCacheConst.Base.ITEM_ENTITY)
|
||||
public ItemEntity queryItem(Long itemId) {
|
||||
return itemDao.selectById(itemId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.admin.module.business.base.item.dao.ItemDao;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemSelect;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.vo.ItemVO;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ItemQueryService {
|
||||
@Resource
|
||||
private ItemDao itemDao;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param queryForm 入参
|
||||
* @return PageResult<ItemVO>
|
||||
*/
|
||||
public PageResult<ItemVO> queryPage(ItemQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<ItemVO> list = itemDao.queryPage(page, queryForm);
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物料信息
|
||||
*
|
||||
* @param itemSelect 入参
|
||||
* @return List<ItemEntity>
|
||||
*/
|
||||
public List<ItemEntity> queryItem(ItemSelect itemSelect) {
|
||||
LambdaQueryWrapper<ItemEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//是否启用
|
||||
if (itemSelect.getDisabledFlag() != null) {
|
||||
queryWrapper.eq(ItemEntity::getDisabledFlag, itemSelect.getDisabledFlag());
|
||||
}
|
||||
return itemDao.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据物料编码查询
|
||||
*
|
||||
* @param itemCode 物料编码
|
||||
* @return ItemEntity
|
||||
*/
|
||||
public ItemEntity queryByItemCode(String itemCode) {
|
||||
LambdaQueryWrapper<ItemEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ItemEntity::getItemCode, itemCode);
|
||||
return itemDao.selectOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,16 @@
|
|||
package net.lab1024.sa.admin.module.business.base.item.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.item.dao.ItemDao;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemAddForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.form.ItemUpdateForm;
|
||||
import net.lab1024.sa.admin.module.business.base.item.domain.vo.ItemVO;
|
||||
import net.lab1024.sa.admin.module.business.base.item.manager.ItemManager;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
|
|
@ -31,64 +35,82 @@ public class ItemService {
|
|||
@Resource
|
||||
private ItemDao itemDao;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public PageResult<ItemVO> queryPage(ItemQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<ItemVO> list = itemDao.queryPage(page, queryForm);
|
||||
PageResult<ItemVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
return pageResult;
|
||||
}
|
||||
@Resource
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Resource
|
||||
private ItemQueryService itemQueryService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param addForm 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> add(ItemAddForm addForm) {
|
||||
ItemEntity existingItem = itemQueryService.queryByItemCode(addForm.getItemCode());
|
||||
if (existingItem != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, UserErrorCode.ALREADY_EXIST.getMsg());
|
||||
}
|
||||
ItemEntity itemEntity = SmartBeanUtil.copy(addForm, ItemEntity.class);
|
||||
itemDao.insert(itemEntity);
|
||||
|
||||
//更新缓存
|
||||
itemManager.removeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param updateForm
|
||||
* @return
|
||||
* @param updateForm 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> update(ItemUpdateForm updateForm) {
|
||||
ItemEntity existingItem = itemQueryService.queryByItemCode(updateForm.getItemCode());
|
||||
if (existingItem != null && !existingItem.getItemId().equals(updateForm.getItemId())) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, UserErrorCode.ALREADY_EXIST.getMsg());
|
||||
}
|
||||
ItemEntity itemEntity = SmartBeanUtil.copy(updateForm, ItemEntity.class);
|
||||
itemDao.updateById(itemEntity);
|
||||
//更新缓存
|
||||
itemManager.removeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param idList
|
||||
* @return
|
||||
* @param idList 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)){
|
||||
return ResponseDTO.ok();
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, UserErrorCode.PARAM_ERROR.getMsg());
|
||||
}
|
||||
|
||||
itemDao.deleteBatchIds(idList);
|
||||
itemManager.removeBatchByIds(idList);
|
||||
|
||||
//更新缓存
|
||||
itemManager.removeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个删除
|
||||
*
|
||||
* @param itemId 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> delete(Long itemId) {
|
||||
if (null == itemId){
|
||||
return ResponseDTO.ok();
|
||||
if (null == itemId) {
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, UserErrorCode.PARAM_ERROR.getMsg());
|
||||
}
|
||||
|
||||
itemDao.deleteById(itemId);
|
||||
|
||||
//更新缓存
|
||||
itemManager.removeCache();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class LocationController {
|
|||
@PostMapping("/location/queryPage")
|
||||
@SaCheckPermission("location:query")
|
||||
public ResponseDTO<PageResult<LocationVO>> queryPage(@RequestBody @Valid LocationQueryForm queryForm) {
|
||||
return locationQueryService.queryPage(queryForm);
|
||||
return ResponseDTO.ok(locationQueryService.queryPage(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加 @author 霍锦")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationSe
|
|||
import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO;
|
||||
import net.lab1024.sa.admin.module.business.base.location.manager.LocationManager;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -47,13 +46,10 @@ public class LocationQueryService {
|
|||
* @param queryForm 查询参数
|
||||
* @return PageResult<LocationVO>
|
||||
*/
|
||||
public ResponseDTO<PageResult<LocationVO>> queryPage(LocationQueryForm queryForm) {
|
||||
public PageResult<LocationVO> queryPage(LocationQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<LocationVO> list = locationDao.queryPage(page, queryForm);
|
||||
PageResult<LocationVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
}
|
||||
|
||||
// 查询库区名称
|
||||
List<Long> categoryIdList = list.stream().map(LocationVO::getAreaId).distinct().collect(Collectors.toList());
|
||||
Map<Long, AreaEntity> areaMap = areaQueryService.queryAreaList(categoryIdList);
|
||||
|
|
@ -63,10 +59,15 @@ public class LocationQueryService {
|
|||
area.setAreaName(areaEntity.getAreaName());
|
||||
}
|
||||
});
|
||||
return ResponseDTO.ok(pageResult);
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
//转实体转VO
|
||||
/**
|
||||
* 实体转VO
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return LocationVO
|
||||
*/
|
||||
public LocationVO entityToVO(LocationEntity entity) {
|
||||
AreaEntity area = areaManager.queryArea(entity.getAreaId());
|
||||
return LocationVO.builder()
|
||||
|
|
@ -87,7 +88,10 @@ public class LocationQueryService {
|
|||
|
||||
|
||||
/**
|
||||
* 查询库位信息
|
||||
* 库位下拉查询
|
||||
*
|
||||
* @param locationSelect 查询参数
|
||||
* @return List<LocationVO>
|
||||
*/
|
||||
public List<LocationVO> queryLocation(LocationSelect locationSelect) {
|
||||
LambdaQueryWrapper<LocationEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
|
@ -121,6 +125,12 @@ public class LocationQueryService {
|
|||
return list.stream().map(this::entityToVO).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据库位ID集合查询库位信息
|
||||
*
|
||||
* @param locationIdList 库位ID集合
|
||||
* @return Map<Long, LocationEntity>
|
||||
*/
|
||||
public Map<Long, LocationEntity> queryLocationList(List<Long> locationIdList) {
|
||||
if (CollectionUtils.isEmpty(locationIdList)) {
|
||||
return Collections.emptyMap();
|
||||
|
|
|
|||
|
|
@ -3,33 +3,19 @@ package net.lab1024.sa.admin.module.business.base.location.service;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.lab1024.sa.admin.constant.UsageStatusEnum;
|
||||
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.area.manager.AreaManager;
|
||||
import net.lab1024.sa.admin.module.business.base.area.service.AreaQueryService;
|
||||
import net.lab1024.sa.admin.module.business.base.area.service.AreaService;
|
||||
import net.lab1024.sa.admin.module.business.base.location.dao.LocationDao;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationAddForm;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.LocationUpdateForm;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.form.MultipleAdjust;
|
||||
import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO;
|
||||
import net.lab1024.sa.admin.module.business.base.location.manager.LocationManager;
|
||||
import net.lab1024.sa.admin.module.business.category.domain.entity.CategoryEntity;
|
||||
import net.lab1024.sa.admin.module.business.goods.domain.vo.GoodsExcelVO;
|
||||
import net.lab1024.sa.admin.module.business.goods.domain.vo.GoodsVO;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +40,9 @@ public class LocationService {
|
|||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param addForm 添加参数
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> add(LocationAddForm addForm) {
|
||||
LocationEntity existingLocation = locationQueryService.queryByLocationCode(addForm.getLocationCode());
|
||||
|
|
@ -70,6 +59,9 @@ public class LocationService {
|
|||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param updateForm 更新参数
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> update(LocationUpdateForm updateForm) {
|
||||
LocationEntity existingLocation = locationQueryService.queryByLocationCode(updateForm.getLocationCode());
|
||||
|
|
@ -85,13 +77,16 @@ public class LocationService {
|
|||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param idList 删除参数
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.ok();
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, UserErrorCode.PARAM_ERROR.getMsg());
|
||||
}
|
||||
|
||||
locationDao.deleteBatchIds(idList);
|
||||
locationManager.removeBatchByIds(idList);
|
||||
//更新缓存
|
||||
locationManager.removeCache();
|
||||
return ResponseDTO.ok();
|
||||
|
|
@ -99,10 +94,13 @@ public class LocationService {
|
|||
|
||||
/**
|
||||
* 单个删除
|
||||
*
|
||||
* @param locationId 入参
|
||||
* @return ResponseDTO<String>
|
||||
*/
|
||||
public ResponseDTO<String> delete(Long locationId) {
|
||||
if (null == locationId) {
|
||||
return ResponseDTO.ok();
|
||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, UserErrorCode.PARAM_ERROR.getMsg());
|
||||
}
|
||||
|
||||
locationDao.deleteById(locationId);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
<!-- 查询结果列 -->
|
||||
<sql id="base_columns">
|
||||
t_item.item_id,
|
||||
t_item
|
||||
.
|
||||
item_id
|
||||
,
|
||||
t_item.item_code,
|
||||
t_item.item_name,
|
||||
t_item.unit,
|
||||
|
|
@ -25,12 +28,12 @@
|
|||
FROM t_item
|
||||
<where>
|
||||
<!--物料编码-->
|
||||
<if test="queryForm.itemCode != null and queryForm.itemCode != ''">
|
||||
AND INSTR(t_item.item_code,#{queryForm.itemCode})
|
||||
<if test="queryForm.itemId != null">
|
||||
AND t_item.item_id=#{queryForm.itemId}
|
||||
</if>
|
||||
<!--物料名称-->
|
||||
<if test="queryForm.itemName != null and queryForm.itemName != ''">
|
||||
AND INSTR(t_item.item_name,#{queryForm.itemName})
|
||||
<if test="queryForm.disabledFlag != null">
|
||||
AND t_item.disabled_flag=#{queryForm.disabledFlag}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
<!-- 查询结果列 -->
|
||||
<sql id="base_columns">
|
||||
t_location
|
||||
.
|
||||
location_id
|
||||
,
|
||||
t_location.location_id,
|
||||
t_location.location_code,
|
||||
t_location.location_name,
|
||||
t_location.status,
|
||||
|
|
|
|||
Loading…
Reference in New Issue