licailing vor 4 Jahren
Ursprung
Commit
f5990882cb

+ 6 - 3
src/main/java/com/izouma/wenlvju/domain/PerformanceApply.java

@@ -53,10 +53,13 @@ public class PerformanceApply extends BaseEntity {
     @ApiModelProperty(value = "奖项")
     private String awards;
 
-    private Integer score;
+    private Double score;
 
-//    @ApiModelProperty(value = "排序")
-//    private int sort;
+    @ApiModelProperty(value = "签到时间")
+    private LocalDateTime signInAt;
+
+    @ApiModelProperty(value = "签到人")
+    private Long signInBy;
 
     @Transient
     private String artType;

+ 24 - 0
src/main/java/com/izouma/wenlvju/domain/PerformanceScore.java

@@ -0,0 +1,24 @@
+package com.izouma.wenlvju.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Where;
+
+import javax.persistence.Entity;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@Entity
+@Where(clause = "del = 0")
+public class PerformanceScore extends BaseEntity {
+    private Long performanceApplyId;
+
+    private double score;
+
+    private Long userId;
+
+}

+ 19 - 0
src/main/java/com/izouma/wenlvju/repo/PerformanceScoreRepo.java

@@ -0,0 +1,19 @@
+package com.izouma.wenlvju.repo;
+
+import com.izouma.wenlvju.domain.PerformanceScore;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+import java.util.List;
+
+public interface PerformanceScoreRepo extends JpaRepository<PerformanceScore, Long>, JpaSpecificationExecutor<PerformanceScore> {
+    @Query("update PerformanceScore t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+
+    List<PerformanceScore> findAllByPerformanceApplyId(Long performanceApplyId);
+}

+ 3 - 0
src/main/java/com/izouma/wenlvju/repo/PersonRepo.java

@@ -7,10 +7,13 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.List;
 
 public interface PersonRepo extends JpaRepository<Person, Long>, JpaSpecificationExecutor<Person> {
     @Query("update Person t set t.del = true where t.id = ?1")
     @Modifying
     @Transactional
     void softDelete(Long id);
+
+    List<Person> findAllByPerformanceApplyId(Long performanceApplyId);
 }

+ 98 - 50
src/main/java/com/izouma/wenlvju/service/PerformanceApplyService.java

@@ -3,17 +3,15 @@ package com.izouma.wenlvju.service;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.izouma.wenlvju.domain.ArtType;
-import com.izouma.wenlvju.domain.Organization;
-import com.izouma.wenlvju.domain.Performance;
-import com.izouma.wenlvju.domain.PerformanceApply;
+import com.izouma.wenlvju.domain.*;
 import com.izouma.wenlvju.dto.PageQuery;
 import com.izouma.wenlvju.enums.ApplyStatus;
+import com.izouma.wenlvju.enums.AuthorityName;
 import com.izouma.wenlvju.exception.BusinessException;
-import com.izouma.wenlvju.repo.ArtTypeRepo;
-import com.izouma.wenlvju.repo.OrganizationRepo;
-import com.izouma.wenlvju.repo.PerformanceApplyRepo;
-import com.izouma.wenlvju.repo.PerformanceRepo;
+import com.izouma.wenlvju.repo.*;
+import com.izouma.wenlvju.security.Authority;
+import com.izouma.wenlvju.security.JwtTokenUtil;
+import com.izouma.wenlvju.security.JwtUserFactory;
 import com.izouma.wenlvju.utils.JpaUtils;
 import com.izouma.wenlvju.utils.ObjUtils;
 import lombok.AllArgsConstructor;
@@ -23,10 +21,7 @@ import org.springframework.stereotype.Service;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -37,6 +32,10 @@ public class PerformanceApplyService {
     private final PerformanceRepo      performanceRepo;
     private final ArtTypeRepo          artTypeRepo;
     private final OrganizationRepo     organizationRepo;
+    private final PersonRepo           personRepo;
+    private final UserRepo             userRepo;
+    private final JwtTokenUtil         jwtTokenUtil;
+    private final PerformanceScoreRepo performanceScoreRepo;
 
     public Page<PerformanceApply> all(PageQuery pageQuery) {
         Page<PerformanceApply> all = performanceApplyRepo.findAll(JpaUtils.toSpecification(pageQuery, PerformanceApply.class), JpaUtils
@@ -73,50 +72,13 @@ public class PerformanceApplyService {
         performanceApplyRepo.save(apply);
     }
 
-    /*
-    自动编排
-     */
-//    public void autoArrangement(Long performanceId) {
-//        List<PerformanceApply> applyList =
-//                performanceApplyRepo.findAllByStatusAndPerformanceId(ApplyStatus.PASS, performanceId);
-//
-//        List<PerformanceApply> showTime = applyList.stream()
-//                .filter(apply -> apply.getShowTime() != null)
-//                .sorted((a, b) -> b.getShowTime().compareTo(a.getShowTime()))
-//                .collect(Collectors.toList());
-//        List<PerformanceApply> showTimeNull = applyList.stream()
-//                .filter(apply -> apply.getShowTime() == null)
-//                .collect(Collectors.toList());
-//
-//        if (CollUtil.isEmpty(showTimeNull)) {
-//            return;
-//        }
-//
-//        if (CollUtil.isEmpty(showTime)) {
-//            Performance performance = performanceRepo.findById(performanceId).orElseThrow(new BusinessException("无记录"));
-//            final LocalDateTime[] time = {LocalDateTime.of(performance.getStartTime().plusDays(3), LocalTime.now())};
-//            showTimeNull.forEach(apply -> {
-//                apply.setShowTime(time[0]);
-//                performanceApplyRepo.save(apply);
-//                time[0] = time[0].plusMinutes(10);
-//            });
-//            return;
-//        }
-//        final LocalDateTime[] time = {showTime.get(0).getShowTime().plusMinutes(10)};
-//        showTimeNull.forEach(apply -> {
-//            apply.setShowTime(time[0]);
-//            performanceApplyRepo.save(apply);
-//            time[0] = time[0].plusMinutes(10);
-//        });
-//    }
-
-
     public List<PerformanceApply> autoArrangement1(Long performanceId) {
         Performance performance = performanceRepo.findById(performanceId).orElseThrow(new BusinessException("无记录"));
         if (LocalDate.now().isBefore(performance.getEndDate())) {
             throw new BusinessException("报名结束后才可以自动编排");
         }
 
+        // 只编排通过的
         List<PerformanceApply> applyList =
                 performanceApplyRepo.findAllByStatusAndPerformanceId(ApplyStatus.PASS, performanceId);
         LocalDate startDate = performance.getEventStartDate();
@@ -194,4 +156,90 @@ public class PerformanceApplyService {
 //        });
     }
 
+    /*
+    签到
+    由管理人员先登陆,进行签到
+     */
+    public PerformanceApply signIn(Long id, Long userId) {
+        PerformanceApply performanceApply = performanceApplyRepo.findById(id)
+                .orElseThrow(new BusinessException("无此表演"));
+
+        if (ObjectUtil.isNotNull(performanceApply.getSignInAt()) && ObjectUtil.isNotNull(performanceApply.getSignInBy())) {
+            throw new BusinessException("已签到");
+        }
+
+        performanceApply.setSignInAt(LocalDateTime.now());
+        performanceApply.setSignInBy(userId);
+
+        return performanceApplyRepo.save(performanceApply);
+    }
+
+    /*
+    扫描作品二维码,通过手机号获取身份
+     */
+    public Map<String, String> getAuth(Long id, String phone) {
+        PerformanceApply performanceApply = performanceApplyRepo.findById(id)
+                .orElseThrow(new BusinessException("无此表演"));
+
+        Map<String, String> map = new HashMap<>();
+
+        if (phone.equals(performanceApply.getPhone())) {
+            map.put("phone", phone);
+            return map;
+        }
+
+        List<String> phones = personRepo.findAllByPerformanceApplyId(id)
+                .stream()
+                .map(Person::getName)
+                .collect(Collectors.toList());
+        if (phones.contains(phone)) {
+            map.put("phone", phone);
+            return map;
+        }
+
+        User user = userRepo.findByPhoneAndDelFalse(phone);
+        if (ObjectUtil.isNull(user)) {
+            throw new BusinessException("手机号错误");
+        }
+        if (!user.getAuthorities().contains(Authority.get(AuthorityName.ROLE_ADMIN))) {
+            throw new BusinessException("无权限");
+        }
+        String token = jwtTokenUtil.generateToken(JwtUserFactory.create(user));
+        map.put("phone", phone);
+        map.put("token", token);
+        return map;
+    }
+
+    /*
+    评分
+     */
+    public void score(Long id, double score, Long userId) {
+        PerformanceApply apply = performanceApplyRepo.findById(id).orElseThrow(new BusinessException("无此表演"));
+        if (!ApplyStatus.PASS.equals(apply.getStatus())) {
+            throw new BusinessException("此节目未通过审核");
+        }
+        if (ObjectUtil.isNull(apply.getShowStartTime())) {
+            throw new BusinessException("无表演时间");
+        }
+        if (LocalDateTime.now().isBefore(apply.getShowStartTime())) {
+            throw new BusinessException("节目暂未开始");
+        }
+
+        PerformanceScore performanceScore = PerformanceScore.builder()
+                .performanceApplyId(id)
+                .score(score)
+                .userId(userId)
+                .build();
+        performanceScoreRepo.save(performanceScore);
+
+        double scores = performanceScoreRepo.findAllByPerformanceApplyId(id)
+                .stream()
+                .mapToDouble(PerformanceScore::getScore)
+                .average()
+                .orElse(0.0);
+
+//        double scores1 = (double) Math.round(scores * 1000) / 1000;
+        apply.setScore(scores);
+        performanceApplyRepo.save(apply);
+    }
 }

+ 22 - 0
src/main/java/com/izouma/wenlvju/service/PerformanceScoreService.java

@@ -0,0 +1,22 @@
+package com.izouma.wenlvju.service;
+
+import com.izouma.wenlvju.domain.PerformanceScore;
+import com.izouma.wenlvju.dto.PageQuery;
+import com.izouma.wenlvju.repo.PerformanceScoreRepo;
+import com.izouma.wenlvju.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public class PerformanceScoreService {
+
+    private final PerformanceScoreRepo performanceScoreRepo;
+
+    public Page<PerformanceScore> all(PageQuery pageQuery) {
+        return performanceScoreRepo.findAll(JpaUtils.toSpecification(pageQuery, PerformanceScore.class), JpaUtils.toPageRequest(pageQuery));
+    }
+}

+ 17 - 0
src/main/java/com/izouma/wenlvju/web/PerformanceApplyController.java

@@ -6,6 +6,7 @@ import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.PerformanceApplyRepo;
 import com.izouma.wenlvju.service.PerformanceApplyService;
 import com.izouma.wenlvju.utils.ObjUtils;
+import com.izouma.wenlvju.utils.SecurityUtils;
 import com.izouma.wenlvju.utils.excel.ExcelUtils;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/performanceApply")
@@ -82,5 +84,20 @@ public class PerformanceApplyController extends BaseController {
     public void autoAwards(@RequestParam Long performanceId) {
         performanceApplyService.autoAwards(performanceId);
     }
+
+    @PostMapping("/score")
+    @ApiOperation("打分")
+    public void score(@RequestParam Long id, @RequestParam int score) {
+        performanceApplyService.score(id, score, SecurityUtils.getAuthenticatedUser().getId());
+    }
+
+    @PostMapping("/signIn")
+    public PerformanceApply signIn(@RequestParam Long id) {
+        return performanceApplyService.signIn(id, SecurityUtils.getAuthenticatedUser().getId());
+    }
+
+    public Map<String, String> getAuth(Long id, String phone) {
+        return performanceApplyService.getAuth(id, phone);
+    }
 }
 

+ 70 - 0
src/main/java/com/izouma/wenlvju/web/PerformanceScoreController.java

@@ -0,0 +1,70 @@
+package com.izouma.wenlvju.web;
+
+import com.izouma.wenlvju.domain.PerformanceScore;
+import com.izouma.wenlvju.service.PerformanceScoreService;
+import com.izouma.wenlvju.dto.PageQuery;
+import com.izouma.wenlvju.exception.BusinessException;
+import com.izouma.wenlvju.repo.PerformanceScoreRepo;
+import com.izouma.wenlvju.utils.ObjUtils;
+import com.izouma.wenlvju.utils.excel.ExcelUtils;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/performanceScore")
+@AllArgsConstructor
+public class PerformanceScoreController extends BaseController {
+    private final PerformanceScoreService performanceScoreService;
+    private final PerformanceScoreRepo    performanceScoreRepo;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/save")
+    public PerformanceScore save(@RequestBody PerformanceScore record) {
+        if (record.getId() != null) {
+            PerformanceScore orig = performanceScoreRepo.findById(record.getId())
+                    .orElseThrow(new BusinessException("无记录"));
+            ObjUtils.merge(orig, record);
+            return performanceScoreRepo.save(orig);
+        }
+        return performanceScoreRepo.save(record);
+    }
+
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<PerformanceScore> all(@RequestBody PageQuery pageQuery) {
+        return performanceScoreService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public PerformanceScore get(@PathVariable Long id) {
+        return performanceScoreRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @PostMapping("/del/{id}")
+    public void del(@PathVariable Long id) {
+        performanceScoreRepo.softDelete(id);
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<PerformanceScore> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+
+    @ApiOperation("打分细则")
+    @PostMapping("/breakdown")
+    public List<PerformanceScore> breakdown(@RequestParam Long performanceApplyId) {
+
+        return performanceScoreRepo.findAllByPerformanceApplyId(performanceApplyId);
+    }
+}
+

+ 1 - 0
src/main/resources/genjson/PerformanceScore.json

@@ -0,0 +1 @@
+{"tableName":"PerformanceScore","className":"PerformanceScore","remark":"展演分数","genTable":true,"genClass":true,"genList":false,"genForm":false,"genRouter":false,"javaPath":"/Users/qiufangchao/Desktop/project/wenlvju/src/main/java/com/izouma/wenlvju","viewPath":"/Users/qiufangchao/Desktop/project/wenlvju/src/main/vue/src/views","routerPath":"/Users/qiufangchao/Desktop/project/wenlvju/src/main/vue/src","resourcesPath":"/Users/qiufangchao/Desktop/project/wenlvju/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"performanceApplyId","modelName":"performanceApplyId","remark":"performanceApplyId","showInList":true,"showInForm":true,"formType":"number"},{"name":"score","modelName":"score","remark":"score","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"userId","modelName":"userId","remark":"userId","showInList":true,"showInForm":true,"formType":"number"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.wenlvju","tablePackage":"com.izouma.wenlvju.domain.PerformanceScore"}

+ 1 - 1
src/main/vue/src/views/PerformanceApplyEdit.vue

@@ -52,7 +52,7 @@
                 </el-date-picker>
             </el-form-item> -->
             <el-form-item>
-                <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+                <el-button @click="onSave" :loading="saving" type="primary" v-if="organization">保存</el-button>
                 <el-button @click="onDelete" :loading="saving" type="danger" v-if="formData.id">删除 </el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
             </el-form-item>

+ 6 - 1
src/main/vue/src/views/PerformanceApplyList.vue

@@ -34,7 +34,12 @@
             <el-table-column prop="contact" label="联系人"> </el-table-column>
             <el-table-column prop="phone" label="联系电话"> </el-table-column>
             <el-table-column prop="status" label="状态" :formatter="statusFormatter"> </el-table-column>
-            <el-table-column prop="showTime" label="表演时间"> </el-table-column>
+            <el-table-column prop="showTime" label="表演时间" min-width="140"
+                ><template slot-scope="{ row }">
+                    <span v-if="row.showStartTime">{{ row.showStartTime }} 至 {{ row.showEndTime }}</span>
+                    <span v-else>暂无</span>
+                </template></el-table-column
+            >
             <el-table-column label="操作" align="center" fixed="right" min-width="220">
                 <template slot-scope="{ row }">
                     <!-- <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>

+ 26 - 3
src/main/vue/src/views/PerformanceApplyList2.vue

@@ -42,7 +42,7 @@
             <el-table-column prop="contact" label="联系人"> </el-table-column>
             <el-table-column prop="phone" label="联系电话"> </el-table-column>
             <el-table-column prop="status" label="状态" :formatter="statusFormatter"> </el-table-column>
-            <el-table-column label="表演时间" min-width="120">
+            <el-table-column label="表演时间" min-width="140">
                 <template slot-scope="{ row }"> {{ row.showStartTime }} 至 {{ row.showEndTime }} </template>
             </el-table-column>
             <el-table-column prop="awards" label="奖项">
@@ -53,7 +53,7 @@
             </el-table-column>
             <el-table-column prop="score" label="得分">
                 <template slot-scope="{ row }">
-                    <span v-if="row.score != null"> {{ row.score }} </span>
+                    <el-link v-if="row.score != null" @click="breakdown(row)"> {{ row.score }} </el-link>
                     <span v-else>暂无</span>
                 </template>
             </el-table-column>
@@ -170,6 +170,12 @@
                 </div>
             </div>
         </el-dialog>
+        <el-dialog title="得分详细" :visible.sync="dialogScore" width="450px" center>
+            <el-table :data="scoreList">
+                <el-table-column prop="createdAt" label="评分时间" min-width="100" align="center"> </el-table-column>
+                <el-table-column prop="score" label="分数" min-width="100" align="center"> </el-table-column>
+            </el-table>
+        </el-dialog>
     </div>
 </template>
 <script>
@@ -200,7 +206,9 @@ export default {
             add: false,
             loading: false,
             dialogArrangement: false,
-            timeList: []
+            timeList: [],
+            dialogScore: false,
+            scoreList: []
         };
     },
     computed: {
@@ -438,6 +446,21 @@ export default {
                 var y = b['showStartTime'];
                 return x < y ? -1 : x > y ? 1 : 0;
             });
+        },
+        // 打分明细
+        breakdown(row) {
+            this.dialogScore = true;
+            this.$http
+                .post('/performanceScore/breakdown', {
+                    performanceApplyId: row.id
+                })
+                .then(res => {
+                    this.scoreList = res;
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.$message.error(e.error);
+                });
         }
     }
 };

+ 5 - 0
src/test/java/com/izouma/wenlvju/service/PerformanceApplyServiceTest.java

@@ -16,4 +16,9 @@ public class PerformanceApplyServiceTest extends ApplicationTests {
 
     }
 
+    @Test
+    public void test1() {
+        performanceApplyService.score(14L, 79,1L );
+    }
+
 }