修改班级平均成绩走势图

master
xiaoCJ 1 year ago
parent 61cadb4425
commit 98a8355dd5

@ -6,8 +6,11 @@ import com.sztzjy.fund_investment.annotation.OperateLog;
import com.sztzjy.fund_investment.config.security.JwtUser;
import com.sztzjy.fund_investment.config.security.TokenProvider;
import com.sztzjy.fund_investment.entity.Flow;
import com.sztzjy.fund_investment.entity.PerformanceScore;
import com.sztzjy.fund_investment.entity.PerformanceScoreExample;
import com.sztzjy.fund_investment.entity.User;
import com.sztzjy.fund_investment.mapper.FlowMapper;
import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper;
import com.sztzjy.fund_investment.service.IUserService;
import com.sztzjy.fund_investment.util.ResultEntity;
import com.sztzjy.fund_investment.util.RsaUtil;
@ -27,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -41,16 +45,19 @@ public class UserController {
private AuthenticationManagerBuilder authenticationManagerBuilder;
@Autowired
private FlowMapper flowMapper;
@Autowired
private PerformanceScoreMapper performanceScoreMapper;
@ApiOperation(value = "用户登录",httpMethod = "POST")
@ApiOperation(value = "用户登录", httpMethod = "POST")
@OperateLog(recordParameters = false)
@PostMapping("login")
@AnonymousAccess
public ResultEntity login(@RequestParam String username, @RequestParam String passwordEncode) {
String password;
try{
try {
password = RsaUtil.decryptByPrivateKey(passwordEncode);
}catch (Exception e){
} catch (Exception e) {
return new ResultEntity(HttpStatus.BAD_REQUEST, "密码错误");
}
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
@ -68,15 +75,15 @@ public class UserController {
map.put("schoolId", user.getSchoolId());
Flow flow = flowMapper.selectByPrimaryKey(jwtUser.getUserId());
if(flow==null){
if (flow == null) {
String uuid = String.valueOf(UUID.randomUUID());
Flow flow1 = new Flow();
flow1.setUserid(jwtUser.getUserId());
flow1.setFlowId(uuid);
flowMapper.insert(flow1);
map.put("flowId",uuid);
}else {
map.put("flowId",flow.getFlowId());
map.put("flowId", uuid);
} else {
map.put("flowId", flow.getFlowId());
}
return new ResultEntity(HttpStatus.OK, map);
@ -93,13 +100,20 @@ public class UserController {
System.out.println(new BCryptPasswordEncoder().encode(password));
}
@ApiOperation(value = "重新实训",httpMethod = "POST")
@ApiOperation(value = "重新实训", httpMethod = "POST")
@PostMapping("reTraining")
@AnonymousAccess
public ResultEntity reTraining(@RequestParam String userId) {
Flow flow = flowMapper.selectByPrimaryKey(userId);
flow.setFlowId(IdUtil.simpleUUID());
flowMapper.updateByPrimaryKey(flow);
return new ResultEntity(HttpStatus.OK,"已重新实训!");
PerformanceScoreExample example = new PerformanceScoreExample();
example.createCriteria().andFlowIdEqualTo(flow.getFlowId());
List<PerformanceScore> performanceScores = performanceScoreMapper.selectByExample(example);
if (performanceScores.isEmpty()) {
return null;
}
performanceScoreMapper.deleteByExample(example);
return new ResultEntity(HttpStatus.OK, "已重新实训!");
}
}

@ -52,7 +52,7 @@ public class ClassScoreController {
@AnonymousAccess
@GetMapping("/getClassAVGScore")
@ApiOperation("成绩管理/班级平均成绩折线图")
public ResultEntity<List<TeaClassScore>> getClassAVGScore(@RequestParam String schoolId) {
public ResultEntity<List<ClassAVGScoreVo>> getClassAVGScore(@RequestParam String schoolId) {
return new ResultEntity<>(classScoreService.getClassAVGScore(schoolId));
}

@ -0,0 +1,54 @@
package com.sztzjy.fund_investment.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Author xcj
* @Date 2023/12/14
*/
@Data
public class ClassAVGScoreVo {
// private String id;
// @ApiModelProperty("学校ID")
// private String schoolId;
// @ApiModelProperty("班级ID")
// private String classId;
@ApiModelProperty("班级名称")
private String className;
// @ApiModelProperty("优秀人数")
// private Integer excellentCount;
//
// @ApiModelProperty("良好人数")
// private Integer goodCount;
//
// @ApiModelProperty("一般人数")
// private Integer generalCount;
//
// @ApiModelProperty("不及格人数")
// private Integer failCount;
// @ApiModelProperty("班级最高分")
// private BigDecimal classMaxScore;
//
// @ApiModelProperty("班级最低分")
// private BigDecimal classMinScore;
@ApiModelProperty("班级平均分")
private List<BigDecimal> classAverageScore;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
@ApiModelProperty("最早得分日期")
private Date startTime;
}

@ -6,6 +6,8 @@ import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface TeaClassScoreMapper {
long countByExample(TeaClassScoreExample example);
@ -30,5 +32,8 @@ public interface TeaClassScoreMapper {
int updateByPrimaryKey(TeaClassScore record);
List<TeaClassScore> selectAndOrderByTime(@Param("schoolId")String schoolId);
List<TeaClassScore> selectAndOrderByTime(@Param("schoolId")String schoolId,@Param("className")String className);
@Select("select class_name from tea_class_score where school_id = #{schoolId} group by class_name")
List<String> selectClassNameBySchool(@Param("schoolId")String schoolId);
}

@ -50,13 +50,31 @@ public class ClassScoreServiceImpl implements ClassScoreService {
private IFileUtil fileUtil;
/*
/*
* @author xcj
* @Date 2023/11/24
*/
@Override
public List<TeaClassScore> getClassAVGScore(String schoolId) {
return teaClassScoreMapper.selectAndOrderByTime(schoolId);
public List<ClassAVGScoreVo> getClassAVGScore(String schoolId) {
List<String> classNameList = teaClassScoreMapper.selectClassNameBySchool(schoolId);
List<ClassAVGScoreVo> voList = new ArrayList<>();
for (String className : classNameList) {
ClassAVGScoreVo vo = new ClassAVGScoreVo();
vo.setClassName(className);
List<TeaClassScore> list = teaClassScoreMapper.selectAndOrderByTime(schoolId, className);
if (list.isEmpty()) {
continue;
}
TeaClassScore teaClassScore = list.get(0);
vo.setStartTime(teaClassScore.getStartTime());
List<BigDecimal> scoreList = new ArrayList();
for (TeaClassScore classScore : list) {
scoreList.add(classScore.getClassAverageScore());
}
vo.setClassAverageScore(scoreList);
voList.add(vo);
}
return voList;
}

@ -17,7 +17,7 @@ import java.util.Map;
* @Date 2023/11/24
*/
public interface ClassScoreService {
List<TeaClassScore> getClassAVGScore(String schoolId);
List<ClassAVGScoreVo> getClassAVGScore(String schoolId);
TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time);

@ -97,7 +97,8 @@
<include refid="Base_Column_List" />
from tea_class_score
where school_id = #{schoolId,jdbcType=VARCHAR}
and start_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
AND class_name = #{className}
AND start_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
order by start_time
</select>

Loading…
Cancel
Save