zhuhaiwen 3 years ago
parent
commit
94cce05f09

+ 13 - 13
oa-app/src/main/java/com/css/oa/exam/admin/bean/Admin.java

12
        this.my_unit_id = my_unit_id;
12
        this.my_unit_id = my_unit_id;
13
    }
13
    }
14
14
15
//    public static Admin getAdminByToken(@NotNull String token){
16
//        if(token.equals("1")){
17
//            return new Admin("中央水利局","0");
18
//        }else if(token.equals("2")){
19
//            return new Admin("华南水利局","1");
20
//        }else if(token.equals("3")){
21
//            return new Admin("湖南水利","2");
22
//        }else if(token.equals("4")){
23
//            return new Admin("长沙市水利","3");
24
//        }else {
25
//            return new Admin("长沙县水利","4");
26
//        }
27
//    }
15
    public static Admin getAdminByToken(@NotNull String token){
16
        if(token.equals("1")){
17
            return new Admin("中央水利局朱局长","1");
18
        }else if(token.equals("2")){
19
            return new Admin("华南局朱董事","2");
20
        }else if(token.equals("3")){
21
            return new Admin("湖南水利厅朱厅长","3");
22
        }else if(token.equals("4")){
23
            return new Admin("长沙市水利所朱所长","4");
24
        }else {
25
            return new Admin("长沙县水利站朱站长","5");
26
        }
27
    }
28
28
29
    public static String getAdminUnitId(@NotNull String token){
29
    public static String getAdminUnitId(@NotNull String token){
30
        if(token.equals("1")){
30
        if(token.equals("1")){

+ 7 - 4
oa-app/src/main/java/com/css/oa/exam/exam/service/ExamService.java

76
        if (obj.getUpdate_time() == null) {
76
        if (obj.getUpdate_time() == null) {
77
            obj.setUpdate_time(newDate);
77
            obj.setUpdate_time(newDate);
78
        }
78
        }
79
        if (TextUtils.isEmpty(obj.getCreate_user()) || obj.getCreate_user().equalsIgnoreCase("null")) {
80
            obj.setCreate_user("系统");
79
        Admin admin = Admin.getAdminByToken(token);
80
        if (TextUtils.isEmpty(obj.getCreate_user())) {
81
            obj.setCreate_user(admin.name);
81
        }
82
        }
82
        if (TextUtils.isEmpty(obj.getUpdate_user()) || obj.getCreate_user().equalsIgnoreCase("null")) {
83
            obj.setUpdate_user("系统");
83
        if (TextUtils.isEmpty(obj.getUpdate_user())) {
84
            obj.setUpdate_user(admin.name);
84
        }
85
        }
85
        return saveExam(obj);
86
        return saveExam(obj);
86
    }
87
    }
90
        checkPermission("管理员所在的单位没有编辑考试的权限");
91
        checkPermission("管理员所在的单位没有编辑考试的权限");
91
        Optional<Exam> byId = repository.findById(newObj.getUuid());
92
        Optional<Exam> byId = repository.findById(newObj.getUuid());
92
        Exam old = byId.get();
93
        Exam old = byId.get();
94
        Admin admin = Admin.getAdminByToken(token);
95
        newObj.setUpdate_user(admin.name);
93
        UpdateObjectTool.copyNullProperties(old, newObj);
96
        UpdateObjectTool.copyNullProperties(old, newObj);
94
        return saveExam(newObj);
97
        return saveExam(newObj);
95
    }
98
    }

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

1
package com.css.oa.exam.place.bean;
2
3
public class VerifyOneReq {
4
5
    public String uuid;
6
7
    public String suggest;
8
9
}

+ 4 - 3
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 java.util.ArrayList;
4
import java.util.List;
5
3
public class VerifyReq {
6
public class VerifyReq {
4
7
5
    public String uuid;
6
    public int state;
7
    public String suggest;
8
    public List<String> ids = new ArrayList<>();
8
9
9
}
10
}

+ 21 - 9
oa-app/src/main/java/com/css/oa/exam/place/controller/PlaceController.java

