chen.lin
19 小时以前 8d5c50656d81dc3eb04a841ecd259adebf99424a
搜索库存明细调整不查询删除物料
7个文件已修改
73 ■■■■■ 已修改文件
rsf-admin/src/config/MyDataProvider.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/locItem/LocItemList.jsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/UserController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/system/service/UserService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/config/MyDataProvider.js
@@ -37,7 +37,10 @@
  // get a list of records based on an array of ids
  getMany: async (resource, params) => {
    // console.log("getMany", resource, params);
    if (resource === "user") {
      await new Promise((r) => setTimeout(r, 1000));
    }
    const res = await request.post(resource + "/many/" + params.ids);
    const { code, msg, data } = res.data;
    if (code === 200) {
rsf-admin/src/page/locItem/LocItemList.jsx
@@ -56,8 +56,20 @@
    },
}));
const locUseStatusChoices = typeof localStorage !== 'undefined'
    ? (JSON.parse(localStorage.getItem('sys_dicts') || '[]')).filter((d) => d.dictTypeCode === 'sys_loc_use_stas')
    : [];
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <AutocompleteInput
        source="useStatus"
        label="table.field.loc.useStatus"
        choices={locUseStatusChoices}
        optionText="label"
        optionValue="value"
        resettable
    />,
    <NumberInput source="locId" label="table.field.locItem.locId" />,
    <TextInput source="locCode" label="table.field.locItem.locCode" />,
    <NumberInput source="matnrId" label="table.field.locItem.matnrId" />,
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java
@@ -22,6 +22,7 @@
import com.vincent.rsf.server.system.controller.BaseController;
import com.vincent.rsf.server.manager.enums.LocStsType;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -42,8 +43,16 @@
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class);
        // 库位状态筛选:关联 man_loc,不能作为 man_loc_item 字段参与 buildWrapper
        Object useStatus = map.get("useStatus");
        if (pageParam.getWhere() != null && pageParam.getWhere().getMap() != null) {
            pageParam.getWhere().getMap().remove("useStatus");
        }
        QueryWrapper<LocItem> wrapper = pageParam.buildWrapper(true);
        if (useStatus != null && StringUtils.isNotBlank(useStatus.toString())) {
            String status = useStatus.toString().replace("'", "''");
            wrapper.apply("EXISTS (SELECT 1 FROM man_loc ml WHERE ml.id = man_loc_item.loc_id AND ml.use_status = '" + status + "')");
        }
        FieldsUtils.setFieldsFilters(wrapper, pageParam, LocItem.class);
        /**拼接扩展字段*/
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/UserController.java
@@ -60,7 +60,7 @@
    @PreAuthorize("hasAuthority('system:user:list')")
    @PostMapping({"/user/many/{ids}", "/users/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(userService.listByIds(Arrays.asList(ids)));
        return R.ok().add(userService.listByIdsCached(Arrays.asList(ids)));
    }
    @PreAuthorize("hasAuthority('system:user:list')")
rsf-server/src/main/java/com/vincent/rsf/server/system/service/UserService.java
@@ -7,8 +7,14 @@
import com.vincent.rsf.server.common.domain.PageResult;
import com.vincent.rsf.server.system.entity.User;
import java.util.Collection;
import java.util.List;
public interface UserService extends IService<User> {
    /** 按 ID 批量查询用户(带短期缓存,减轻列表页 createBy/updateBy 等多次请求压力) */
    List<User> listByIdsCached(Collection<Long> ids);
    PageResult<User> pageRel(PageParam<User, BaseParam> pageParam);
    User getByUsername(String username, Long tenantId);
rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java
@@ -14,9 +14,16 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    /** 批量查询缓存:key = 排序后的 ids 拼接,value = (过期时间戳, 用户列表),TTL 5 分钟 */
    private static final long CACHE_TTL_MS = 5 * 60 * 1000L;
    private static final ConcurrentHashMap<String, CacheEntry<List<User>>> USER_MANY_CACHE = new ConcurrentHashMap<>(64);
    @Resource
    private UserRoleService userRoleService;
@@ -70,4 +77,29 @@
        return baseMapper.selectByUsernameWithoutTenant(username,tenantId);
    }
    @Override
    public List<User> listByIdsCached(Collection<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            return Collections.emptyList();
        }
        String key = ids.stream().sorted().map(Object::toString).collect(Collectors.joining(","));
        long now = System.currentTimeMillis();
        CacheEntry<List<User>> entry = USER_MANY_CACHE.get(key);
        if (entry != null && entry.expireAt > now) {
            return entry.data;
        }
        List<User> list = listByIds(ids);
        USER_MANY_CACHE.put(key, new CacheEntry<>(now + CACHE_TTL_MS, list));
        return list;
    }
    private static class CacheEntry<T> {
        final long expireAt;
        final T data;
        CacheEntry(long expireAt, T data) {
            this.expireAt = expireAt;
            this.data = data;
        }
    }
}
rsf-server/src/main/resources/mapper/manager/LocItemMapper.xml
@@ -44,8 +44,9 @@
            , GROUP_CONCAT(DISTINCT l.use_status ORDER BY l.use_status) AS locStatuses
        </if>
        FROM man_loc_item li
        INNER JOIN man_loc l ON l.id = li.loc_id
        WHERE li.matnr_id IN
        INNER JOIN man_loc l ON l.id = li.loc_id AND (l.deleted = 0 OR l.deleted IS NULL)
        WHERE li.deleted = 0
        AND li.matnr_id IN
        <foreach collection="matnrIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>