平均分配分值

master
pd 4 years ago
parent 6eb88e4187
commit b8e8868747
  1. 4
      src/main/java/com/yipin/liuwanr/controller/Project_ManagementController.java
  2. 67
      src/main/java/com/yipin/liuwanr/helper/UserUtil.java
  3. 2
      src/main/java/com/yipin/liuwanr/mapper/Project_ManagementMapper.java

@ -198,8 +198,8 @@ public class Project_ManagementController {
@ApiOperation(value = "实验任务列表", notes = "实验任务列表") @ApiOperation(value = "实验任务列表", notes = "实验任务列表")
@GetMapping("/getByjudgmentPointsId") @GetMapping("/getByjudgmentPointsId")
Response getByjudgmentPointsId(@ApiParam(name = "judgmentPointsIds", value = "判分点主键id", required = true) @RequestParam List<Integer> judgmentPointsIds, Response getByjudgmentPointsId(@ApiParam(name = "judgmentPointsIds", value = "判分点主键id", required = true) @RequestParam List<Integer> judgmentPointsIds,
@ApiParam(name = "projectId", value = "项目主键ID", required = false) @RequestParam(required = false) Integer projectId, @ApiParam(name = "projectId", value = "项目主键ID", required = false) @RequestParam(required = false) Integer projectId,
@ApiParam(name = "userId", value = "用户主键ID", required = false) @RequestParam(required = false) Integer userId) { @ApiParam(name = "userId", value = "用户主键ID", required = false) @RequestParam(required = false) Integer userId) {
Response resp = new Response(); Response resp = new Response();
HashMap<String, Object> ret = service.getByjudgmentPointsId(judgmentPointsIds, projectId, userId); HashMap<String, Object> ret = service.getByjudgmentPointsId(judgmentPointsIds, projectId, userId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");

@ -5,34 +5,45 @@ import java.util.List;
public class UserUtil { public class UserUtil {
/** /**
* 平均分配分值 * 平均分配分值
* @param number 判分点数量 *
* @return * @param number 判分点数量
*/ * @return
public static List<Integer> averageValue(Integer number) { */
Integer score=100/number; public static List<Integer> averageValue(Integer number) {
Integer lastScore=score+100%number; Integer score = 100 / number;
List<Integer> list=new ArrayList<Integer>(); List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < number-1; i++) { if (100 % number == 0) {
list.add(score); for (int i = 0; i < number; i++) {
} list.add(score);
list.add(lastScore); }
return list; } else {
} int n = 0;
for (int i = 0; i < number; i++) {
list.add(score);
}
for (int i = 100 % number; i > 0; i--) {
n = score + 1;
list.set(i, n);
}
}
return list;
}
/** /**
* 将string类型转成list集合 * 将string类型转成list集合
* @param str *
* @return * @param str
*/ * @return
public static List<Integer> strToInteger(String str){ */
String[] strs = str.split(","); public static List<Integer> strToInteger(String str) {
List<Integer> list=new ArrayList<Integer>(); String[] strs = str.split(",");
for (int i = 0; i < strs.length; i++) { List<Integer> list = new ArrayList<Integer>();
list.add(Integer.parseInt(strs[i])); for (int i = 0; i < strs.length; i++) {
} list.add(Integer.parseInt(strs[i]));
return list; }
} return list;
}
} }

@ -131,7 +131,7 @@ public interface Project_ManagementMapper {
* @return * @return
*/ */
@Select({ "<script>", @Select({ "<script>",
"select judgmentPointsId,judgmentPointsName from hr_judgment_points where isdel=0 and systemId=#{systemId}", "select judgmentPointsId,judgmentPointsName from hr_judgment_points where isdel=0 and systemId=#{systemId} and isopen=0",
" <if test='judgmentPointsName!=null'> and judgmentPointsName like concat('%','${judgmentPointsName}','%')</if>", " <if test='judgmentPointsName!=null'> and judgmentPointsName like concat('%','${judgmentPointsName}','%')</if>",
"</script>" }) "</script>" })
List<Judgment_Points> queryAllJudgmentPoints(Judgment_Points points); List<Judgment_Points> queryAllJudgmentPoints(Judgment_Points points);

Loading…
Cancel
Save