Browse Source

格式化了一下代码

bfzgs 2 years ago
parent
commit
2a646ed3e2
18 changed files with 277 additions and 311 deletions
  1. 2 1
      final-device/src/main/java/org/brynhild/graduation/device/controller/StudentController.groovy
  2. 0 1
      final-device/src/main/java/org/brynhild/graduation/device/service/impl/DeviceServiceImpl.groovy
  3. 2 1
      final-device/src/main/java/org/brynhild/graduation/device/service/impl/StudentServiceImpl.groovy
  4. 5 5
      final-device/src/main/java/org/brynhild/graduation/device/task/PrimaryPusher.groovy
  5. 2 2
      final-gateway/src/main/java/org/brynhild/graduation/gateway/rule/config/AuthorityMap.groovy
  6. 3 2
      final-persistence/src/main/java/org/brynhild/graduation/persistence/device/repository/SignInRecordRepository.groovy
  7. 20 23
      final-persistence/src/main/java/org/brynhild/graduation/persistence/timetable/entity/TimeTable.java
  8. 16 16
      final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/CommonController.java
  9. 2 2
      final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/StudentController.java
  10. 8 8
      final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/TeacherController.groovy
  11. 99 110
      final-timetable/src/main/java/org/brynhild/graduation/timetable/executor/WordExecutor.groovy
  12. 1 8
      final-timetable/src/main/java/org/brynhild/graduation/timetable/service/ITimeTableService.groovy
  13. 106 116
      final-timetable/src/main/java/org/brynhild/graduation/timetable/service/impl/TimeTableServiceImpl.groovy
  14. 3 6
      final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/ClassStatisticInfo.java
  15. 3 4
      final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/CourseStatisticInfo.java
  16. 3 4
      final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/StudentStatisticInfo.java
  17. 1 1
      final-transfer/src/main/java/org/brynhild/graduation/transfer/view/ViewConvertor.groovy
  18. 1 1
      final-user/src/main/java/org/brynhild/graduation/user/service/impl/TeacherServiceImpl.groovy

+ 2 - 1
final-device/src/main/java/org/brynhild/graduation/device/controller/StudentController.groovy

@@ -3,7 +3,6 @@ package org.brynhild.graduation.device.controller
 import jakarta.annotation.Resource
 import org.brynhild.graduation.common.transfer.dto.Result
 import org.brynhild.graduation.common.utils.RequestBodyVerifier
-import org.brynhild.graduation.device.service.IAdminService
 import org.brynhild.graduation.device.service.IStudentService
 import org.brynhild.graduation.transfer.device.vo.QuerySignInRecordRequest
 import org.springframework.beans.factory.annotation.Autowired
@@ -27,11 +26,13 @@ class StudentController {
         }
         return studentService.findSignInRecord(request)
     }
+
     @Autowired
     @Resource
     void setStudentService(IStudentService studentService) {
         this.studentService = studentService
     }
