zhuhaiwen 3 years ago
parent
commit
d79e18f043

+ 4 - 0
oa-app/src/main/java/com/css/oa/exam/place/bean/VerifyOneReq.java

1
package com.css.oa.exam.place.bean;
1
package com.css.oa.exam.place.bean;
2
2
3
import com.css.oa.exam.constants.BoolState;
4
3
public class VerifyOneReq {
5
public class VerifyOneReq {
4
6
5
    public String uuid;
7
    public String uuid;
6
8
9
    public int gree = BoolState.DEFULT;
10
7
    public String suggest;
11
    public String suggest;
8
12
9
}
13
}

+ 5 - 0
oa-app/src/main/java/com/css/oa/exam/place/bean/VerifyReq.java

1
package com.css.oa.exam.place.bean;
1
package com.css.oa.exam.place.bean;
2
2
3
import com.css.oa.exam.constants.BoolState;
4
3
import java.util.ArrayList;
5
import java.util.ArrayList;
4
import java.util.List;
6
import java.util.List;
5
7
7
9
8
    public List<String> ids = new ArrayList<>();
10
    public List<String> ids = new ArrayList<>();
9
11
12
13
    public int gree = BoolState.DEFULT;
14
10
}
15
}

+ 15 - 3
oa-app/src/main/java/com/css/oa/exam/place/controller/PlaceController.java

