比赛部分

dev
王家东 5 months ago
parent 3f921d3075
commit 4dedf71109
  1. 24
      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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
@ -94,6 +96,16 @@ public class AnnualCompetitionProjectRegistrationController {
public Result<String> studentSignUp(@RequestBody StudentSignUpVo studentSignUpVo) { public Result<String> studentSignUp(@RequestBody StudentSignUpVo studentSignUpVo) {
log.info("the studentSignUpVo:{}", studentSignUpVo); log.info("the studentSignUpVo:{}", studentSignUpVo);
annualCompetitionProjectRegistrationService.studentSignUp(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(); return Result.OK();
} }
@ -682,15 +694,21 @@ public class AnnualCompetitionProjectRegistrationController {
* @return * @return
*/ */
public Result<String> applicationRefusal(String id) { 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(); AnnualCompetitionProjectRegistration one = annualCompetitionProjectRegistrationService.query().eq("id", id).one();
AnnualCompPoint acp = annualCompPointService.getById(one.getAnnualCompid());
if (!(one.getEnrollStatic().equals("3") || one.getEnrollStatic().equals("4") || one.getEnrollStatic().equals("0"))) { if(now1.after(acp.getApplyStartTime()) && now1.before(acp.getApplyEndTime())){
if (!one.getEnrollStatic().equals("3")) {
AnnualCompetitionProjectRegistration a = new AnnualCompetitionProjectRegistration(); AnnualCompetitionProjectRegistration a = new AnnualCompetitionProjectRegistration();
a.setId(id); a.setId(id);
a.setEnrollStatic("4"); a.setEnrollStatic("3");
annualCompetitionProjectRegistrationService.updateById(a); annualCompetitionProjectRegistrationService.updateById(a);
return Result.OK("已申请驳回!"); return Result.OK("已申请驳回!");
} }
} else {
return Result.error("不在报名时间内!");
}
return Result.error("不需要申请驳回!"); return Result.error("不需要申请驳回!");
} }

@ -90,11 +90,12 @@ public class CompController extends JeecgController<Comp, ICompService> {
//角色编码 管理员&教务处 可以看到所有,其它用户可见到所属自己数据 //角色编码 管理员&教务处 可以看到所有,其它用户可见到所属自己数据
Map<String, String> efficientRoleMap = new LinkedHashMap<>(); Map<String, String> efficientRoleMap = new LinkedHashMap<>();
efficientRoleMap.put("admin", "admin"); efficientRoleMap.put("admin", "admin");
/*efficientRoleMap.put("committee", "committee");*/ efficientRoleMap.put("xs", "xs");
efficientRoleMap.put("superAdmin", "superAdmin"); efficientRoleMap.put("superAdmin", "superAdmin");
if (efficientRoleMap.containsValue(roleMap.get("admin")) if (efficientRoleMap.containsValue(roleMap.get("admin"))
||efficientRoleMap.containsValue(roleMap.get("committee")) ||efficientRoleMap.containsValue(roleMap.get("committee"))
||efficientRoleMap.containsValue(roleMap.get("superAdmin"))) { ||efficientRoleMap.containsValue(roleMap.get("superAdmin"))
||efficientRoleMap.containsValue(roleMap.get("xs"))) {
} else { } else {
comp.setCompAdmin(loginUser.getUsername()); comp.setCompAdmin(loginUser.getUsername());
} }
@ -195,71 +196,66 @@ public class CompController extends JeecgController<Comp, ICompService> {
} }
/*--------------------------王家东添加开始============================*/ /*--------------------------王家东添加开始============================*/
//获取比赛类型comptyp就是类型的分数 //开始获取同一类型比赛的个数
Double comptypeweight = compTypeService.getById(comp.getCompTypeId()).getScore(); int compcount = compTypeService.getgeshu(comp.getCompTypeId())+1;
int comptyp = (int) Math.round(comptypeweight); //开始获取上下限
//开始获取 int lowdown = (int) (compTypeService.getById(comp.getCompTypeId()).getScore() - compTypeService.getById(comp.getCompTypeId()).getScorel());
/*comp.setCompweight(csort);*/ //开始计算差值
List<String> stringNumbers = compTypeService.getALL(); float b = (float) lowdown / compcount;
// 将字符串数字转换为整数并进行排序 //用于查询全部的数据
List<Integer> intNumbers = convertAndSort(stringNumbers); List<String> parlint = compService.getallscore(comp.getCompTypeId());
//获取到的上下限 //开始获取排名的倒叙
int result = processInput(intNumbers, comptyp); int rank = insertAndRank(parlint, String.valueOf(comp.getCompOrder()));
//开始获取个数 System.out.println(parlint);
int geshu = compTypeService.getgeshu(comp.getCompTypeId()); int score = (int) (( rank+1) * b + compTypeService.getById(comp.getCompTypeId()).getScorel());
comp.setCompweight(score);
//开始计算中间值
int b = result / geshu; //开始计算同类型其他比赛
//开始获取逆向排名 List<Comp> compList = compService.getAllCompByType(comp.getCompTypeId());
int position = findPosition(intNumbers,comptyp); if (compList.size()>0){
//计算全职 for (int i=0;i<compList.size();i++){
int wei = (intNumbers.size()-position +1) * b+comptyp; System.out.println(compList.get(i).getCompOrder());
comp.setCompweight(wei); 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); compService.save(comp);
return Result.OK("添加成功!"); 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,最小返回列表长度 public static int insertAndRank(List<String> list, String newValue) {
return (position == 0) ? 1 : (intList.size() - position + 1); // 插入新值
} list.add(newValue);
// 排序(如果有需要,这里已经是插入后的状态,但我们为了验证再次排序)
Collections.sort(list, Collections.reverseOrder());
private static List<Integer> convertAndSort(List<String> stringNumbers) { // 排名计算
List<Integer> intNumbers = new ArrayList<>(); int rank = 1;
for (String s : stringNumbers) { int currentRankCount = 1;
intNumbers.add(Integer.parseInt(String.valueOf((int)Double.parseDouble(s)))); String lastValue = list.get(0); // 获取最大值
}
Collections.sort(intNumbers, Collections.reverseOrder()); // 从大到小排序
return intNumbers;
}
private static int processInput(List<Integer> intNumbers, int inputNumber) { for (int i = 1; i <= list.size(); i++) {
// 查找输入的数字在列表中的位置 if (i < list.size() && list.get(i).equals(lastValue)) {
int index = intNumbers.indexOf(inputNumber); // 如果当前值与上一个值相同,则增加并列排名计数
if (index != -1) { // 如果找到了 currentRankCount++;
// 如果是最大的一个数字,用100减去这个数
if (index == 0) {
return 100 - inputNumber;
} else { } 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.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.demo.comp.entity.Comp; import org.jeecg.modules.demo.comp.entity.Comp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -14,8 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0 * @Version: V1.0
*/ */
public interface CompMapper extends BaseMapper<Comp> { 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'") @Select("SELECT COUNT(*) FROM sys_user_role WHERE role_id ='1731948288626339841'")
int getzjint(); int getzjint();
@ -23,4 +22,13 @@ public interface CompMapper extends BaseMapper<Comp> {
@Select("select id from comp where comp_admin=#{ids}") @Select("select id from comp where comp_admin=#{ids}")
List<String> findcompid(String 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 * @Version: V1.0
*/ */
public interface ICompService extends IService<Comp> { public interface ICompService extends IService<Comp> {
List<Comp> getbyAdmin(String username);
int getzjint(); int getzjint();
List<String> findcompid(String ids); 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 @Autowired
private CompMapper compMapper; private CompMapper compMapper;
@Override
public List<Comp> getbyAdmin(String username) {
return compMapper.getbyAdmin(username);
}
@Override @Override
public int getzjint() { public int getzjint() {
return compMapper.getzjint(); return compMapper.getzjint();
@ -35,4 +30,19 @@ public class CompServiceImpl extends ServiceImpl<CompMapper, Comp> implements IC
public List<String> findcompid(String ids) { public List<String> findcompid(String ids) {
return compMapper.findcompid(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") // @RequiresPermissions("CompType:comp_type:add")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<String> add(@RequestBody CompType compType) { public Result<String> add(@RequestBody CompType compType) {
Double score = compType.getScore(); /* Double score = compType.getScore();
String typeName = compType.getTypeName(); String typeName = compType.getTypeName();*/
switch (typeName){ /* switch (typeName){
case "A": case "A":
if (!(score>90&&score<=100)) if (!(score>90&&score<=100))
return Result.error("A类比赛类型需要91-100之间"); return Result.error("A类比赛类型需要91-100之间");
@ -122,7 +122,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
if (!(score>=60&&score<=70)) if (!(score>=60&&score<=70))
return Result.error("D类比赛类型需要60-70之间"); return Result.error("D类比赛类型需要60-70之间");
break; break;
} }*/
compTypeService.save(compType); compTypeService.save(compType);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
@ -138,7 +138,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
// @RequiresPermissions("CompType:comp_type:edit") // @RequiresPermissions("CompType:comp_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody CompType compType) { public Result<String> edit(@RequestBody CompType compType) {
Double score = compType.getScore(); /*Double score = compType.getScore();
String typeName = compType.getTypeName(); String typeName = compType.getTypeName();
switch (typeName){ switch (typeName){
case "A": case "A":
@ -158,7 +158,7 @@ public class CompTypeController extends JeecgController<CompType, ICompTypeServi
if (!(score>60&&score<70)) if (!(score>60&&score<70))
return Result.error("D类比赛类型需要60-70之间"); return Result.error("D类比赛类型需要60-70之间");
break; break;
} }*/
compTypeService.updateById(compType); compTypeService.updateById(compType);
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");

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

@ -17,6 +17,7 @@ enum Api {
pj = '/AnnualCompPoint/annualCompPoint/pj', pj = '/AnnualCompPoint/annualCompPoint/pj',
cjhz = '/AnnualCompPoint/annualCompPoint/cjhz', cjhz = '/AnnualCompPoint/annualCompPoint/cjhz',
tongfenfuping = '/AnnualCompPoint/annualCompPoint/tongfenfuping', 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-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="项目层次" v-bind="validateInfos.objLevel" :labelCol="labelCol" :wrapperCol="wrapperCol7"> <a-form-item label="项目层次1" 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-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-form-item>
</a-col> </a-col>
</a-row> </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 JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue'; import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue';
import {getValueType} from '/@/utils'; import {getValueType} from '/@/utils';
import {saveOrUpdate} from '../AnnualCompPoint.api'; import {saveOrUpdate, getProjectlevel} from '../AnnualCompPoint.api';
import {Form} from 'ant-design-vue'; import {Form} from 'ant-design-vue';
const props = defineProps({ const props = defineProps({
// objLevelll: { type: Array, default: () => [] },
formDisabled: {type: Boolean, default: false}, formDisabled: {type: Boolean, default: false},
formData: { formData: {
type: Object, default: () => { type: Object, default: () => {
@ -237,6 +239,13 @@ const props = defineProps({
}, },
formBpm: {type: Boolean, default: true} 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 formRef = ref();
const useForm = Form.useForm; const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']); const emit = defineEmits(['register', 'ok']);
@ -245,7 +254,7 @@ const formData = reactive<Record<string, any>>({
annualCompId: '', annualCompId: '',
objName: '', objName: '',
introduce: '', introduce: '',
objLevel: '3', objLevel: '',
entryForm: 'Y', entryForm: 'Y',
teamNumber: undefined, teamNumber: undefined,
teacherNumber: undefined, teacherNumber: undefined,
@ -319,7 +328,11 @@ const disabled = computed(() => {
* 新增 * 新增
*/ */
function add() { 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 * @param params
*/ */
export const saveOrUpdate = (params, isUpdate) => { export const saveOrUpdate = (params, isUpdate, handleSuccess) => {
const url = isUpdate ? Api.edit : Api.save; 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) { if (res.success) {
createMessage.success(res.message); createMessage.success(res.message);
emit('ok'); emit('ok');
window.location.reload()
} else { } else {
createMessage.warning(res.message); createMessage.warning(res.message);
} }

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

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

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

Loading…
Cancel
Save