比赛部分

dev
王家东 5 months ago
parent 3f921d3075
commit 4dedf71109
  1. 32
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcompetitionprojectregistration/controller/AnnualCompetitionProjectRegistrationController.java
  2. 108
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/controller/CompController.java
  3. 12
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/mapper/CompMapper.java
  4. 8
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/ICompService.java
  5. 20
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/impl/CompServiceImpl.java
  6. 12
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/controller/CompTypeController.java
  7. 8
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/entity/CompType.java
  8. 6
      jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts
  9. 25
      jeecgboot-vue3-master/src/views/annualCompPoint/committee/components/AnnualCompPointForm.vue
  10. 6
      jeecgboot-vue3-master/src/views/annualcomp/submitted/AnnualComp.api.ts
  11. 1
      jeecgboot-vue3-master/src/views/annualcomp/submitted/components/Form1.vue
  12. 8
      jeecgboot-vue3-master/src/views/annualcompetitionprojectregistration/student/AnnualCompetitionProjectRegistrationList.vue
  13. 16
      jeecgboot-vue3-master/src/views/comptype/CompType.data.ts
  14. 10
      jeecgboot-vue3-master/src/views/comptype/components/CompTypeForm.vue

@ -44,6 +44,8 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
@ -94,6 +96,16 @@ public class AnnualCompetitionProjectRegistrationController {
public Result<String> studentSignUp(@RequestBody StudentSignUpVo studentSignUpVo) {
log.info("the studentSignUpVo:{}", studentSignUpVo);
annualCompetitionProjectRegistrationService.studentSignUp(studentSignUpVo);
//获取当前的年度比赛项目id和用户信息进行判断,一个用户只能报名一个年度比赛项目
/* String trueorflase = annualCompetitionProjectRegistrationService.trueorflase(studentSignUpVo);*/
// if (trueorflase.equals("0")) {
// annualCompetitionProjectRegistrationService.studentSignUp(studentSignUpVo);
// } else if (trueorflase.equals("1")){
// return Result.error("您已经报过名了");
// }else if (trueorflase.equals("2")){
// return Result.error("团队中已经有成员报过名了");
// }
return Result.OK();
}
@ -682,14 +694,20 @@ public class AnnualCompetitionProjectRegistrationController {
* @return
*/
public Result<String> applicationRefusal(String id) {
LocalDateTime now = LocalDateTime.now();
Date now1 = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
AnnualCompetitionProjectRegistration one = annualCompetitionProjectRegistrationService.query().eq("id", id).one();
if (!(one.getEnrollStatic().equals("3") || one.getEnrollStatic().equals("4") || one.getEnrollStatic().equals("0"))) {
AnnualCompetitionProjectRegistration a = new AnnualCompetitionProjectRegistration();
a.setId(id);
a.setEnrollStatic("4");
annualCompetitionProjectRegistrationService.updateById(a);
return Result.OK("已申请驳回!");
AnnualCompPoint acp = annualCompPointService.getById(one.getAnnualCompid());
if(now1.after(acp.getApplyStartTime()) && now1.before(acp.getApplyEndTime())){
if (!one.getEnrollStatic().equals("3")) {
AnnualCompetitionProjectRegistration a = new AnnualCompetitionProjectRegistration();
a.setId(id);
a.setEnrollStatic("3");
annualCompetitionProjectRegistrationService.updateById(a);
return Result.OK("已申请驳回!");
}
} else {
return Result.error("不在报名时间内!");
}
return Result.error("不需要申请驳回!");

@ -90,11 +90,12 @@ public class CompController extends JeecgController<Comp, ICompService> {
//角色编码 管理员&教务处 可以看到所有,其它用户可见到所属自己数据
Map<String, String> efficientRoleMap = new LinkedHashMap<>();
efficientRoleMap.put("admin", "admin");
/*efficientRoleMap.put("committee", "committee");*/
efficientRoleMap.put("xs", "xs");
efficientRoleMap.put("superAdmin", "superAdmin");
if (efficientRoleMap.containsValue(roleMap.get("admin"))
||efficientRoleMap.containsValue(roleMap.get("committee"))
||efficientRoleMap.containsValue(roleMap.get("superAdmin"))) {
||efficientRoleMap.containsValue(roleMap.get("superAdmin"))
||efficientRoleMap.containsValue(roleMap.get("xs"))) {
} else {
comp.setCompAdmin(loginUser.getUsername());
}
@ -195,71 +196,66 @@ public class CompController extends JeecgController<Comp, ICompService> {
}
/*--------------------------王家东添加开始============================*/
//获取比赛类型comptyp就是类型的分数
Double comptypeweight = compTypeService.getById(comp.getCompTypeId()).getScore();
int comptyp = (int) Math.round(comptypeweight);
//开始获取
/*comp.setCompweight(csort);*/
List<String> stringNumbers = compTypeService.getALL();
// 将字符串数字转换为整数并进行排序
List<Integer> intNumbers = convertAndSort(stringNumbers);
//获取到的上下限
int result = processInput(intNumbers, comptyp);
//开始获取个数
int geshu = compTypeService.getgeshu(comp.getCompTypeId());
//开始计算中间值
int b = result / geshu;
//开始获取逆向排名
int position = findPosition(intNumbers,comptyp);
//计算全职
int wei = (intNumbers.size()-position +1) * b+comptyp;
comp.setCompweight(wei);
//开始获取同一类型比赛的个数
int compcount = compTypeService.getgeshu(comp.getCompTypeId())+1;
//开始获取上下限
int lowdown = (int) (compTypeService.getById(comp.getCompTypeId()).getScore() - compTypeService.getById(comp.getCompTypeId()).getScorel());
//开始计算差值
float b = (float) lowdown / compcount;
//用于查询全部的数据
List<String> parlint = compService.getallscore(comp.getCompTypeId());
//开始获取排名的倒叙
int rank = insertAndRank(parlint, String.valueOf(comp.getCompOrder()));
System.out.println(parlint);
int score = (int) (( rank+1) * b + compTypeService.getById(comp.getCompTypeId()).getScorel());
comp.setCompweight(score);
//开始计算同类型其他比赛
List<Comp> compList = compService.getAllCompByType(comp.getCompTypeId());
if (compList.size()>0){
for (int i=0;i<compList.size();i++){
System.out.println(compList.get(i).getCompOrder());
int rankold = insertAndRank(parlint, String.valueOf(compList.get(i).getCompOrder()));
int scoreold = (int) (( rankold+1) * b + compTypeService.getById(comp.getCompTypeId()).getScorel());
compService.updatedate(compList.get(i).getId(),scoreold);
}
}
/*--------------------------王家东添加开始============================*/
compService.save(comp);
return Result.OK("添加成功!");
}
private static int findPosition(List<Integer> intList, int inputNumber) {
// 使用二分查找或简单遍历找到输入数字的位置(索引从0开始)
int position = Collections.binarySearch(intList, inputNumber);
// 如果binarySearch返回负数,说明输入的数字不在列表中,我们需要找到它应该插入的位置(取反然后减1)
if (position < 0) {
position = -position - 1;
}
// 根据位置计算并返回相应的位数
// 如果最大返回1,最小返回列表长度
return (position == 0) ? 1 : (intList.size() - position + 1);
}
//这个是获取倒叙的方法
public static int insertAndRank(List<String> list, String newValue) {
// 插入新值
list.add(newValue);
// 排序(如果有需要,这里已经是插入后的状态,但我们为了验证再次排序)
Collections.sort(list, Collections.reverseOrder());
private static List<Integer> convertAndSort(List<String> stringNumbers) {
List<Integer> intNumbers = new ArrayList<>();
for (String s : stringNumbers) {
intNumbers.add(Integer.parseInt(String.valueOf((int)Double.parseDouble(s))));
}
Collections.sort(intNumbers, Collections.reverseOrder()); // 从大到小排序
return intNumbers;
}
// 排名计算
int rank = 1;
int currentRankCount = 1;
String lastValue = list.get(0); // 获取最大值
private static int processInput(List<Integer> intNumbers, int inputNumber) {
// 查找输入的数字在列表中的位置
int index = intNumbers.indexOf(inputNumber);
if (index != -1) { // 如果找到了
// 如果是最大的一个数字,用100减去这个数
if (index == 0) {
return 100 - inputNumber;
for (int i = 1; i <= list.size(); i++) {
if (i < list.size() && list.get(i).equals(lastValue)) {
// 如果当前值与上一个值相同,则增加并列排名计数
currentRankCount++;
} else {
// 如果不是最大的一个数字,用它前面的那个数字减去这个数
return intNumbers.get(index - 1) - inputNumber;
// 值改变了,更新排名和当前排名计数
if (lastValue.equals(newValue)) {
// 如果新值在遍历过程中被找到,则返回其排名
return rank;
}
rank += currentRankCount;
currentRankCount = 1;
lastValue = i < list.size() ? list.get(i) : null; // 更新为下一个值(如果有的话)
}
} else {
// 输入的数字不在列表中
System.out.println("输入的数字不在列表中。");
return -1; // 或者可以抛出异常
}
// 理论上不会到达这里,除非列表为空或新值大于列表中所有值
return rank;
}
/**

@ -4,6 +4,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.demo.comp.entity.Comp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -14,8 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0
*/
public interface CompMapper extends BaseMapper<Comp> {
@Select("select * from comp where comp_admin = #{username}")
List<Comp> getbyAdmin(String username);
@Select("SELECT COUNT(*) FROM sys_user_role WHERE role_id ='1731948288626339841'")
int getzjint();
@ -23,4 +22,13 @@ public interface CompMapper extends BaseMapper<Comp> {
@Select("select id from comp where comp_admin=#{ids}")
List<String> findcompid(String ids);
@Select("select comp_order from comp where comp_type_id =#{compTypeId}")
List<String> getallscore(String compTypeId);
@Select("select * from comp where comp_type_id =#{compTypeId}")
List<Comp> getAllCompByType(String compTypeId);
@Update("UPDATE comp SET compweight = #{scoreold} WHERE id=#{id}")
void updatedate(String id, int scoreold);
}

@ -12,9 +12,15 @@ import java.util.List;
* @Version: V1.0
*/
public interface ICompService extends IService<Comp> {
List<Comp> getbyAdmin(String username);
int getzjint();
List<String> findcompid(String ids);
List<String> getallscore(String compTypeId);
List<Comp> getAllCompByType(String compTypeId);
void updatedate(String id, int scoreold);
}

@ -21,11 +21,6 @@ public class CompServiceImpl extends ServiceImpl<CompMapper, Comp> implements IC
@Autowired
private CompMapper compMapper;
@Override
public List<Comp> getbyAdmin(String username) {
return compMapper.getbyAdmin(username);
}
@Override
public int getzjint() {
return compMapper.getzjint();
@ -35,4 +30,19 @@ public class CompServiceImpl extends ServiceImpl<CompMapper, Comp> implements IC
public List<String> findcompid(String ids) {
return compMapper.findcompid(ids);
}
@Override
public List<String> getallscore(String compTypeId) {
return compMapper.getallscore(compTypeId);
}
@Override
public List<Comp> getAllCompByType(String compTypeId) {
return compMapper.getAllCompByType(compTypeId);
}
@Override
public void updatedate(String id, int scoreold) {
compMapper.updatedate(id,scoreold);
}
}

@ -102,9 +102,9 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
// @RequiresPermissions("CompType:comp_type:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody CompType compType) {
Double score = compType.getScore();
String typeName = compType.getTypeName();
switch (typeName){
/* Double score = compType.getScore();
String typeName = compType.getTypeName();*/
/* switch (typeName){
case "A":
if (!(score>90&&score<=100))
return Result.error("A类比赛类型需要91-100之间");
@ -122,7 +122,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
if (!(score>=60&&score<=70))
return Result.error("D类比赛类型需要60-70之间");
break;
}
}*/
compTypeService.save(compType);
return Result.OK("添加成功!");
}
@ -138,7 +138,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
// @RequiresPermissions("CompType:comp_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody CompType compType) {
Double score = compType.getScore();
/*Double score = compType.getScore();
String typeName = compType.getTypeName();
switch (typeName){
case "A":
@ -158,7 +158,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
if (!(score>60&&score<70))
return Result.error("D类比赛类型需要60-70之间");
break;
}
}*/
compTypeService.updateById(compType);
return Result.OK("编辑成功!");

@ -59,8 +59,12 @@ public class CompType implements Serializable {
@Excel(name = "类型名称", width = 15)
@ApiModelProperty(value = "类型名称")
private String typeName;
/**权值*/
/**权值上限*/
@Excel(name = "权值", width = 15)
@ApiModelProperty(value = "权值")
@ApiModelProperty(value = "权值上限")
private Double score;
/**权值下限*/
@Excel(name = "权值", width = 15)
@ApiModelProperty(value = "权值下限")
private Double scorel;
}

@ -17,6 +17,7 @@ enum Api {
pj = '/AnnualCompPoint/annualCompPoint/pj',
cjhz = '/AnnualCompPoint/annualCompPoint/cjhz',
tongfenfuping = '/AnnualCompPoint/annualCompPoint/tongfenfuping',
getProjectlevel = '/projectlevel/projectlevel/getProjectlevel',
}
/**
@ -142,3 +143,8 @@ export const tongfenfuping = (params,handleSuccess) => {
});
}
export const getProjectlevel = (params) => {
const url = Api.getProjectlevel;
return defHttp.get({ url: url, params });
};

@ -40,8 +40,10 @@
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="项目层次" v-bind="validateInfos.objLevel" :labelCol="labelCol" :wrapperCol="wrapperCol7">
<j-dict-select-tag type="radio" v-model:value="formData.objLevel" placeholder="请选择项目层次" dict-code="obj_lever" />
<a-form-item label="项目层次1" v-bind="validateInfos.objLevel" :labelCol="labelCol" :wrapperCol="wrapperCol7">
<a-radio-group v-model:value="formData.objLevel">
<a-radio v-for="item in objLevelll" :key="item.id" :value="item.id">{{ item.name }}</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
</a-row>
@ -226,10 +228,10 @@ import JSwitch from '/@/components/Form/src/jeecg/components/JSwitch.vue';
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue';
import {getValueType} from '/@/utils';
import {saveOrUpdate} from '../AnnualCompPoint.api';
import {saveOrUpdate, getProjectlevel} from '../AnnualCompPoint.api';
import {Form} from 'ant-design-vue';
const props = defineProps({
// objLevelll: { type: Array, default: () => [] },
formDisabled: {type: Boolean, default: false},
formData: {
type: Object, default: () => {
@ -237,6 +239,13 @@ const props = defineProps({
},
formBpm: {type: Boolean, default: true}
});
const objLevelll = ref([])
const getProjectlevelEvent = async() => {
const res = await getProjectlevel()
objLevelll.value = res
console.log(res,'2222')
}
getProjectlevelEvent()
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
@ -245,7 +254,7 @@ const formData = reactive<Record<string, any>>({
annualCompId: '',
objName: '',
introduce: '',
objLevel: '3',
objLevel: '',
entryForm: 'Y',
teamNumber: undefined,
teacherNumber: undefined,
@ -319,7 +328,11 @@ const disabled = computed(() => {
* 新增
*/
function add() {
edit({});
resetFields();
if (props.objLevelll.length !== 0) {
formData.objLevel = props.objLevelll[0].id;
}
edit({ ...formData });
}
/**

@ -68,7 +68,9 @@ export const batchDelete = (params, handleSuccess) => {
*
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
export const saveOrUpdate = (params, isUpdate, handleSuccess) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params });
return defHttp.post({ url: url, params }).then(() => {
handleSuccess();
});
};

@ -109,6 +109,7 @@
if (res.success) {
createMessage.success(res.message);
emit('ok');
window.location.reload()
} else {
createMessage.warning(res.message);
}

@ -132,11 +132,11 @@ import ChaoseTopicPersionModal from '/@/views/chooseTopicPersion/components/Chao
// const router = useRouter()
function chooseTopic(record: Recordable) {
console.log(record)
console.log(record,'1212')
choose(record).then(res => {
console.log(res)
registerModal1.value.disableSubmit = false;
registerModal1.value.add({enrollCode:record.enrollCode});
console.log(res,'2222')
registerModal1.value.disableSubmit = true;
registerModal1.value.edit({enrollCode:record.enrollCode});
}).catch(err => console.log(err))
}
// function edit1(record: Recordable) {

@ -10,10 +10,16 @@ export const columns: BasicColumn[] = [
dataIndex: 'typeName'
},
{
title: '权值',
title: '权值上限',
align: "center",
dataIndex: 'score'
},
{
title: '权值下限',
align: "center",
dataIndex: 'scorel'
},
];
//查询数据
@ -28,10 +34,16 @@ export const formSchema: FormSchema[] = [
component: 'Input',
},
{
label: '权值',
label: '权值上限',
field: 'score',
component: 'InputNumber',
},
{
label: '权值下限',
field: 'scorel',
component: 'InputNumber',
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',

@ -8,8 +8,14 @@
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="权值" v-bind="validateInfos.score">
<a-input-number v-model:value="formData.score" placeholder="请输入权值" style="width: 100%" :disabled="disabled"/>
<a-form-item label="权值上限" v-bind="validateInfos.score">
<a-input-number v-model:value="formData.score" placeholder="请输入权值上限" style="width: 100%" :disabled="disabled"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="权值下限" v-bind="validateInfos.score">
<a-input-number v-model:value="formData.scorel" placeholder="请输入权值下限" style="width: 100%" :disabled="disabled"/>
</a-form-item>
</a-col>
</a-row>

Loading…
Cancel
Save