zhuhaiwen 3 年 前
コミット
d79e18f043

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

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

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

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

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

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

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

@ -1,5 +1,6 @@
1 1
package com.css.oa.exam.place.repository;
2 2
3
import com.css.oa.exam.constants.BoolState;
3 4
import com.fasterxml.jackson.annotation.JsonFormat;
4 5
import lombok.Data;
5 6
@ -18,18 +19,21 @@ public class Place implements Serializable, Cloneable {
18 19
    @Column(name = "UUID")
19 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 31
    @Column(name = "PLACE_NAME")
22 32
    public String place_name;
23 33
24 34
    @Column(name = "PLACE_CODE")
25 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 37
    @Column(name = "ROOM_COUNT")
34 38
    public int room_count;
35 39

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

@ -1,8 +1,6 @@
1 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 4
import com.css.oa.exam.place.repository.Place;
7 5
8 6
import java.util.List;
@ -14,15 +12,15 @@ public interface IPlaceService {
14 12
15 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 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 25
    PlaceResultWrap queryToYear();
28 26

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

@ -4,12 +4,10 @@ import com.css.oa.exam.admin.bean.Admin;
4 4
import com.css.oa.exam.admin.repository.IUnitRepository;
5 5
import com.css.oa.exam.admin.repository.Unit;
6 6
import com.css.oa.exam.base.BaseService;
7
import com.css.oa.exam.constants.BoolState;
7 8
import com.css.oa.exam.exam.repository.Exam;
8 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 11
import com.css.oa.exam.place.repository.IPlaceRepository;
14 12
import com.css.oa.exam.place.repository.Place;
15 13
import com.css.oa.exam.util.UpdateObjectTool;
@ -66,9 +64,12 @@ public class PlaceService extends BaseService implements IPlaceService {
66 64
                    //我创建的、我的下级提交的
67 65
                    Admin admin = Admin.getAdminByToken(token);
68 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 74
                    //1,考点名
74 75
                    String place_name = condition.place_name;
@ -88,10 +89,10 @@ public class PlaceService extends BaseService implements IPlaceService {
88 89
                    }
89 90
                    //4.审核状态
90 91
                    String verify_state = condition.verify_state;
91
                    if(verify_state.equalsIgnoreCase(DropdownVerifyState.WAIT)){
92
                    if (verify_state.equalsIgnoreCase(DropdownVerifyState.WAIT)) {
92 93
                        //待提交
93 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 97
                        Expression<String> queue = root.get("queue").as(String.class);
97 98
                        EntityType<Place> model = root.getModel();
@ -99,10 +100,10 @@ public class PlaceService extends BaseService implements IPlaceService {
99 100
                        //root.join()
100 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 105
                        List<Unit> top = unitRepository.getTop();
105
                        if(top != null && top.size() > 0){
106
                        if (top != null && top.size() > 0) {
106 107
                            predicateList.add(criteriaBuilder.equal(root.get("curr_id").as(String.class), top.get(0).getUuid()));
107 108
                        }
108 109
                    }
@ -197,42 +198,42 @@ public class PlaceService extends BaseService implements IPlaceService {
197 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 238
    @Override
238 239
    public void add(Place place) {
@ -250,20 +251,35 @@ public class PlaceService extends BaseService implements IPlaceService {
250 251
            place.setUpdate_time(newDate);
251 252
        }
252 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 260
        if (TextUtils.isEmpty(place.getCreate_user())) {
254 261
            place.setCreate_user(admin.name);
255 262
        }
256 263
        if (TextUtils.isEmpty(place.getUpdate_user())) {
257 264
            place.setUpdate_user(admin.name);
258 265
        }
259
        setQue(place);
260 266
        repository.save(place);
261 267
    }
262 268
263 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,10 +287,14 @@ public class PlaceService extends BaseService implements IPlaceService {
271 287
     * @param newPlace 这个方法,对象必须携带id
272 288
     */
273 289
    @Override
274
    public void update(Place newPlace) {
290
    public void update(Place newPlace) throws Exception {
291
        Admin admin = Admin.getAdminByToken(token);
292
275 293
        Optional<Place> byId = repository.findById(newPlace.getUuid());
276 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 298
        newPlace.setUpdate_user(admin.name);
279 299
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
280 300
        repository.save(newPlace);
@ -305,43 +325,51 @@ public class PlaceService extends BaseService implements IPlaceService {
305 325
    }
306 326
307 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 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 351
    @Override
335
    public void batchVerify(List<String> ids) {
352
    public void batchVerify(VerifyReq req) {
336 353
        Admin admin = Admin.getAdminByToken(token);
337
        List<Place> oldAll = repository.getAllByIds(ids);
354
        List<Place> oldAll = repository.getAllByIds(req.ids);
338 355
        List<Place> newAll = new ArrayList<>();
339 356
        for (Place oldPlace : oldAll) {
340
            if (cannot(oldPlace, admin)) {
357
            //如果到了自己这一级,我就能审核
358
            if (!oldPlace.getCurr_id().equalsIgnoreCase(admin.my_unit_id)) {
341 359
                continue;
342 360
            }
343 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 373
            UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
346 374
            newAll.add(newPlace);
347 375
        }

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

@ -33,12 +33,11 @@ public class SubjectService extends BaseService implements ISubjectService {
33 33
    ISubjectRepository repository;
34 34
35 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 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 41
                throw new Exception(msg);
43 42
            }
44 43
        }