From 4dedf71109f1439caca2c480f3fe299f0d519c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=B6=E4=B8=9C?= <1654135867@qq.com> Date: Sat, 6 Jul 2024 10:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E8=B5=9B=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...petitionProjectRegistrationController.java | 32 ++++-- .../demo/comp/controller/CompController.java | 108 +++++++++--------- .../modules/demo/comp/mapper/CompMapper.java | 12 +- .../demo/comp/service/ICompService.java | 8 +- .../comp/service/impl/CompServiceImpl.java | 20 +++- .../controller/CompTypeController.java | 12 +- .../demo/comptype/entity/CompType.java | 8 +- .../committee/AnnualCompPoint.api.ts | 6 + .../components/AnnualCompPointForm.vue | 25 +++- .../annualcomp/submitted/AnnualComp.api.ts | 6 +- .../annualcomp/submitted/components/Form1.vue | 1 + ...nualCompetitionProjectRegistrationList.vue | 8 +- .../src/views/comptype/CompType.data.ts | 16 ++- .../comptype/components/CompTypeForm.vue | 10 +- 14 files changed, 177 insertions(+), 95 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcompetitionprojectregistration/controller/AnnualCompetitionProjectRegistrationController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcompetitionprojectregistration/controller/AnnualCompetitionProjectRegistrationController.java index b3f7a07b..ca76285c 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcompetitionprojectregistration/controller/AnnualCompetitionProjectRegistrationController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualcompetitionprojectregistration/controller/AnnualCompetitionProjectRegistrationController.java @@ -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 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 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("不需要申请驳回!"); diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/controller/CompController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/controller/CompController.java index 3fc63e4d..252ffaea 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/controller/CompController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/controller/CompController.java @@ -90,11 +90,12 @@ public class CompController extends JeecgController { //角色编码 管理员&教务处 可以看到所有,其它用户可见到所属自己数据 Map 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 { } /*--------------------------王家东添加开始============================*/ - //获取比赛类型comptyp就是类型的分数 - Double comptypeweight = compTypeService.getById(comp.getCompTypeId()).getScore(); - int comptyp = (int) Math.round(comptypeweight); - //开始获取 - /*comp.setCompweight(csort);*/ - List stringNumbers = compTypeService.getALL(); - // 将字符串数字转换为整数并进行排序 - List 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 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 compList = compService.getAllCompByType(comp.getCompTypeId()); + if (compList.size()>0){ + for (int i=0;i 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 list, String newValue) { + // 插入新值 + list.add(newValue); + // 排序(如果有需要,这里已经是插入后的状态,但我们为了验证再次排序) + Collections.sort(list, Collections.reverseOrder()); - private static List convertAndSort(List stringNumbers) { - List 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 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; } /** diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/mapper/CompMapper.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/mapper/CompMapper.java index 81def730..9cf7e291 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/mapper/CompMapper.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/mapper/CompMapper.java @@ -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 { - @Select("select * from comp where comp_admin = #{username}") - List 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 { @Select("select id from comp where comp_admin=#{ids}") List findcompid(String ids); + + @Select("select comp_order from comp where comp_type_id =#{compTypeId}") + List getallscore(String compTypeId); + + @Select("select * from comp where comp_type_id =#{compTypeId}") + List getAllCompByType(String compTypeId); + + @Update("UPDATE comp SET compweight = #{scoreold} WHERE id=#{id}") + void updatedate(String id, int scoreold); } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/ICompService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/ICompService.java index aecd0b70..04c22724 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/ICompService.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/ICompService.java @@ -12,9 +12,15 @@ import java.util.List; * @Version: V1.0 */ public interface ICompService extends IService { - List getbyAdmin(String username); + int getzjint(); List findcompid(String ids); + + List getallscore(String compTypeId); + + List getAllCompByType(String compTypeId); + + void updatedate(String id, int scoreold); } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/impl/CompServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/impl/CompServiceImpl.java index d4eee9f6..44a09494 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/impl/CompServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comp/service/impl/CompServiceImpl.java @@ -21,11 +21,6 @@ public class CompServiceImpl extends ServiceImpl implements IC @Autowired private CompMapper compMapper; - @Override - public List getbyAdmin(String username) { - return compMapper.getbyAdmin(username); - } - @Override public int getzjint() { return compMapper.getzjint(); @@ -35,4 +30,19 @@ public class CompServiceImpl extends ServiceImpl implements IC public List findcompid(String ids) { return compMapper.findcompid(ids); } + + @Override + public List getallscore(String compTypeId) { + return compMapper.getallscore(compTypeId); + } + + @Override + public List getAllCompByType(String compTypeId) { + return compMapper.getAllCompByType(compTypeId); + } + + @Override + public void updatedate(String id, int scoreold) { + compMapper.updatedate(id,scoreold); + } } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/controller/CompTypeController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/controller/CompTypeController.java index 1a328645..649d12e8 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/controller/CompTypeController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/controller/CompTypeController.java @@ -102,9 +102,9 @@ public class CompTypeController extends JeecgController 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=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 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 JeecgController60&&score<70)) return Result.error("D类比赛类型需要60-70之间"); break; - } + }*/ compTypeService.updateById(compType); return Result.OK("编辑成功!"); diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/entity/CompType.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/entity/CompType.java index 32f03467..e3adda23 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/entity/CompType.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/comptype/entity/CompType.java @@ -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; } diff --git a/jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts b/jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts index 4b8cdab0..9a30ef48 100644 --- a/jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts +++ b/jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts @@ -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 }); +}; + diff --git a/jeecgboot-vue3-master/src/views/annualCompPoint/committee/components/AnnualCompPointForm.vue b/jeecgboot-vue3-master/src/views/annualCompPoint/committee/components/AnnualCompPointForm.vue index 36bf3995..a24e4ccb 100644 --- a/jeecgboot-vue3-master/src/views/annualCompPoint/committee/components/AnnualCompPointForm.vue +++ b/jeecgboot-vue3-master/src/views/annualCompPoint/committee/components/AnnualCompPointForm.vue @@ -40,8 +40,10 @@ - - + + + {{ item.name }} + @@ -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>({ 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 }); } /** diff --git a/jeecgboot-vue3-master/src/views/annualcomp/submitted/AnnualComp.api.ts b/jeecgboot-vue3-master/src/views/annualcomp/submitted/AnnualComp.api.ts index 95421e1d..fbb9173e 100644 --- a/jeecgboot-vue3-master/src/views/annualcomp/submitted/AnnualComp.api.ts +++ b/jeecgboot-vue3-master/src/views/annualcomp/submitted/AnnualComp.api.ts @@ -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(); + }); }; diff --git a/jeecgboot-vue3-master/src/views/annualcomp/submitted/components/Form1.vue b/jeecgboot-vue3-master/src/views/annualcomp/submitted/components/Form1.vue index 77bfe108..c98d42a8 100644 --- a/jeecgboot-vue3-master/src/views/annualcomp/submitted/components/Form1.vue +++ b/jeecgboot-vue3-master/src/views/annualcomp/submitted/components/Form1.vue @@ -109,6 +109,7 @@ if (res.success) { createMessage.success(res.message); emit('ok'); + window.location.reload() } else { createMessage.warning(res.message); } diff --git a/jeecgboot-vue3-master/src/views/annualcompetitionprojectregistration/student/AnnualCompetitionProjectRegistrationList.vue b/jeecgboot-vue3-master/src/views/annualcompetitionprojectregistration/student/AnnualCompetitionProjectRegistrationList.vue index 9a7eb784..84bbfb35 100644 --- a/jeecgboot-vue3-master/src/views/annualcompetitionprojectregistration/student/AnnualCompetitionProjectRegistrationList.vue +++ b/jeecgboot-vue3-master/src/views/annualcompetitionprojectregistration/student/AnnualCompetitionProjectRegistrationList.vue @@ -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) { diff --git a/jeecgboot-vue3-master/src/views/comptype/CompType.data.ts b/jeecgboot-vue3-master/src/views/comptype/CompType.data.ts index b2e591e9..b39397de 100644 --- a/jeecgboot-vue3-master/src/views/comptype/CompType.data.ts +++ b/jeecgboot-vue3-master/src/views/comptype/CompType.data.ts @@ -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: '', diff --git a/jeecgboot-vue3-master/src/views/comptype/components/CompTypeForm.vue b/jeecgboot-vue3-master/src/views/comptype/components/CompTypeForm.vue index d06c39f4..c6b29010 100644 --- a/jeecgboot-vue3-master/src/views/comptype/components/CompTypeForm.vue +++ b/jeecgboot-vue3-master/src/views/comptype/components/CompTypeForm.vue @@ -8,8 +8,14 @@ - - + + + + + + + +