11
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.web.bind.annotation.*;
12
import org.springframework.web.bind.annotation.*;
13
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
14
import java.util.List;
17
import java.util.Map;
15
import java.util.Map;
18
16
68
    public Result update(@RequestBody Place newPlace) {
66
    public Result update(@RequestBody Place newPlace) {
69
        Result<Map> result;
67
        Result<Map> result;
70
        try {
68
        try {
69
            String token = getToken();
70
            mService.setToken(token);
71
            if (TextUtils.isEmpty(newPlace.getUuid())) {
71
            if (TextUtils.isEmpty(newPlace.getUuid())) {
72
                return setErr("uuid参数不能为空");
72
                return setErr("uuid参数不能为空");
73
            }
73
            }
135
    }
135
    }
136
136
137
    @ApiOperation(value = "审核")
137
    @ApiOperation(value = "审核")
138
    @PostMapping("/verify")
139
    public Result verify(@RequestBody VerifyReq req) {
138
    @PostMapping("/verifyOne")
139
    public Result verifyOne(@RequestBody VerifyOneReq req) {
140
        Result<Map> result;
140
        Result<Map> result;
141
        try {
141
        try {
142
            if(TextUtils.isEmpty(req.uuid)){
142
            String token = getToken();
143
            mService.setToken(token);
144
            if (TextUtils.isEmpty(req.uuid)) {
143
                return setErr("uuid参数不能为空");
145
                return setErr("uuid参数不能为空");
144
            }
146
            }
145
            if(req.state == 0){
146
                return setErr("state参数不能为空或不能为0");
147
            }
148
            mService.verify(req.uuid, req.state, req.suggest);
147
            mService.verifyOne(req.uuid, req.suggest);
149
            result = setResult();
148
            result = setResult();
150
        } catch (Exception e) {
149
        } catch (Exception e) {
151
            result = setErr(e.getMessage());
150
            result = setErr(e.getMessage());
154
        return result;
153
        return result;
155
    }
154
    }
156
155
156
    @ApiOperation(value = "批量审核")
157
    @PostMapping("/batchVerify")
158
    public Result batchVerify(@RequestBody List<String> ids) {
159
        Result<Map> result;
160
        try {
161
            mService.batchVerify(ids);
162
            result = setResult();
163
        } catch (Exception e) {
164
            result = setErr(e.getMessage());
165
            e.printStackTrace();
166
        }
167
        return result;
168
    }
157
169
158
    @ApiOperation(value = "年份-考试-考点")
170
    @ApiOperation(value = "年份-考试-考点")
159
    @GetMapping("/queryToYear")
171
    @GetMapping("/queryToYear")

+ 10 - 5
oa-app/src/main/java/com/css/oa/exam/place/repository/IPlaceRepository.java

16
    //批量删除
16
    //批量删除
17
    @Modifying
17
    @Modifying
18
    @Transactional
18
    @Transactional
19
    @Query(nativeQuery = true, value = "delete from ATT_EXAM_PLACE where UUID in :ids")
19
    @Query(nativeQuery = true, value = "delete from OP_EXAM_PLACE where UUID in :ids")
20
    void deleteRealByIds(@Param("ids") List<String> ids);
20
    void deleteRealByIds(@Param("ids") List<String> ids);
21
21
22
    @Modifying
22
    @Modifying
23
    @Transactional
23
    @Transactional
24
    @Query(nativeQuery = true , value = "select * from ATT_EXAM_PLACE where EXAM_ID = :exam_id")
24
    @Query(nativeQuery = true , value = "select * from OP_EXAM_PLACE where EXAM_ID = :exam_id")
25
    List<Place> queryById(@Param("exam_id")String exam_id);
25
    List<Place> queryById(@Param("exam_id")String exam_id);
26
26
27
    @Modifying
27
    @Modifying
28
    @Transactional
28
    @Transactional
29
    @Query(nativeQuery = true , value = "select UUID from ATT_EXAM_PLACE where EXAM_ID = :exam_id")
29
    @Query(nativeQuery = true, value = "select * from OP_EXAM_PLACE where UUID in :ids")
30
    List<Place> getAllByIds(@Param("ids") List<String> ids);
31
32
    @Modifying
33
    @Transactional
34
    @Query(nativeQuery = true , value = "select UUID from OP_EXAM_PLACE where EXAM_ID = :exam_id")
30
    List<String> queryMyIdByExamId(@Param("exam_id")String exam_id);
35
    List<String> queryMyIdByExamId(@Param("exam_id")String exam_id);
31
36
32
    @Modifying
37
    @Modifying
33
    @Transactional
38
    @Transactional
34
    @Query(nativeQuery = true, value = "select * from ATT_EXAM_PLACE where EXAM_ID in :ids")
39
    @Query(nativeQuery = true, value = "select * from OP_EXAM_PLACE where EXAM_ID in :ids")
35
    List<Place> queryByExamIds(@Param("ids") List<String> ids);
40
    List<Place> queryByExamIds(@Param("ids") List<String> ids);
36
41
37
//    @Modifying
42
//    @Modifying
38
//    @Transactional
43
//    @Transactional
39
//    @Query(nativeQuery = true , value = "select * from ATT_EXAM_PLACE where EXAM_ID = :exam_id")
44
//    @Query(nativeQuery = true , value = "select * from OP_EXAM_PLACE where EXAM_ID = :exam_id")
40
//    List<ExamPlace> queryByName(@Param("name")String name);
45
//    List<ExamPlace> queryByName(@Param("name")String name);
41
46
42
}
47
}

+ 2 - 3
oa-app/src/main/java/com/css/oa/exam/place/repository/Place.java

45
    @Column(name = "EXAM_TYPE")
45
    @Column(name = "EXAM_TYPE")
46
    public int exam_type;
46
    public int exam_type;
47
47
48
    //状态  11一级审核通过 10一级审核未通过 15一级待审核,  20二级未通过 25二级待审核 , 35三级待提交
49
    @Column(name = "STATE")
50
    public int state;
48
    @Column(name = "VERIFY_STATE")
49
    public String verify_state;
51
50
52
//    @Column(name = "SUGGEST") //审核意见
51
//    @Column(name = "SUGGEST") //审核意见
53
//    public int suggest;
52
//    public int suggest;

+ 3 - 1
oa-app/src/main/java/com/css/oa/exam/place/service/IPlaceService.java

20
20
21
    boolean duplicate(PlaceDuplicateBean bean);
21
    boolean duplicate(PlaceDuplicateBean bean);
22
22
23
    void verify(String uuid, int state, String suggest);
23
    void verifyOne(String uuid, String suggest);
24
25
    void batchVerify(List<String> ids);
24
26
25
    PlaceResultWrap queryToYear();
27
    PlaceResultWrap queryToYear();
26
28

+ 68 - 23
oa-app/src/main/java/com/css/oa/exam/place/service/PlaceService.java

165
    @Autowired
165
    @Autowired
166
    IUnitRepository unitRepository;
166
    IUnitRepository unitRepository;
167
167
168
    private Unit getUnit(String id) {
169
        List<Unit> unitList = unitRepository.getUnitBy(id);
170
        if (unitList.size() > 0) {
171
            Unit me = unitList.get(0);
172
            return me;
173
        }
174
        return null;
175
    }
176
168
    private ArrayList<String> getArr(Unit unit) {
177
    private ArrayList<String> getArr(Unit unit) {
169
        ArrayList list = new ArrayList();
170
        list.add(unit.uuid);
178
        ArrayList<String> ids = new ArrayList();
179
        ids.add(unit.uuid);
171
        String p_id = unit.getP_id();
180
        String p_id = unit.getP_id();
172
        while (!TextUtils.isEmpty(p_id)) {
173
            List<Unit> unitList = unitRepository.getUnitBy(p_id);
174
            if (unitList.size() > 0) {
175
                Unit pUnit = unitList.get(0);
176
                list.add(pUnit.uuid);
177
                list.addAll(getArr(pUnit));
181
        boolean b = !TextUtils.isEmpty(p_id) && !p_id.equals("-1") && !p_id.equals(" ") && !p_id.contains(" ");
182
        if (b) {
183
            Unit pUnit = getUnit(p_id);
184
            if (pUnit != null) {
185
                ids.addAll(getArr(pUnit));
178
            }
186
            }
179
        }
187
        }
180
        return list;
188
        return ids;
181
    }
189
    }
182
190
183
    private void setQue(Place place) {
191
    private void setQue(Place place) {
184
        String adminUnitId = Admin.getAdminUnitId(token);
192
        String adminUnitId = Admin.getAdminUnitId(token);
185
        List<Unit> unitList = unitRepository.getUnitBy(adminUnitId);
186
        if (unitList.size() > 0) {
187
            Unit unit = unitList.get(0);
188
            place.setCurr_id(unit.uuid);
189
            ArrayList<String> list = getArr(unit);
193
        Unit me = getUnit(adminUnitId);
194
        if (me != null) {
195
            place.setCurr_id(me.uuid);
196
            place.setVerify_state("待提交");
197
198
            ArrayList<String> list = getArr(me);
190
            String que = "";
199
            String que = "";
191
            for (int i = 0; i < list.size(); i++) {
200
            for (int i = 0; i < list.size(); i++) {
192
                String id  = list.get(i);
193
                if(i == 0){
201
                String id = list.get(i);
202
                if (i == 0) {
194
                    que = que + id;
203
                    que = que + id;
195
                }else {
204
                } else {
196
                    que = que + "," + id;
205
                    que = que + "," + id;
197
                }
206
                }
198
            }
207
            }
208
            list.clear();
199
            place.setQueue(que);
209
            place.setQueue(que);
200
        }
210
        }
201
211
216
        if (place.getUpdate_time() == null) {
226
        if (place.getUpdate_time() == null) {
217
            place.setUpdate_time(newDate);
227
            place.setUpdate_time(newDate);
218
        }
228
        }
219
        if (TextUtils.isEmpty(place.getCreate_user()) || place.getCreate_user().equalsIgnoreCase("null")) {
220
            place.setCreate_user("无管理员");
229
        Admin admin = Admin.getAdminByToken(token);
230
        if (TextUtils.isEmpty(place.getCreate_user())) {
231
            place.setCreate_user(admin.name);
221
        }
232
        }
222
        if (TextUtils.isEmpty(place.getUpdate_user()) || place.getCreate_user().equalsIgnoreCase("null")) {
223
            place.setUpdate_user("无管理员");
233
        if (TextUtils.isEmpty(place.getUpdate_user())) {
234
            place.setUpdate_user(admin.name);
224
        }
235
        }
225
        setQue(place);
236
        setQue(place);
226
        repository.save(place);
237
        repository.save(place);
240
    public void update(Place newPlace) {
251
    public void update(Place newPlace) {
241
        Optional<Place> byId = repository.findById(newPlace.getUuid());
252
        Optional<Place> byId = repository.findById(newPlace.getUuid());
242
        Place oldPlace = byId.get();
253
        Place oldPlace = byId.get();
254
        Admin admin = Admin.getAdminByToken(token);
255
        newPlace.setUpdate_user(admin.name);
243
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
256
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
244
        repository.save(newPlace);
257
        repository.save(newPlace);
245
    }
258
    }
269
    }
282
    }
270
283
271
    @Override
284
    @Override
272
    public void verify(String uuid, int state, String suggest) {
285
    public void verifyOne(String uuid, String suggest) {
273
        Optional<Place> byId = repository.findById(uuid);
286
        Optional<Place> byId = repository.findById(uuid);
274
        Place oldPlace = byId.get();
287
        Place oldPlace = byId.get();
275
288
289
        Admin admin = Admin.getAdminByToken(token);
276
        Place newPlace = new Place();
290
        Place newPlace = new Place();
277
        newPlace.setState(state);
291
        newPlace.setCurr_id(admin.my_unit_id);
278
292
279
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
293
        UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
280
        repository.save(newPlace);
294
        repository.save(newPlace);
281
    }
295
    }
282
296
297
    private boolean cannot(Place oldPlace, Admin admin) {
298
        String[] que = oldPlace.getQueue().split(",");
299
        ArrayList<String> ids = new ArrayList();
300
        for (String id : que) {
301
            ids.add(id);
302
        }
303
        int i = ids.indexOf(oldPlace.getCurr_id());
304
        int j = ids.indexOf(admin.my_unit_id);
305
        if (i < j) {
306
            return false;
307
        }
308
        return true;
309
    }
310
311
    @Override
312
    public void batchVerify(List<String> ids) {
313
        Admin admin = Admin.getAdminByToken(token);
314
        List<Place> oldAll = repository.getAllByIds(ids);
315
        List<Place> newAll = new ArrayList<>();
316
        for (Place oldPlace : oldAll) {
317
            if (cannot(oldPlace, admin)) {
318
                continue;
319
            }
320
            Place newPlace = new Place();
321
            newPlace.setCurr_id(admin.my_unit_id);
322
            UpdateObjectTool.copyNullProperties(oldPlace, newPlace);
323
            newAll.add(newPlace);
324
        }
325
        repository.saveAll(newAll);
326
    }
327
283
    @Autowired
328
    @Autowired
284
    IExamRepository examRepository;
329
    IExamRepository examRepository;
285
330

+ 2 - 2
oa-app/src/main/java/com/css/oa/exam/room/controller/RoomController.java

1
package com.css.oa.exam.room.controller;
1
package com.css.oa.exam.room.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.place.bean.VerifyReq;
4
import com.css.oa.exam.place.bean.VerifyOneReq;
5
import com.css.oa.exam.room.bean.RoomQueryReq;
5
import com.css.oa.exam.room.bean.RoomQueryReq;
6
import com.css.oa.exam.room.repository.Room;
6
import com.css.oa.exam.room.repository.Room;
7
import com.css.oa.exam.room.service.RoomService;
7
import com.css.oa.exam.room.service.RoomService;
59
59
60
    @ApiOperation(value = "审核")
60
    @ApiOperation(value = "审核")
61
    @PostMapping("/verify")
61
    @PostMapping("/verify")
62
    public Result verify(@RequestBody VerifyReq req) {
62
    public Result verify(@RequestBody VerifyOneReq req) {
63
        Result<Map> result;
63
        Result<Map> result;
64
        try {
64
        try {
65
            if(TextUtils.isEmpty(req.uuid)){
65
            if(TextUtils.isEmpty(req.uuid)){

+ 11 - 8
oa-app/src/main/java/com/css/oa/exam/subject/service/SubjectService.java

61
        if (obj.getUpdate_time() == null) {
61
        if (obj.getUpdate_time() == null) {
62
            obj.setUpdate_time(newDate);
62
            obj.setUpdate_time(newDate);
63
        }
63
        }
64
        if (TextUtils.isEmpty(obj.getCreate_user()) || obj.getCreate_user().equalsIgnoreCase("null")) {
65
            obj.setCreate_user("系统");
64
        Admin admin = Admin.getAdminByToken(token);
65
        if (TextUtils.isEmpty(obj.getCreate_user())) {
66
            obj.setCreate_user(admin.name);
66
        }
67
        }
67
        if (TextUtils.isEmpty(obj.getUpdate_user()) || obj.getCreate_user().equalsIgnoreCase("null")) {
68
            obj.setUpdate_user("系统");
68
        if (TextUtils.isEmpty(obj.getUpdate_user())) {
69
            obj.setUpdate_user(admin.name);
69
        }
70
        }
70
        repository.save(obj);
71
        repository.save(obj);
71
    }
72
    }
114
    }
115
    }
115
116
116
    @Override
117
    @Override
117
    public void update(Subject newTest) throws Exception {
118
    public void update(Subject newObj) throws Exception {
118
        checkPermission("管理员所在的单位没有编辑科目的权限");
119
        checkPermission("管理员所在的单位没有编辑科目的权限");
119
        Optional<Subject> byId = repository.findById(newTest.getUuid());
120
        Optional<Subject> byId = repository.findById(newObj.getUuid());
120
        Subject old = byId.get();
121
        Subject old = byId.get();
121
        UpdateObjectTool.copyNullProperties(old, newTest);
122
        repository.save(newTest);
122
        Admin admin = Admin.getAdminByToken(token);
123
        newObj.setUpdate_user(admin.name);
124
        UpdateObjectTool.copyNullProperties(old, newObj);
125
        repository.save(newObj);
123
    }
126
    }
124
127
125
    @Override
128
    @Override