田源
2025-01-16 a13255b4129ee8a7a7b7e1ecd8e02dd2c78f7c17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.vci.web.dao.impl;
 
import com.vci.constant.VciFileBtmTypeConstant;
import com.vci.model.VciFileVolumeDO;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.dao.VciFileVolumeDaoI;
import com.vci.web.service.WebBoServiceI;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 文件柜的数据操作层
 * @author weidy
 * @date 2021/3/11
 */
@Repository
public class VciFileVolumeDaoImpl implements VciFileVolumeDaoI {
 
    /**
     * 业务数据对象的服务
     */
    @Autowired
    private WebBoServiceI boService;
    /**
     * 使用主键删除
     *
     * @param oid 数据主键
     * @return 执行结果
     */
    @Override
    public int deleteByPrimaryKey(String oid) {
        VciBaseUtil.alertNotNull(oid,"文件的主键");
        boService.deleteByCondition(VciFileBtmTypeConstant.FILE_VOLUME, WebUtil.getOidQuery(oid));
        return StringUtils.countMatches(oid,",") + 1;
    }
 
    /**
     * 添加数据
     *
     * @param record 文仓管理数据对象
     * @return 执行结果
     */
    @Override
    public int insert(VciFileVolumeDO record) {
        VciBaseUtil.alertNotNull(record,"要添加的内容");
        if(StringUtils.isBlank(record.getOid())){
            record.setOid(VciBaseUtil.getPk());
        }
        boService.addSave(record);
        return 1;
    }
 
    /**
     * 根据主键查询
     *
     * @param oid 数据主键
     * @return 数据对象
     */
    @Override
    public VciFileVolumeDO selectByPrimaryKey(String oid) {
        return boService.selectByOid(oid, VciFileVolumeDO.class);
    }
 
    /**
     * 根据主键批量获取对象
     *
     * @param oids 主键,包含单引号,但是不能超过1000
     * @return 数据对象列表
     */
    @Override
    public List<VciFileVolumeDO> selectByPrimaryKeys(String oids) {
        return boService.selectByOidCollection(VciBaseUtil.str2List(oids),VciFileVolumeDO.class);
    }
 
    /**
     * 根据主键批量查询对象
     *
     * @param oids 对象主键,使用逗号分隔,但是不能超过1000
     * @return 业务对象
     */
    @Override
    public List<VciFileVolumeDO> selectByPrimaryKeyCollection(Collection<String> oids) {
        return boService.selectByOidCollection(oids,VciFileVolumeDO.class);
    }
 
    /**
     * 查询所有分类
     *
     * @return 查询结果
     */
    @Override
    public List<VciFileVolumeDO> selectAll() {
        return boService.queryObject(VciFileVolumeDO.class,null);
    }
 
    /**
     * 更新物料、工具基本分类
     *
     * @param record 物料、工具基本分类数据对象
     * @return 执行结果
     */
    @Override
    public int updateByPrimaryKey(VciFileVolumeDO record) {
        VciBaseUtil.alertNotNull(record,"要修改的内容",record.getOid(),"主键");
        boService.editSave(record);
        return 1;
    }
 
    /**
     * 根据查询条件查询数据
     *
     * @param wrapper 查询条件,包括分页,排序
     * @return 数据对象列表
     */
    @Override
    public List<VciFileVolumeDO> selectByWrapper(VciQueryWrapperForDO wrapper) {
        return boService.selectByQueryWrapper(wrapper,VciFileVolumeDO.class);
    }
 
    /**
     * 根据查询条件来查询总数
     *
     * @param wrapper 查询条件
     * @return 总数
     */
    @Override
    public Long countByWrapper(VciQueryWrapperForDO wrapper) {
        return Long.valueOf(boService.countByQueryWrapper(wrapper,VciFileVolumeDO.class));
    }
 
    /**
     * 根据主键获取名称
     *
     * @param oid 主键
     * @return 中文名称
     */
    @Override
    public String selectNameByOid(String oid) {
        VciFileVolumeDO fileObjectDO = selectByPrimaryKey(oid);
        return fileObjectDO!=null?fileObjectDO.getName():"";
    }
 
    /**
     * 批量删除对象
     *
     * @param oids 对象的主键集合
     * @return 受印象的行数
     */
    @Override
    public long batchDeleteByOids(Collection<String> oids) {
        VciBaseUtil.switchCollectionForOracleIn(oids).forEach(oidList->{
            Map<String,String> conditionMap = new HashMap<>();
            conditionMap.put("oid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidList.toArray(new String[0])) + ")");
            boService.deleteByCondition(VciFileBtmTypeConstant.FILE_VOLUME,conditionMap);
        });
        return oids.size();
    }
 
    /**
     * 更新使用的容量
     *
     * @param oid        主键
     * @param usedVolume 使用的容量
     * @return 受影响的行数
     */
    @Override
    public int updateUsedVolume(String oid, String usedVolume) {
        //这个暂时没有
        return 0;
    }
}