+
     @Autowired
     @Resource
     void setVerifier(RequestBodyVerifier verifier) {

+ 0 - 1
final-device/src/main/java/org/brynhild/graduation/device/service/impl/DeviceServiceImpl.groovy

@@ -96,7 +96,6 @@ class DeviceServiceImpl implements IDeviceService {
     }
 
 
-
     @Autowired
     @Resource
     void setDeviceRepository(DeviceRepository deviceRepository) {

+ 2 - 1
final-device/src/main/java/org/brynhild/graduation/device/service/impl/StudentServiceImpl.groovy

@@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Component
 
 @Component
-class StudentServiceImpl implements IStudentService{
+class StudentServiceImpl implements IStudentService {
     private SpecificationFactory specificationFactory
     private SignInRecordRepository signInRecordRepository
 
@@ -26,6 +26,7 @@ class StudentServiceImpl implements IStudentService{
     void setSpecificationFactory(SpecificationFactory specificationFactory) {
         this.specificationFactory = specificationFactory
     }
+
     @Autowired
     @Resource
     void setSignInRecordRepository(SignInRecordRepository signInRecordRepository) {

+ 5 - 5
final-device/src/main/java/org/brynhild/graduation/device/task/PrimaryPusher.groovy

@@ -43,7 +43,7 @@ class PrimaryPusher {
         Map<Long, List<List<TimeTable>>> secondaryGatewayMapping = new HashMap<>()
         for (mapping in terminalMapping) {
             def master = mapping.device.getMaster()
-            if(master==null){
+            if (master == null) {
                 continue
             }
             def optional = deviceRepository.findById(master)
@@ -84,14 +84,14 @@ class PrimaryPusher {
 
             for (table in timetableList) {
                 def timeTableBinaries = viewConvertor.convertToTimetableBinary(table)
-                boolean finished=true
+                boolean finished = true
                 for (binary in timeTableBinaries) {
                     def toDevice = handler.sendMessageToDevice(device.getMac(), binary.convertToBytes())
-                    if(!toDevice){
-                        finished=toDevice
+                    if (!toDevice) {
+                        finished = toDevice
                     }
                 }
-                if(finished){
+                if (finished) {
                     table.setPushed(true)
                     tableRepository.save(table)
                 }

+ 2 - 2
final-gateway/src/main/java/org/brynhild/graduation/gateway/rule/config/AuthorityMap.groovy

@@ -14,8 +14,8 @@ class AuthorityMap {
     private final Map<String, List<Integer>> authorityMap = new HashMap<String, List<Integer>>() {
         {
             put("/admin", Arrays.asList(AccountConstant.ADMIN))
-            put("/student",Arrays.asList(AccountConstant.USER))
-            put("/teacher",Arrays.asList(AccountConstant.TEACHER))
+            put("/student", Arrays.asList(AccountConstant.USER))
+            put("/teacher", Arrays.asList(AccountConstant.TEACHER))
 //        put("/system",AccountConstant.SYSTEM)
         }
     }

+ 3 - 2
final-persistence/src/main/java/org/brynhild/graduation/persistence/device/repository/SignInRecordRepository.groovy

@@ -9,7 +9,8 @@ interface SignInRecordRepository extends LogicDeleteRepository<SignInRecord> {
 
     List<SignInRecord> findSignInRecordByUserId(Long userId);
 
-    List<SignInRecord> findSignInRecordByTimeBetweenAndAreaId(String startTime,String endTime,Long areaId)
-    List<SignInRecord> findSignInRecordByTimeBetweenAndAreaIdAndUserId(String startTime,String endTime,Long areaId,Long userId)
+    List<SignInRecord> findSignInRecordByTimeBetweenAndAreaId(String startTime, String endTime, Long areaId)
+
+    List<SignInRecord> findSignInRecordByTimeBetweenAndAreaIdAndUserId(String startTime, String endTime, Long areaId, Long userId)
 
 }

+ 20 - 23
final-persistence/src/main/java/org/brynhild/graduation/persistence/timetable/entity/TimeTable.java

@@ -24,6 +24,10 @@ import java.util.List;
 @Where(clause = CommonDBStringDefinition.LOGIC_DELETE_WHERE_CLAUSE)
 @NoArgsConstructor
 public class TimeTable extends LogicDeleteEntity implements Serializable {
+    private static List<String> startSignInTime = Arrays.asList("07:50:00", "08:45:00", "10:00:00", "10:55:00", "13:50:00", "14:45:00", "16:00:00", "16:55:00", "18:50:00", "19:45:00", "20:40:00");
+    private static List<String> endSignInTime = Arrays.asList("08:10:00", "09:05:00", "10:20:00", "11:15:00", "14:10:00", "15:05:00", "16:20:00", "17:15:00", "19:10:00", "20:05:00", "21:00:00");
+    private static List<String> startSignOutTime = Arrays.asList("08:35:00", "09:30:00", "10:45:00", "11:40:00", "14:35:00", "15:30:00", "16:45:00", "17:40:00", "19:35:00", "20:30:00", "21:35:00");
+    private static List<String> endSignOutTime = Arrays.asList("08:55:00", "09:50:00", "11:05:00", "12:00:00", "14:55:00", "15:50:00", "17:05:00", "18:00:00", "19:55:00", "20:50:00", "21:55:00");
     @LogFieldDescription("区域id")
     @Column(name = "area_id")
     private Long areaId;
@@ -49,46 +53,39 @@ public class TimeTable extends LogicDeleteEntity implements Serializable {
     private Integer year;
     @LogFieldDescription("学期")
     private Integer term;
-
     @LogFieldDescription("是否推送")
     private Boolean pushed = false;
 
-    private static List<String> startSignInTime = Arrays.asList("07:50:00", "08:45:00", "10:00:00", "10:55:00", "13:50:00", "14:45:00", "16:00:00", "16:55:00", "18:50:00", "19:45:00", "20:40:00");
-    private static List<String> endSignInTime = Arrays.asList("08:10:00", "09:05:00", "10:20:00", "11:15:00", "14:10:00", "15:05:00", "16:20:00", "17:15:00", "19:10:00", "20:05:00", "21:00:00");
-
-    private static List<String> startSignOutTime = Arrays.asList("08:35:00", "09:30:00", "10:45:00", "11:40:00", "14:35:00", "15:30:00", "16:45:00", "17:40:00", "19:35:00", "20:30:00", "21:35:00");
-    private static List<String> endSignOutTime = Arrays.asList("08:55:00", "09:50:00", "11:05:00", "12:00:00", "14:55:00", "15:50:00", "17:05:00", "18:00:00", "19:55:00", "20:50:00", "21:55:00");
-
-    public String getStartSignInTime(){
+    public String getStartSignInTime() {
         LocalDate start = LocalDate.of(2023, 2, 20);
-        start=start.plusWeeks(Long.parseLong(week)-1);
-        start=start.plusDays(day.longValue()-1);
+        start = start.plusWeeks(Long.parseLong(week) - 1);
+        start = start.plusDays(day.longValue() - 1);
         String date = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-        return date+" "+ startSignInTime.get(index-1);
+        return date + " " + startSignInTime.get(index - 1);
     }
 
-    public String getEndSignInTime(){
+    public String getEndSignInTime() {
         LocalDate start = LocalDate.of(2023, 2, 20);
-        start=start.plusWeeks(Long.parseLong(week)-1);
-        start=start.plusDays(day.longValue()-1);
+        start = start.plusWeeks(Long.parseLong(week) - 1);
+        start = start.plusDays(day.longValue() - 1);
         String date = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-        return date+" "+ endSignInTime.get(index-1);
+        return date + " " + endSignInTime.get(index - 1);
     }
 
-    public String getStartSignOutTime(){
+    public String getStartSignOutTime() {
         LocalDate start = LocalDate.of(2023, 2, 20);
-        start=start.plusWeeks(Long.parseLong(week)-1);
-        start=start.plusDays(day.longValue()-1);
+        start = start.plusWeeks(Long.parseLong(week) - 1);
+        start = start.plusDays(day.longValue() - 1);
         String date = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-        return date+" "+ startSignOutTime.get(index+step-2);
+        return date + " " + startSignOutTime.get(index + step - 2);
     }
 
-    public String getEndSignOutTime(){
+    public String getEndSignOutTime() {
         LocalDate start = LocalDate.of(2023, 2, 20);
-        start=start.plusWeeks(Long.parseLong(week)-1);
-        start=start.plusDays(day.longValue()-1);
+        start = start.plusWeeks(Long.parseLong(week) - 1);
+        start = start.plusDays(day.longValue() - 1);
         String date = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-        return date+" "+ endSignOutTime.get(index+step-2);
+        return date + " " + endSignOutTime.get(index + step - 2);
     }
 }
 

+ 16 - 16
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/CommonController.java

@@ -38,52 +38,52 @@ public class CommonController {
 
     @PostMapping("/statistic/class")
     public Result queryClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info, BindingResult result,
-                                      @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+                                      @RequestHeader(AccountConstant.ACCOUNT_HEADER) String token) {
         if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
-        return tableService.queryClassStatistic(info,token);
+        return tableService.queryClassStatistic(info, token);
     }
 
     @PostMapping("/statistic/student")
     public Result queryStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info, BindingResult result,
-                                        @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+                                        @RequestHeader(AccountConstant.ACCOUNT_HEADER) String token) {
         if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
-        return tableService.queryStudentStatistic(info,token);
+        return tableService.queryStudentStatistic(info, token);
     }
 
     @GetMapping("/statistic/class")
-    public Result queryClassStatisticPublic(){
-        AdminQueryClassStatistic info=new AdminQueryClassStatistic();
+    public Result queryClassStatisticPublic() {
+        AdminQueryClassStatistic info = new AdminQueryClassStatistic();
         info.setId(2L);
-        return tableService.queryClassStatistic(info,"");
+        return tableService.queryClassStatistic(info, "");
     }
 
     @GetMapping("/statistic/student")
-    public Result queryStudentStatisticPublic(){
-        AdminQueryStudentStatistic info=new AdminQueryStudentStatistic();
+    public Result queryStudentStatisticPublic() {
+        AdminQueryStudentStatistic info = new AdminQueryStudentStatistic();
         info.setId(3L);
-        return tableService.queryStudentStatistic(info,"");
+        return tableService.queryStudentStatistic(info, "");
     }
 
 
     @PostMapping("/statistic/class/generate")
-    public Result generateClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info,BindingResult result,
-                                         @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+    public Result generateClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info, BindingResult result,
+                                         @RequestHeader(AccountConstant.ACCOUNT_HEADER) String token) {
         if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
-        return tableService.generateClassStatistic(info,token);
+        return tableService.generateClassStatistic(info, token);
     }
 
     @PostMapping("/statistic/student/generate")
-    public Result generateStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info,BindingResult result,
-                                           @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+    public Result generateStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info, BindingResult result,
+                                           @RequestHeader(AccountConstant.ACCOUNT_HEADER) String token) {
         if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
-        return tableService.generateStudentStatistic(info,token);
+        return tableService.generateStudentStatistic(info, token);
     }
 }

+ 2 - 2
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/StudentController.java

@@ -20,8 +20,8 @@ public class StudentController {
     private final ITimeTableService tableService;
 
     @PostMapping("/timetable")
-    public Result queryStudentTimetable(@RequestBody @Validated QueryTimeTableRequest request, BindingResult result){
-        if(result.hasErrors()){
+    public Result queryStudentTimetable(@RequestBody @Validated QueryTimeTableRequest request, BindingResult result) {
+        if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
         return tableService.findTimeTable(request);

+ 8 - 8
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/TeacherController.groovy

@@ -22,32 +22,32 @@ class TeacherController {
     private ITimeTableService tableService
 
     @PostMapping("/timetable")
-    Result queryStudentTimetable(@RequestBody @Validated QueryTimeTableRequest request, BindingResult result){
-        if(result.hasErrors()){
+    Result queryStudentTimetable(@RequestBody @Validated QueryTimeTableRequest request, BindingResult result) {
+        if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
         return tableService.findTimeTable(request);
     }
 
     @PostMapping("/clazz")
-    Result queryTeachingClass(@RequestBody @Validated QueryTeachingClassRequest request,BindingResult result){
-        if(result.hasErrors()){
+    Result queryTeachingClass(@RequestBody @Validated QueryTeachingClassRequest request, BindingResult result) {
+        if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
         return tableService.queryTeachingClass(request)
     }
 
     @PostMapping("/statistic")
-    Result queryTeachingCourseStatistic(@RequestBody @Validated QueryTeachingCourseStatisticRequest request,BindingResult result){
-        if(result.hasErrors()){
+    Result queryTeachingCourseStatistic(@RequestBody @Validated QueryTeachingCourseStatisticRequest request, BindingResult result) {
+        if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
         return tableService.queryTeachingCourseStatistic(request)
     }
 
     @PostMapping("/statistic/generate")
-    Result generateTeachingCourseStatistic(@RequestBody @Validated QueryTeachingCourseStatisticRequest request,BindingResult result){
-        if(result.hasErrors()){
+    Result generateTeachingCourseStatistic(@RequestBody @Validated QueryTeachingCourseStatisticRequest request, BindingResult result) {
+        if (result.hasErrors()) {
             return verifier.convertToErrors(result);
         }
         return tableService.generateTeachingCourseStatistic(request)

+ 99 - 110
final-timetable/src/main/java/org/brynhild/graduation/timetable/executor/WordExecutor.groovy

@@ -2,23 +2,13 @@ package org.brynhild.graduation.timetable.executor
 
 import jakarta.annotation.Resource
 import org.apache.poi.POIXMLDocument
-import org.apache.poi.xwpf.usermodel.XWPFDocument
-import org.apache.poi.xwpf.usermodel.XWPFParagraph
-import org.apache.poi.xwpf.usermodel.XWPFRun
-import org.apache.poi.xwpf.usermodel.XWPFTable
-import org.apache.poi.xwpf.usermodel.XWPFTableCell
+import org.apache.poi.xwpf.usermodel.*
 import org.brynhild.graduation.common.constant.CourseConstant
 import org.brynhild.graduation.persistence.timetable.entity.Course
 import org.brynhild.graduation.transfer.timetable.bo.ClassStatisticInfo
 import org.brynhild.graduation.transfer.timetable.bo.CourseStatisticInfo
 import org.brynhild.graduation.transfer.timetable.bo.StudentStatisticInfo
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalJc
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.*
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Component
 
@@ -33,176 +23,175 @@ class WordExecutor {
     }
 
     static void main(String[] args) {
-        def course= new Course()
+        def course = new Course()
         course.with {
-            id=1L
-            deleteAt=null
-            name="134141"
-            credit=4
-            department=2
-            type=1
-            period=20
+            id = 1L
+            deleteAt = null
+            name = "134141"
+            credit = 4
+            department = 2
+            type = 1
+            period = 20
         }
-        def classData=new ClassStatisticInfo()
+        def classData = new ClassStatisticInfo()
         classData.with {
-            it.course=course
-            count=10
-            actualCount=1
-            rate=0.1
+            it.course = course
+            count = 10
+            actualCount = 1
+            rate = 0.1
         }
         println classData
 
-        def list=new ArrayList<ClassStatisticInfo>()
+        def list = new ArrayList<ClassStatisticInfo>()
         list.add(classData)
 
-        def replaceMap=new HashMap<String,String>()
-        replaceMap.put("title","测试班级")
+        def replaceMap = new HashMap<String, String>()
+        replaceMap.put("title", "测试班级")
 
-        generateClassStatisticReport("docOutput/测试.docx",list,replaceMap)
+        generateClassStatisticReport("docOutput/测试.docx", list, replaceMap)
     }
 
-    private static final String CLASS_STATISTIC_TEMPLATE="docTemplate/class.docx"
+    private static final String CLASS_STATISTIC_TEMPLATE = "docTemplate/class.docx"
 
-    static void generateClassStatisticReport(String outputFilename,List<ClassStatisticInfo> infoList,Map<String,String> replaceMap){
-        XWPFDocument document=new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
-        if(replaceMap!=null){
-            replaceMarkedText(document,replaceMap)
+    static void generateClassStatisticReport(String outputFilename, List<ClassStatisticInfo> infoList, Map<String, String> replaceMap) {
+        XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
+        if (replaceMap != null) {
+            replaceMarkedText(document, replaceMap)
         }
         def tables = document.getTables()
-        def table=tables[0]
+        def table = tables[0]
         initForm(table)
-        int firstIndex=table.getRows().size()
-        for(int i=0;i<infoList.size();i++){
+        int firstIndex = table.getRows().size()
+        for (int i = 0; i < infoList.size(); i++) {
             table.createRow()
         }
-        for(int i=0;i<infoList.size();i++){
+        for (int i = 0; i < infoList.size(); i++) {
             def cells = table.getRow(firstIndex + i).getTableCells()
-            cells[0].text="${infoList[i].course.id}"
-            cells[1].text=infoList[i].course.name
-            if(infoList[i].course.type== CourseConstant.COMPULSORY){
-                cells[2].text="必修"
-            }else{
-                cells[2].text="选修"
+            cells[0].text = "${infoList[i].course.id}"
+            cells[1].text = infoList[i].course.name
+            if (infoList[i].course.type == CourseConstant.COMPULSORY) {
+                cells[2].text = "必修"
+            } else {
+                cells[2].text = "选修"
             }
-            cells[3].text="${infoList[i].course.credit}"
-            cells[4].text="${infoList[i].count}"
-            cells[5].text="${infoList[i].actualCount}"
-            cells[6].text="${infoList[i].rate*100}%"
-            for(cell in cells){
+            cells[3].text = "${infoList[i].course.credit}"
+            cells[4].text = "${infoList[i].count}"
+            cells[5].text = "${infoList[i].actualCount}"
+            cells[6].text = "${infoList[i].rate * 100}%"
+            for (cell in cells) {
                 setCellCenter(cell)
             }
         }
-        File file=new File(outputFilename)
-        FileOutputStream fos=new FileOutputStream(file)
+        File file = new File(outputFilename)
+        FileOutputStream fos = new FileOutputStream(file)
         document.write(fos)
         fos.close()
     }
 
-    static void generateStudentStatisticReport(String outputFilename,List<StudentStatisticInfo> infoList, Map<String,String> replaceMap){
-        XWPFDocument document=new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
-        if(replaceMap!=null){
-            replaceMarkedText(document,replaceMap)
+    static void generateStudentStatisticReport(String outputFilename, List<StudentStatisticInfo> infoList, Map<String, String> replaceMap) {
+        XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
+        if (replaceMap != null) {
+            replaceMarkedText(document, replaceMap)
         }
         def tables = document.getTables()
-        def table=tables[0]
+        def table = tables[0]
         initForm(table)
-        int firstIndex=table.getRows().size()
-        for(int i=0;i<infoList.size();i++){
+        int firstIndex = table.getRows().size()
+        for (int i = 0; i < infoList.size(); i++) {
             table.createRow()
         }
-        for(int i=0;i<infoList.size();i++){
+        for (int i = 0; i < infoList.size(); i++) {
             def cells = table.getRow(firstIndex + i).getTableCells()
-            cells[0].text="${infoList[i].course.id}"
-            cells[1].text=infoList[i].course.name
-            if(infoList[i].course.type== CourseConstant.COMPULSORY){
-                cells[2].text="必修"
-            }else{
-                cells[2].text="选修"
+            cells[0].text = "${infoList[i].course.id}"
+            cells[1].text = infoList[i].course.name
+            if (infoList[i].course.type == CourseConstant.COMPULSORY) {
+                cells[2].text = "必修"
+            } else {
+                cells[2].text = "选修"
             }
-            cells[3].text="${infoList[i].course.credit}"
-            cells[4].text="${infoList[i].count}"
-            cells[5].text="${infoList[i].actualCount}"
-            cells[6].text="${infoList[i].rate*100}%"
-            for(cell in cells){
+            cells[3].text = "${infoList[i].course.credit}"
+            cells[4].text = "${infoList[i].count}"
+            cells[5].text = "${infoList[i].actualCount}"
+            cells[6].text = "${infoList[i].rate * 100}%"
+            for (cell in cells) {
                 setCellCenter(cell)
             }
         }
-        File file=new File(outputFilename)
-        FileOutputStream fos=new FileOutputStream(file)
+        File file = new File(outputFilename)
+        FileOutputStream fos = new FileOutputStream(file)
         document.write(fos)
         fos.close()
     }
 
-    static void generateTeachingCourseStatisticReport(String outputFilename, List<CourseStatisticInfo> infoList, Map<String,String> replaceMap){
-        XWPFDocument document=new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
-        if(replaceMap!=null){
-            replaceMarkedText(document,replaceMap)
+    static void generateTeachingCourseStatisticReport(String outputFilename, List<CourseStatisticInfo> infoList, Map<String, String> replaceMap) {
+        XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(CLASS_STATISTIC_TEMPLATE))
+        if (replaceMap != null) {
+            replaceMarkedText(document, replaceMap)
         }
         def tables = document.getTables()
-        def table=tables[0]
+        def table = tables[0]
         initForm(table)
-        int firstIndex=table.getRows().size()
-        for(int i=0;i<infoList.size();i++){
+        int firstIndex = table.getRows().size()
+        for (int i = 0; i < infoList.size(); i++) {
             table.createRow()
         }
-        for(int i=0;i<infoList.size();i++){
+        for (int i = 0; i < infoList.size(); i++) {
             def cells = table.getRow(firstIndex + i).getTableCells()
-            cells[0].text="${infoList[i].course.id}"
-            cells[1].text=infoList[i].course.name
-            if(infoList[i].course.type== CourseConstant.COMPULSORY){
-                cells[2].text="必修"
-            }else{
-                cells[2].text="选修"
+            cells[0].text = "${infoList[i].course.id}"
+            cells[1].text = infoList[i].course.name
+            if (infoList[i].course.type == CourseConstant.COMPULSORY) {
+                cells[2].text = "必修"
+            } else {
+                cells[2].text = "选修"
             }
-            cells[3].text="${infoList[i].course.credit}"
-            cells[4].text="${infoList[i].count}"
-            cells[5].text="${infoList[i].actualCount}"
-            cells[6].text="${infoList[i].rate*100}%"
-            for(cell in cells){
+            cells[3].text = "${infoList[i].course.credit}"
+            cells[4].text = "${infoList[i].count}"
+            cells[5].text = "${infoList[i].actualCount}"
+            cells[6].text = "${infoList[i].rate * 100}%"
+            for (cell in cells) {
                 setCellCenter(cell)
             }
         }
-        File file=new File(outputFilename)
-        FileOutputStream fos=new FileOutputStream(file)
+        File file = new File(outputFilename)
+        FileOutputStream fos = new FileOutputStream(file)
         document.write(fos)
         fos.close()
     }
 
 
-
-    private static void replaceMarkedText(XWPFDocument document,Map<String,String> replaceMap){
-        List<XWPFParagraph> paragraphs= document.getParagraphs();
-        for(XWPFParagraph paragraph:paragraphs){
-            String text=paragraph.getText();
-            if(text.contains("\$")){
-                List<XWPFRun> runs=paragraph.getRuns()
-                for(XWPFRun run:runs){
-                    run.setText(replaceText(run.toString(),replaceMap),0);
+    private static void replaceMarkedText(XWPFDocument document, Map<String, String> replaceMap) {
+        List<XWPFParagraph> paragraphs = document.getParagraphs();
+        for (XWPFParagraph paragraph : paragraphs) {
+            String text = paragraph.getText();
+            if (text.contains("\$")) {
+                List<XWPFRun> runs = paragraph.getRuns()
+                for (XWPFRun run : runs) {
+                    run.setText(replaceText(run.toString(), replaceMap), 0);
                 }
             }
         }
     }
 
-    private static String replaceText(String value,Map<String,String> replaceMap){
+    private static String replaceText(String value, Map<String, String> replaceMap) {
         println value
         def keySet = replaceMap.keySet()
-        for(key in keySet){
-            def matchKey="\${${key}}"
-            if(value.indexOf(matchKey)!=-1){
+        for (key in keySet) {
+            def matchKey = "\${${key}}"
+            if (value.indexOf(matchKey) != -1) {
                 return replaceMap[key]
             }
         }
         return value
     }
 
-    private static void setCellCenter(XWPFTableCell cell){
-        CTTc cttc=cell.getCTTc();
-        CTTcPr ctpr=cttc.addNewTcPr();
+    private static void setCellCenter(XWPFTableCell cell) {
+        CTTc cttc = cell.getCTTc();
+        CTTcPr ctpr = cttc.addNewTcPr();
         ctpr.addNewVAlign().setVal(STVerticalJc.CENTER);
         cttc.getPList().get(0).addNewPPr().addNewJc().setVal(STJc.CENTER);
     }
 
-    private static void initForm(XWPFTable table){
+    private static void initForm(XWPFTable table) {
         CTTblBorders borders = table.getCTTbl().getTblPr().addNewTblBorders();
         CTBorder hBorder = borders.addNewInsideH();
         hBorder.setVal(STBorder.Enum.forString("single"));  // 线条类型

+ 1 - 8
final-timetable/src/main/java/org/brynhild/graduation/timetable/service/ITimeTableService.groovy

@@ -1,14 +1,7 @@
 package org.brynhild.graduation.timetable.service
 
 import org.brynhild.graduation.common.transfer.dto.Result
-import org.brynhild.graduation.transfer.timetable.vo.AdminAddTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminDeleteTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminModifyTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic
-import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic
-import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
-import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingCourseStatisticRequest
-import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
+import org.brynhild.graduation.transfer.timetable.vo.*
 
 interface ITimeTableService {
 

+ 106 - 116
final-timetable/src/main/java/org/brynhild/graduation/timetable/service/impl/TimeTableServiceImpl.groovy

@@ -4,7 +4,6 @@ import jakarta.annotation.Resource
 import org.brynhild.graduation.common.constant.AccountConstant
 import org.brynhild.graduation.common.transfer.dto.Result
 import org.brynhild.graduation.common.utils.JwtUtil
-import org.brynhild.graduation.persistence.device.entity.SignInRecord
 import org.brynhild.graduation.persistence.device.repository.AreaRepository
 import org.brynhild.graduation.persistence.device.repository.SignInRecordRepository
 import org.brynhild.graduation.persistence.file.entity.LocalFile
@@ -13,8 +12,6 @@ import org.brynhild.graduation.persistence.timetable.entity.Course
 import org.brynhild.graduation.persistence.timetable.entity.TimeTable
 import org.brynhild.graduation.persistence.timetable.repository.CourseRepository
 import org.brynhild.graduation.persistence.timetable.repository.TimeTableRepository
-import org.brynhild.graduation.persistence.user.entity.Class
-import org.brynhild.graduation.persistence.user.entity.User
 import org.brynhild.graduation.persistence.user.repository.ClassRepository
 import org.brynhild.graduation.persistence.user.repository.UserRepository
 import org.brynhild.graduation.timetable.config.CosConfig
@@ -28,14 +25,7 @@ import org.brynhild.graduation.transfer.file.dto.FileInfo
 import org.brynhild.graduation.transfer.timetable.bo.ClassStatisticInfo
 import org.brynhild.graduation.transfer.timetable.bo.CourseStatisticInfo
 import org.brynhild.graduation.transfer.timetable.bo.StudentStatisticInfo
-import org.brynhild.graduation.transfer.timetable.vo.AdminAddTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminDeleteTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminModifyTimeTable
-import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic
-import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic
-import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
-import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingCourseStatisticRequest
-import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
+import org.brynhild.graduation.transfer.timetable.vo.*
 import org.brynhild.graduation.transfer.view.ViewConvertor
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Service
@@ -144,161 +134,161 @@ class TimeTableServiceImpl implements ITimeTableService {
 
     @Override
     Result queryClassStatistic(AdminQueryClassStatistic info, String token) {
-        def result=getClassStatistic(info)
-        return new Result(true,"查询成功",result)
+        def result = getClassStatistic(info)
+        return new Result(true, "查询成功", result)
     }
 
-    private List<ClassStatisticInfo> getClassStatistic(AdminQueryClassStatistic info){
+    private List<ClassStatisticInfo> getClassStatistic(AdminQueryClassStatistic info) {
         def timeTableByClass = tableRepository.findTimeTableByClazz("${info.id}")
-        def courseMap=new HashMap<Long, Course>()
-        def countMap=new HashMap<Long,Long>()
-        def actualCountMap=new HashMap<Long,Long>()
+        def courseMap = new HashMap<Long, Course>()
+        def countMap = new HashMap<Long, Long>()
+        def actualCountMap = new HashMap<Long, Long>()
 
         def courseIdSet = timeTableByClass.stream().map { it.courseId }.collect(Collectors.toSet())
-        for(courseId in courseIdSet){
-            courseRepository.findById(courseId).ifPresent {courseMap.put(courseId,it)}
+        for (courseId in courseIdSet) {
+            courseRepository.findById(courseId).ifPresent { courseMap.put(courseId, it) }
         }
         timeTableByClass.stream().forEachOrdered {
-            countMap.computeIfAbsent(it.courseId,i->0L)
-            countMap.put(it.courseId,countMap.get(it.courseId)+1L)
+            countMap.computeIfAbsent(it.courseId, i -> 0L)
+            countMap.put(it.courseId, countMap.get(it.courseId) + 1L)
         }
 
         def listOfUsers = userRepository.findUserByDepartmentId(info.id)
-        def userCount=listOfUsers.size()
-        List<ClassStatisticInfo> infoList=new ArrayList<>()
+        def userCount = listOfUsers.size()
+        List<ClassStatisticInfo> infoList = new ArrayList<>()
 
         println "${listOfUsers.size()},${courseIdSet.size()}"
 
-        for(timetable in timeTableByClass){
-            def startSignInTime=timetable.getStartSignInTime()
+        for (timetable in timeTableByClass) {
+            def startSignInTime = timetable.getStartSignInTime()
             def endSignInTime = timetable.getEndSignInTime()
 
-            def startSignOutTime=timetable.getStartSignOutTime()
-            def endSignOutTime=timetable.getEndSignOutTime()
+            def startSignOutTime = timetable.getStartSignOutTime()
+            def endSignOutTime = timetable.getEndSignOutTime()
 
             println "${startSignInTime}----${endSignInTime}"
             println "${startSignOutTime}----${endSignOutTime}"
 
             def listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(startSignInTime, endSignInTime, timetable.areaId)
             def signIn = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
-            listOfRecords=signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(timetable.startSignOutTime,timetable.endSignOutTime,timetable.areaId)
+            listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(timetable.startSignOutTime, timetable.endSignOutTime, timetable.areaId)
             def signOut = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
             signIn.retainAll(signOut)
 
-            actualCountMap.computeIfAbsent(timetable.courseId,i->0L)
-            actualCountMap.put(timetable.courseId,actualCountMap.get(timetable.courseId)+signIn.size())
+            actualCountMap.computeIfAbsent(timetable.courseId, i -> 0L)
+            actualCountMap.put(timetable.courseId, actualCountMap.get(timetable.courseId) + signIn.size())
         }
 
-        for(course in courseMap.values()){
-            infoList.add(new ClassStatisticInfo(course,countMap.get(course.id)*userCount,actualCountMap.get(course.id)))
+        for (course in courseMap.values()) {
+            infoList.add(new ClassStatisticInfo(course, countMap.get(course.id) * userCount, actualCountMap.get(course.id)))
         }
 
-        infoList=infoList.sort()
+        infoList = infoList.sort()
         return infoList
     }
 
 
     @Override
     Result queryStudentStatistic(AdminQueryStudentStatistic info, String token) {
-        def result=getStudentStatistic(info)
-        return new Result(true,"查询成功",result)
+        def result = getStudentStatistic(info)
+        return new Result(true, "查询成功", result)
     }
 
-    private List<StudentStatisticInfo> getStudentStatistic(AdminQueryStudentStatistic info){
+    private List<StudentStatisticInfo> getStudentStatistic(AdminQueryStudentStatistic info) {
         def optional = userRepository.findById(info.id)
-        if(optional.isEmpty()){
+        if (optional.isEmpty()) {
             return new ArrayList<StudentStatisticInfo>()
         }
         def user = optional.get()
         def timeTableByClass = tableRepository.findTimeTableByClazz("${user.departmentId}")
-        def courseMap=new HashMap<Long, Course>()
-        def countMap=new HashMap<Long,Long>()
-        def actualCountMap=new HashMap<Long,Long>()
+        def courseMap = new HashMap<Long, Course>()
+        def countMap = new HashMap<Long, Long>()
+        def actualCountMap = new HashMap<Long, Long>()
 
         def courseIdSet = timeTableByClass.stream().map { it.courseId }.collect(Collectors.toSet())
-        for(courseId in courseIdSet){
-            courseRepository.findById(courseId).ifPresent {courseMap.put(courseId,it)}
+        for (courseId in courseIdSet) {
+            courseRepository.findById(courseId).ifPresent { courseMap.put(courseId, it) }
         }
         timeTableByClass.stream().forEach {
-            countMap.computeIfAbsent(it.courseId,i->0L)
+            countMap.computeIfAbsent(it.courseId, i -> 0L)
 //            countMap.computeIfPresent(it.courseId,i->i+1)
-            countMap.put(it.courseId,countMap.get(it.courseId)+1)
+            countMap.put(it.courseId, countMap.get(it.courseId) + 1)
         }
 
-        List<StudentStatisticInfo> infoList=new ArrayList<>()
+        List<StudentStatisticInfo> infoList = new ArrayList<>()
 
-        for(timetable in timeTableByClass){
-            def startSignInTime=timetable.getStartSignInTime()
+        for (timetable in timeTableByClass) {
+            def startSignInTime = timetable.getStartSignInTime()
             def endSignInTime = timetable.getEndSignInTime()
 
-            def listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaIdAndUserId(startSignInTime, endSignInTime, timetable.areaId,info.id)
-            if(listOfRecords.isEmpty()){
+            def listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaIdAndUserId(startSignInTime, endSignInTime, timetable.areaId, info.id)
+            if (listOfRecords.isEmpty()) {
                 continue
             }
-            listOfRecords=signInRecordRepository.findSignInRecordByTimeBetweenAndAreaIdAndUserId(timetable.startSignOutTime,timetable.endSignOutTime,timetable.areaId,info.id)
-            if(listOfRecords.isEmpty()){
+            listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaIdAndUserId(timetable.startSignOutTime, timetable.endSignOutTime, timetable.areaId, info.id)
+            if (listOfRecords.isEmpty()) {
                 continue
             }
 
-            actualCountMap.computeIfAbsent(timetable.courseId,i->0L)
+            actualCountMap.computeIfAbsent(timetable.courseId, i -> 0L)
 //            actualCountMap.computeIfPresent(timetable.courseId,i->i+signIn.size())
-            actualCountMap.put(timetable.courseId,actualCountMap.get(timetable.courseId)+1)
+            actualCountMap.put(timetable.courseId, actualCountMap.get(timetable.courseId) + 1)
         }
 
-        for(course in courseMap.values()){
-            infoList.add(new StudentStatisticInfo(course,countMap.get(course.id),actualCountMap.getOrDefault(course.id,0L)))
+        for (course in courseMap.values()) {
+            infoList.add(new StudentStatisticInfo(course, countMap.get(course.id), actualCountMap.getOrDefault(course.id, 0L)))
         }
 
-        infoList=infoList.sort()
+        infoList = infoList.sort()
         return infoList
     }
 
     @Override
     Result generateClassStatistic(AdminQueryClassStatistic info, String token) {
         def optional = classRepository.findById(info.id)
-        if(optional.isEmpty()){
-            return new Result(false,"查询失败");
+        if (optional.isEmpty()) {
+            return new Result(false, "查询失败");
         }
-        def result=getClassStatistic(info)
-        def filename="docOutput/class-${info.id}.docx"
-        def map=new HashMap<String,String>()
+        def result = getClassStatistic(info)
+        def filename = "docOutput/class-${info.id}.docx"
+        def map = new HashMap<String, String>()
         def clazz = optional.get()
-        map.put("title",clazz.name)
-        WordExecutor.generateClassStatisticReport(filename,result ,map)
-        def localFile=new LocalFile();
-        localFile.path="class-${info.id}.docx"
-        cosJavaRepository.addUploadFileTaskSync(new File(filename),localFile)
+        map.put("title", clazz.name)
+        WordExecutor.generateClassStatisticReport(filename, result, map)
+        def localFile = new LocalFile();
+        localFile.path = "class-${info.id}.docx"
+        cosJavaRepository.addUploadFileTaskSync(new File(filename), localFile)
 
         FileInfo fileInfo = new FileInfo();
         fileInfo.setPath(config.getRedirectPath() + localFile.getPath());
-        def list=new ArrayList<FileInfo>()
+        def list = new ArrayList<FileInfo>()
         list.add(fileInfo)
 
-        return new Result(true,"生成成功",list)
+        return new Result(true, "生成成功", list)
     }
 
     @Override
     Result generateStudentStatistic(AdminQueryStudentStatistic info, String token) {
         def optional = userRepository.findById(info.id)
-        if(optional.isEmpty()){
-            return new Result(false,"查询失败")
+        if (optional.isEmpty()) {
+            return new Result(false, "查询失败")
         }
         def user = optional.get()
-        def result=getStudentStatistic(info)
-        def filename="docOutput/student-${info.id}.docx"
-        def map=new HashMap<String,String>()
-        map.put("title",user.name)
-        WordExecutor.generateStudentStatisticReport(filename,result,map)
-        def localFile=new LocalFile();
+        def result = getStudentStatistic(info)
+        def filename = "docOutput/student-${info.id}.docx"
+        def map = new HashMap<String, String>()
+        map.put("title", user.name)
+        WordExecutor.generateStudentStatisticReport(filename, result, map)
+        def localFile = new LocalFile();
 
-        localFile.path="student-${info.id}.docx"
-        cosJavaRepository.addUploadFileTaskSync(new File(filename),localFile)
+        localFile.path = "student-${info.id}.docx"
+        cosJavaRepository.addUploadFileTaskSync(new File(filename), localFile)
 
         FileInfo fileInfo = new FileInfo();
         fileInfo.setPath(config.getRedirectPath() + localFile.getPath());
-        def list=new ArrayList<FileInfo>()
+        def list = new ArrayList<FileInfo>()
         list.add(fileInfo)
-        return new Result(true,"生成成功",list)
+        return new Result(true, "生成成功", list)
     }
 
     @Override
@@ -306,84 +296,84 @@ class TimeTableServiceImpl implements ITimeTableService {
         def listOfTables = tableRepository.findTimeTableByTeacher(request.getTeacherId())
         def collect = listOfTables.stream().map { Long.parseLong(it.clazz) }.collect(Collectors.toSet())
         def classes = classRepository.findAllById(collect)
-        return new Result(true,"查询成功",classes)
+        return new Result(true, "查询成功", classes)
     }
 
-    private List<CourseStatisticInfo> getTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request){
+    private List<CourseStatisticInfo> getTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request) {
         def timeTableByClass = tableRepository.findTimeTableByTeacher(request.id)
-        def courseMap=new HashMap<Long, Course>()
-        def countMap=new HashMap<Long,Long>()
-        def actualCountMap=new HashMap<Long,Long>()
+        def courseMap = new HashMap<Long, Course>()
+        def countMap = new HashMap<Long, Long>()
+        def actualCountMap = new HashMap<Long, Long>()
 
         def courseIdSet = timeTableByClass.stream().map { it.courseId }.collect(Collectors.toSet())
-        for(courseId in courseIdSet){
-            courseRepository.findById(courseId).ifPresent {courseMap.put(courseId,it)}
+        for (courseId in courseIdSet) {
+            courseRepository.findById(courseId).ifPresent { courseMap.put(courseId, it) }
         }
         timeTableByClass.stream().forEach {
-            countMap.computeIfAbsent(it.courseId,i->0L)
-            countMap.put(it.courseId,countMap.get(it.courseId)+1)
+            countMap.computeIfAbsent(it.courseId, i -> 0L)
+            countMap.put(it.courseId, countMap.get(it.courseId) + 1)
         }
-        List<CourseStatisticInfo> infoList=new ArrayList<>()
+        List<CourseStatisticInfo> infoList = new ArrayList<>()
 
-        for(timetable in timeTableByClass){
-            def startSignInTime=timetable.getStartSignInTime()
+        for (timetable in timeTableByClass) {
+            def startSignInTime = timetable.getStartSignInTime()
             def endSignInTime = timetable.getEndSignInTime()
 
-            def startSignOutTime=timetable.getStartSignOutTime()
-            def endSignOutTime=timetable.getEndSignOutTime()
+            def startSignOutTime = timetable.getStartSignOutTime()
+            def endSignOutTime = timetable.getEndSignOutTime()
 
             println "${startSignInTime}----${endSignInTime}"
             println "${startSignOutTime}----${endSignOutTime}"
 
             def listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(startSignInTime, endSignInTime, timetable.areaId)
             def signIn = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
-            listOfRecords=signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(timetable.startSignOutTime,timetable.endSignOutTime,timetable.areaId)
+            listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(timetable.startSignOutTime, timetable.endSignOutTime, timetable.areaId)
             def signOut = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
             signIn.retainAll(signOut)
 
-            actualCountMap.computeIfAbsent(timetable.courseId,i->0L)
-            actualCountMap.put(timetable.courseId,actualCountMap.get(timetable.courseId)+signIn.size())
+            actualCountMap.computeIfAbsent(timetable.courseId, i -> 0L)
+            actualCountMap.put(timetable.courseId, actualCountMap.get(timetable.courseId) + signIn.size())
         }
 
-        for(course in courseMap.values()){
-            infoList.add(new CourseStatisticInfo(course,countMap.get(course.id),actualCountMap.getOrDefault(course.id,0L)))
+        for (course in courseMap.values()) {
+            infoList.add(new CourseStatisticInfo(course, countMap.get(course.id), actualCountMap.getOrDefault(course.id, 0L)))
         }
 
-        infoList=infoList.sort()
+        infoList = infoList.sort()
         return infoList
     }
 
     @Override
     Result queryTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request) {
         def optional = userRepository.findById(request.id)
-        if(optional.isEmpty()){
-            return new Result(false,"用户不存在")
+        if (optional.isEmpty()) {
+            return new Result(false, "用户不存在")
         }
-        return new Result(true,"查询成功",getTeachingCourseStatistic(request))
+        return new Result(true, "查询成功", getTeachingCourseStatistic(request))
     }
 
     @Override
     Result generateTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request) {
         def optional = userRepository.findById(request.id)
-        if(optional.isEmpty()){
-            return new Result(false,"用户不存在")
+        if (optional.isEmpty()) {
+            return new Result(false, "用户不存在")
         }
-        def user=optional.get()
-        def result=getTeachingCourseStatistic(request)
-        def filename="docOutput/teaching-class-${request.id}.docx"
-        def map=new HashMap<String,String>()
-        map.put("title","${user.name}教学课程")
-        WordExecutor.generateTeachingCourseStatisticReport(filename,result ,map)
-        def localFile=new LocalFile();
-        localFile.path="teaching-class-${request.id}.docx"
-        cosJavaRepository.addUploadFileTaskSync(new File(filename),localFile)
+        def user = optional.get()
+        def result = getTeachingCourseStatistic(request)
+        def filename = "docOutput/teaching-class-${request.id}.docx"
+        def map = new HashMap<String, String>()
+        map.put("title", "${user.name}教学课程")
+        WordExecutor.generateTeachingCourseStatisticReport(filename, result, map)
+        def localFile = new LocalFile();
+        localFile.path = "teaching-class-${request.id}.docx"
+        cosJavaRepository.addUploadFileTaskSync(new File(filename), localFile)
 
         FileInfo fileInfo = new FileInfo();
         fileInfo.setPath(config.getRedirectPath() + localFile.getPath());
-        def list=new ArrayList<FileInfo>()
+        def list = new ArrayList<FileInfo>()
         list.add(fileInfo)
 
-        return new Result(true,"生成成功",list)
+        return new Result(true, "生成成功", list)
     }
 
     @Autowired

+ 3 - 6
final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/ClassStatisticInfo.java

@@ -1,27 +1,24 @@
 package org.brynhild.graduation.transfer.timetable.bo;
 
-import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.brynhild.graduation.persistence.timetable.entity.Course;
-import org.brynhild.graduation.persistence.timetable.entity.TimeTable;
 
 @Data
 @NoArgsConstructor
-public class ClassStatisticInfo implements Comparable<ClassStatisticInfo>{
+public class ClassStatisticInfo implements Comparable<ClassStatisticInfo> {
     private Course course;
     private Long count;
     private Long actualCount;
+    private Double rate;
 
     public ClassStatisticInfo(Course course, Long count, Long actualCount) {
         this.course = course;
         this.count = count;
         this.actualCount = actualCount;
-        rate=1.0*actualCount/count;
+        rate = 1.0 * actualCount / count;
     }
 
-    private Double rate;
-
     @Override
     public int compareTo(ClassStatisticInfo o) {
         return rate.compareTo(o.rate);

+ 3 - 4
final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/CourseStatisticInfo.java

@@ -6,20 +6,19 @@ import org.brynhild.graduation.persistence.timetable.entity.Course;
 
 @Data
 @NoArgsConstructor
-public class CourseStatisticInfo implements Comparable<CourseStatisticInfo>{
+public class CourseStatisticInfo implements Comparable<CourseStatisticInfo> {
     private Course course;
     private Long count;
     private Long actualCount;
+    private Double rate;
 
     public CourseStatisticInfo(Course course, Long count, Long actualCount) {
         this.course = course;
         this.count = count;
         this.actualCount = actualCount;
-        rate=1.0*actualCount/count;
+        rate = 1.0 * actualCount / count;
     }
 
-    private Double rate;
-
     @Override
     public int compareTo(CourseStatisticInfo o) {
         return rate.compareTo(o.rate);

+ 3 - 4
final-transfer/src/main/java/org/brynhild/graduation/transfer/timetable/bo/StudentStatisticInfo.java

@@ -6,20 +6,19 @@ import org.brynhild.graduation.persistence.timetable.entity.Course;
 
 @Data
 @NoArgsConstructor
-public class StudentStatisticInfo implements Comparable<StudentStatisticInfo>{
+public class StudentStatisticInfo implements Comparable<StudentStatisticInfo> {
     private Course course;
     private Long count;
     private Long actualCount;
+    private Double rate;
 
     public StudentStatisticInfo(Course course, Long count, Long actualCount) {
         this.course = course;
         this.count = count;
         this.actualCount = actualCount;
-        rate=1.0*actualCount/count;
+        rate = 1.0 * actualCount / count;
     }
 
-    private Double rate;
-
     @Override
     public int compareTo(StudentStatisticInfo o) {
         return rate.compareTo(o.rate);

+ 1 - 1
final-transfer/src/main/java/org/brynhild/graduation/transfer/view/ViewConvertor.groovy

@@ -50,7 +50,7 @@ class ViewConvertor {
         }
                 .forEachOrdered {
                     def binary = new TimeTableBinary(table)
-                    binary.week=it
+                    binary.week = it
                     ret.add(binary)
                 }
 

+ 1 - 1
final-user/src/main/java/org/brynhild/graduation/user/service/impl/TeacherServiceImpl.groovy

@@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Service
 
 @Service
-class TeacherServiceImpl implements ITeacherService{
+class TeacherServiceImpl implements ITeacherService {
     private UserRepository userRepository
 
     @Override