1
package com.css.oa.exam.place.controller;
1
package com.css.oa.exam.place.controller;
2
2
3
import com.css.oa.exam.base.BaseController;
3
import com.css.oa.exam.base.BaseController;
4
import com.css.oa.exam.constants.BoolState;
4
import com.css.oa.exam.place.bean.*;
5
import com.css.oa.exam.place.bean.*;
5
import com.css.oa.exam.place.repository.Place;
6
import com.css.oa.exam.place.repository.Place;
6
import com.css.oa.exam.place.service.PlaceService;
7
import com.css.oa.exam.place.service.PlaceService;
52
    public Result delete(@RequestBody List<String> ids) {
53
    public Result delete(@RequestBody List<String> ids) {
53
        Result<Map> result;
54
        Result<Map> result;
54
        try {
55
        try {
56
            String token = getToken();
57
            mService.setToken(token);
55
            mService.delete(ids);
58
            mService.delete(ids);
56
            result = setResult();
59
            result = setResult();
57
        } catch (Exception e) {
60
        } catch (Exception e) {
146
            if (TextUtils.isEmpty(req.uuid)) {
149
            if (TextUtils.isEmpty(req.uuid)) {
147
                return setErr("uuid参数不能为空");
150
                return setErr("uuid参数不能为空");
148
            }
151
            }
152
            if (req.gree == BoolState.DEFULT) {
153
                return setErr("gree参数不能为空");
154
            }
149
            String token = getToken();
155
            String token = getToken();
150
            mService.setToken(token);
156
            mService.setToken(token);
151
            mService.verifyOne(req.uuid, req.suggest);
157
            mService.verifyOne(req);
152
            result = setResult();
158
            result = setResult();
153
        } catch (Exception e) {
159
        } catch (Exception e) {
154
            result = setErr(e.getMessage());
160
            result = setErr(e.getMessage());
159
165
160
    @ApiOperation(value = "批量审核")
166
    @ApiOperation(value = "批量审核")
161
    @PostMapping("/batchVerify")
167
    @PostMapping("/batchVerify")
162
    public Result batchVerify(@RequestBody List<String> ids) {
168
    public Result batchVerify(@RequestBody VerifyReq req) {
163
        Result<Map> result;
169
        Result<Map> result;
164
        try {
170
        try {
171
            if (req.ids.size() == 0) {
172
                return setErr("ids数组元素 不能为空");
173
            }
174
            if (req.gree == BoolState.DEFULT) {
175
                return setErr("gree参数不能为空");
176
            }
165
            String token = getToken();
177
            String token = getToken();
166
            mService.setToken(token);
178
            mService.setToken(token);
167
            mService.batchVerify(ids);
179
            mService.batchVerify(req);
168
            result = setResult();
180
            result = setResult();
169
        } catch (Exception e) {
181
        } catch (Exception e) {
170
            result = setErr(e.getMessage());
182
            result = setErr(e.getMessage());

+ 3 - 0
oa-app/src/main/java/com/css/oa/exam/place/place.txt

1
考点管理:
2
1,审核状态如果是“上级审核中”,禁止删除本条数据
3
2,“上级审核中”,禁止编辑本条数据

+ 10 - 6
oa-app/src/main/java/com/css/oa/exam/place/repository/Place.java

1
package com.css.oa.exam.place.repository;
1
package com.css.oa.exam.place.repository;
2
2
3
import com.css.oa.exam.constants.BoolState;
3
import com.fasterxml.jackson.annotation.JsonFormat;
4
import com.fasterxml.jackson.annotation.JsonFormat;
4
import lombok.Data;
5
import lombok.Data;
5
6
18
    @Column(name = "UUID")
19
    @Column(name = "UUID")
19
    private String uuid;
20
    private String uuid;
20
21
22
    @Column(name = "CREATE_UNIT_ID")
23
    public String create_unit_id;
24
25
    @Column(name = "CURR_ID")
26
    public String curr_id;
27
28
    @Column(name = "IS_REJECT")
29
    public int is_reject = BoolState.DEFULT;
30
21
    @Column(name = "PLACE_NAME")
31
    @Column(name = "PLACE_NAME")
22
    public String place_name;
32
    public String place_name;
23
33
24
    @Column(name = "PLACE_CODE")
34
    @Column(name = "PLACE_CODE")
25
    public String place_code;
35
    public String place_code;
26
36
27
    @Column(name = "QUEUE")
28
    public String queue;// 1,2,3,4
29
30
    @Column(name = "CURR_ID")
31
    public String curr_id;
32
33
    @Column(name = "ROOM_COUNT")
37
    @Column(name = "ROOM_COUNT")
34
    public int room_count;
38
    public int room_count;
35
39

+ 5 - 7
oa-app/src/main/java/com/css/oa/exam/place/service/IPlaceService.java

1
package com.css.oa.exam.place.service;
1
package com.css.oa.exam.place.service;
2
2
3
import com.css.oa.exam.place.bean.PlaceDuplicateBean;
4
import com.css.oa.exam.place.bean.PlaceQueryReq;
5
import com.css.oa.exam.place.bean.PlaceResultWrap;
3
import com.css.oa.exam.place.bean.*;
6
import com.css.oa.exam.place.repository.Place;
4
import com.css.oa.exam.place.repository.Place;
7
5
8
import java.util.List;
6
import java.util.List;
14
12
15
    void add(Place examUser);
13
    void add(Place examUser);
16
14
17
    void delete(List<String> ids);
15
    void delete(List<String> ids) throws Exception;
18
16
19
    void update(Place user);
17
    void update(Place user) throws Exception;
20
18
21
    boolean duplicate(PlaceDuplicateBean bean);
19
    boolean duplicate(PlaceDuplicateBean bean);
22
20
23
    void verifyOne(String uuid, String suggest);
21
    void verifyOne(VerifyOneReq req);
24
22
25
    void batchVerify(List<String> ids);
23
    void batchVerify(VerifyReq req);
26
24
27
    PlaceResultWrap queryToYear();
25
    PlaceResultWrap queryToYear();
28
26

+ 105 - 77
oa-app/src/main/java/com/css/oa/exam/place/service/PlaceService.java

4
import com.css.oa.exam.admin.repository.IUnitRepository;
4
import com.css.oa.exam.admin.repository.IUnitRepository;
5
import com.css.oa.exam.admin.repository.Unit;
5
import com.css.oa.exam.admin.repository.Unit;
6
import com.css.oa.exam.base.BaseService;
6
import com.css.oa.exam.base.BaseService;
7
import com.css.oa.exam.constants.BoolState;
7
import com.css.oa.exam.exam.repository.Exam;
8
import com.css.oa.exam.exam.repository.Exam;
8
import com.css.oa.exam.exam.repository.IExamRepository;
9
import com.css.oa.exam.exam.repository.IExamRepository;
9
import com.css.oa.exam.place.bean.DropdownVerifyState;
10
import com.css.oa.exam.place.bean.PlaceDuplicateBean;
11
import com.css.oa.exam.place.bean.PlaceQueryReq;
12
import com.css.oa.exam.place.bean.PlaceResultWrap;
10
import com.css.oa.exam.place.bean.*;
13
import com.css.oa.exam.place.repository.IPlaceRepository;
11
import com.css.oa.exam.place.repository.IPlaceRepository;
14
import com.css.oa.exam.place.repository.Place;
12
import com.css.oa.exam.place.repository.Place;
15
import com.css.oa.exam.util.UpdateObjectTool;
13
import com.css.oa.exam.util.UpdateObjectTool;
66
                    //我创建的、我的下级提交的
64
                    //我创建的、我的下级提交的
67
                    Admin admin = Admin.getAdminByToken(token);
65
                    Admin admin = Admin.getAdminByToken(token);
68
                    if (!TextUtils.isEmpty(admin.my_unit_id)) {
66
                    if (!TextUtils.isEmpty(admin.my_unit_id)) {
69
                        String pattern = "%" + admin.my_unit_id + "%";
70
                        Predicate inQueue = criteriaBuilder.like(root.get("queue").as(String.class), pattern);
71
                        predicateList.add(inQueue);//包含 包含条件
67
                        Predicate create_unit_id = criteriaBuilder.equal(root.get("create_unit_id").as(String.class), admin.my_unit_id);
68
                        //Predicate create_unit_id = criteriaBuilder.equal(root.get("create_unit_id").as(String.class), admin.my_unit_id);
69
70
                        Predicate predicate2 = null;
71
                        criteriaBuilder.or(create_unit_id,predicate2);
72
72
                    }
73
                    }
73
                    //1,考点名
74
                    //1,考点名
74
                    String place_name = condition.place_name;
75
                    String place_name = condition.place_name;
88
                    }
89
                    }
89
                    //4.审核状态
90
                    //4.审核状态
90
                    String verify_state = condition.verify_state;
91
                    String verify_state = condition.verify_state;
91
                    if(verify_state.equalsIgnoreCase(DropdownVerifyState.WAIT)){
92
                    if (verify_state.equalsIgnoreCase(DropdownVerifyState.WAIT)) {
92
                        //待提交
93
                        //待提交
93
                        predicateList.add(criteriaBuilder.equal(root.get("curr_id").as(String.class), admin.my_unit_id));
94
                        predicateList.add(criteriaBuilder.equal(root.get("curr_id").as(String.class), admin.my_unit_id));
94
                    }else if(verify_state.equalsIgnoreCase(DropdownVerifyState.ING)){
95
                    } else if (verify_state.equalsIgnoreCase(DropdownVerifyState.ING)) {
95
                        //上级审核中
96
                        //上级审核中
96
                        Expression<String> queue = root.get("queue").as(String.class);
97
                        Expression<String> queue = root.get("queue").as(String.class);
97
                        EntityType<Place> model = root.getModel();
98
                        EntityType<Place> model = root.getModel();
99
                        //root.join()
100
                        //root.join()
100
                        //Path<Place> queue1 = root.get("queue");
101
                        //Path<Place> queue1 = root.get("queue");
101
102
102
                    }else if(verify_state.equalsIgnoreCase(DropdownVerifyState.ED)){
103
                    } else if (verify_state.equalsIgnoreCase(DropdownVerifyState.ED)) {
103
                        //审核通过
104
                        //审核通过
104
                        List<Unit> top = unitRepository.getTop();
105
                        List<Unit> top = unitRepository.getTop();
105
                        if(top != null && top.size() > 0){
106
                        if (top != null && top.size() > 0) {
106
                            predicateList.add(criteriaBuilder.equal(root.get("curr_id").as(String.class), top.get(0).getUuid()));
107
                            predicateList.add(criteriaBuilder.equal(root.get("curr_id").as(String.class), top.get(0).getUuid()));
107
                        }
108
                        }
108
                    }
109
                    }
197
        return null;
198
        return null;
198
    }
199
    }
199
200
200
    private ArrayList<String> getArr(Unit unit) {
201
        ArrayList<String> ids = new ArrayList();
202
        ids.add(unit.uuid);
203
        String p_id = unit.getP_id();
204
        boolean b = !TextUtils.isEmpty(p_id) && !p_id.equals("-1") && !p_id.equals(" ") && !p_id.contains(" ");
205
        if (b) {
206
            Unit pUnit = getUnit(p_id);
207
            if (pUnit != null) {
208
                ids.addAll(getArr(pUnit));
209
            }
210
        }
211
        return ids;
212
    }
213
214
    private void setQue(Place place) {
215
        String adminUnitId = Admin.getAdminUnitId(token);
216
        Unit me = getUnit(adminUnitId);
217
        if (me != null) {
218
            place.setCurr_id(me.uuid);
219
            place.setVerify_state("待提交");
220
221
            ArrayList<String> list = getArr(me);
222
            String que = "";
223
            for (int i = 0; i < list.size(); i++) {
224
                String id = list.get(i);
225
                if (i == 0) {
226
                    que = que + id;
227
                } else {
228
                    que = que + "," + id;
229
                }
230
            }
231
            list.clear();
232
            place.setQueue(que);
233
        }
234
235
    }
201
//    private ArrayList<String> getArr(Unit unit) {
202
//        ArrayList<String> ids = new ArrayList();
203
//        ids.add(unit.uuid);
204
//        String p_id = unit.getP_id();
205
//        boolean b = !TextUtils.isEmpty(p_id) && !p_id.equals("-1") && !p_id.equals(" ") && !p_id.contains(" ");
206
//        if (b) {
207
//            Unit pUnit = getUnit(p_id);
208
//            if (pUnit != null) {
209
//                ids.addAll(getArr(pUnit));
210
//            }
211
//        }
212
//        return ids;
213
//    }
214
215
//    private void setQue(Place place) {
216
//        String adminUnitId = Admin.getAdminUnitId(token);
217
//        Unit me = getUnit(adminUnitId);
218
//        if (me != null) {
219
//            place.setCurr_id(me.uuid);
220
//            place.setVerify_state("待提交");
221
//
222
//            ArrayList<String> list = getArr(me);
223
//            String que = "";
224
//            for (int i = 0; i < list.size(); i++) {
225
//                String id = list.get(i);
226
//                if (i == 0) {
227
//                    que = que + id;
228
//                } else {
229
//                    que = que + "," + id;
230
//                }
231
//            }
232
//            list.clear();
233
//            place.setQueue(que);
234
//        }
235
//
236
//    }
236
237
237
    @Override
238
    @Override
238
    public void add(Place place) {
239
    public void add(Place place) {
250
            place.setUpdate_time(newDate);
251
            place.setUpdate_time(newDate);
251
        }
252
        }
252
        Admin admin = Admin.getAdminByToken(token);
253
        Admin admin = Admin.getAdminByToken(token);
254
        if (place.getIs_reject() == BoolState.DEFULT) {
255
            place.setIs_reject(BoolState.NO);
256
        }
257
        place.setCurr_id(admin.my_unit_id);
258
        place.setCreate_unit_id(admin.my_unit_id);
259
253
        if (TextUtils.isEmpty(place.getCreate_user())) {
260
        if (TextUtils.isEmpty(place.getCreate_user())) {
254
            place.setCreate_user(admin.name);
261
            place.setCreate_user(admin.name);
255
        }
262
        }
256
        if (TextUtils.isEmpty(place.getUpdate_user())) {
263
        if (TextUtils.isEmpty(place.getUpdate_user())) {
257
            place.setUpdate_user(admin.name);
264
            place.setUpdate_user(admin.name);
258
        }
265
        }
259
        setQue(place);
260
        repository.save(place);
266
        repository.save(place);
261
    }
267
    }
262
268
263
    @Override
269
    @Override
264
    public void delete(List<String> ids) {
265
        //ids = ["0","2","3"]
266
        repository.deleteRealByIds(ids);
270
    public void delete(List<String> uuids) throws Exception {
271
        Admin admin = Admin.getAdminByToken(token);
272
        for (String uuid : uuids) {
273
            Place oldPlace = repository.findById(uuid).get();
274
            //是我创建的、并且审核权在我手里边 的时候可以删除
275
            if (oldPlace.getCreate_unit_id().equalsIgnoreCase(admin.my_unit_id) &&
276
                    oldPlace.getCurr_id().equalsIgnoreCase(admin.my_unit_id)) {
277
278
            }else {
279
                throw new Exception("审核权不在您手中,禁止删除");
280
            }
281
        }
282
        repository.deleteRealByIds(uuids);
267
    }
283
    }
268
284
269
285
271
     * @param newPlace 这个方法,对象必须携带id
287
     * @param newPlace 这个方法,对象必须携带id
272
     */
288
     */
273
    @Override
289
    @Override
274
    public void update(Place newPlace) {
290
    public void update(Place newPlace) throws Exception {
291
        Admin admin = Admin.getAdminByToken(token);
292
275
        Optional<Place> byId = repository.findById(newPlace.getUuid());
293
        Optional<Place> byId = repository.findById(newPlace.getUuid());
276
        Place oldPlace = byId.get();
294
        Place oldPlace = byId.get();
277
        Admin admin = Admin.getAdminByToken(token);
295
        if (!oldPlace.getCurr_id().equalsIgnoreCase(admin.my_unit_id)) {
296
            throw new Exception("审核权不在您手中,禁止编辑");
297
        }
278
        newPlace.setUpdate_user(admin.name);
298
        newPlace.setUpdate_user(admin.name);
279
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
299
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
280
        repository.save(newPlace);
300
        repository.save(newPlace);
305
    }
325
    }
306
326
307
    @Override
327
    @Override
308
    public void verifyOne(String uuid, String suggest) {
309
        Optional<Place> byId = repository.findById(uuid);
310
        Place oldPlace = byId.get();
311
328
    public void verifyOne(VerifyOneReq req) {
312
        Admin admin = Admin.getAdminByToken(token);
329
        Admin admin = Admin.getAdminByToken(token);
313
        Place newPlace = new Place();
314
        newPlace.setCurr_id(admin.my_unit_id);
315
316
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
317
        repository.save(newPlace);
318
    }
319
330
320
    private boolean cannot(Place oldPlace, Admin admin) {
321
        String[] que = oldPlace.getQueue().split(",");
322
        ArrayList<String> ids = new ArrayList();
323
        for (String id : que) {
324
            ids.add(id);
331
        Optional<Place> byId = repository.findById(req.uuid);
332
        Place oldPlace = byId.get();
333
        //如果到了自己这一级,我就能审核
334
        if (!oldPlace.getCurr_id().equalsIgnoreCase(admin.my_unit_id)) {
335
            return;
325
        }
336
        }
326
        int i = ids.indexOf(oldPlace.getCurr_id());
327
        int j = ids.indexOf(admin.my_unit_id);
328
        if (i < j) {
329
            return false;
337
        Place newPlace = new Place();
338
        Unit myUnit = getUnit(admin.my_unit_id);
339
        if (req.gree == BoolState.YES) {
340
            newPlace.setCurr_id(myUnit.getP_id());
341
            newPlace.setIs_reject(BoolState.NO);
330
        }
342
        }
331
        return true;
343
        if (req.gree == BoolState.NO) {
344
            newPlace.setCurr_id(oldPlace.getCreate_unit_id());
345
            newPlace.setIs_reject(BoolState.YES);
346
        }
347
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
348
        repository.save(newPlace);
332
    }
349
    }
333
350
334
    @Override
351
    @Override
335
    public void batchVerify(List<String> ids) {
352
    public void batchVerify(VerifyReq req) {
336
        Admin admin = Admin.getAdminByToken(token);
353
        Admin admin = Admin.getAdminByToken(token);
337
        List<Place> oldAll = repository.getAllByIds(ids);
354
        List<Place> oldAll = repository.getAllByIds(req.ids);
338
        List<Place> newAll = new ArrayList<>();
355
        List<Place> newAll = new ArrayList<>();
339
        for (Place oldPlace : oldAll) {
356
        for (Place oldPlace : oldAll) {
340
            if (cannot(oldPlace, admin)) {
357
            //如果到了自己这一级,我就能审核
358
            if (!oldPlace.getCurr_id().equalsIgnoreCase(admin.my_unit_id)) {
341
                continue;
359
                continue;
342
            }
360
            }
343
            Place newPlace = new Place();
361
            Place newPlace = new Place();
344
            newPlace.setCurr_id(admin.my_unit_id);
362
363
            Unit myUnit = getUnit(admin.my_unit_id);
364
            if (req.gree == BoolState.YES) {
365
                newPlace.setCurr_id(myUnit.getP_id());
366
                newPlace.setIs_reject(BoolState.NO);
367
            }
368
            if (req.gree == BoolState.NO) {
369
                newPlace.setCurr_id(oldPlace.getCreate_unit_id());
370
                newPlace.setIs_reject(BoolState.YES);
371
            }
372
345
            UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
373
            UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
346
            newAll.add(newPlace);
374
            newAll.add(newPlace);
347
        }
375
        }

+ 4 - 5
oa-app/src/main/java/com/css/oa/exam/subject/service/SubjectService.java

33
    ISubjectRepository repository;
33
    ISubjectRepository repository;
34
34
35
    private void checkPermission(String msg) throws Exception {
35
    private void checkPermission(String msg) throws Exception {
36
        String adminUnitId = Admin.getAdminUnitId(token);
37
        List<Unit> unitList = unitRepository.getUnitBy(adminUnitId);
36
        String myUnitId = Admin.getAdminUnitId(token);
37
        List<Unit> unitList = unitRepository.getTop();
38
        if (unitList.size() > 0) {
38
        if (unitList.size() > 0) {
39
            Unit unit = unitList.get(0);
40
            String parent_unit_id = unit.getP_id();
41
            if (!TextUtils.isEmpty(parent_unit_id)) {
39
            Unit top = unitList.get(0);
40
            if(!myUnitId.equalsIgnoreCase(top.uuid)){
42
                throw new Exception(msg);
41
                throw new Exception(msg);
43
            }
42
            }
44
        }
43
        }