diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiMemberUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiMemberUserController.java index 0da9528846d11610aedcd262240bd80ec80e6053..85f363dfe8d11f31e616444d58cfa1b0de63c0e1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiMemberUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiMemberUserController.java @@ -385,6 +385,7 @@ public class ApiMemberUserController extends BaseController { if (params.containsKey("memberUserId") && StringUtils.isNotBlank(params.get("memberUserId").toString())) { HashMap hashMap = new HashMap<>(); + hashMap.put("isExam", params.get("isExam").toString()); hashMap.put("memberUserId", params.get("memberUserId").toString()); hashMap.put("examStatus", 1); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiRegionController.java b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiRegionController.java new file mode 100644 index 0000000000000000000000000000000000000000..65e41182f94ce9f223c3abd6ec63059479e66782 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiRegionController.java @@ -0,0 +1,41 @@ +package com.ruoyi.hezhi.api.kaoshi; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.hezhi.domain.TbRegion; +import com.ruoyi.hezhi.service.ITbRegionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; + +/** + * 行政区域Controller + * + * @author ruoyi + * @date 2024-10-21 + */ +@RestController +@RequestMapping("/api/pc/region") +public class ApiRegionController extends BaseController +{ + @Autowired + private ITbRegionService tbRegionService; + + /** + * 查询行政区域列表 + */ + @GetMapping("/treeList") + public AjaxResult treeList(TbRegion tbRegion) + { + List list = tbRegionService.selectTbRegionTreeList(tbRegion); + return success(list); + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/hezhi/controller/TbRegionController.java b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/controller/TbRegionController.java index 0e25dbbfa1501115ae9d49bcc37205289fe57ffa..43263eb3dd64d1b3108d47595138b48ee309d509 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/hezhi/controller/TbRegionController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/hezhi/controller/TbRegionController.java @@ -39,6 +39,16 @@ public class TbRegionController extends BaseController return success(list); } + /** + * 查询行政区域列表 + */ + @GetMapping("/treeList") + public AjaxResult treeList(TbRegion tbRegion) + { + List list = tbRegionService.selectTbRegionTreeList(tbRegion); + return success(list); + } + /** * 导出行政区域列表 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/hezhi/mapper/TbRegionMapper.java b/ruoyi-system/src/main/java/com/ruoyi/hezhi/mapper/TbRegionMapper.java index e67032351ce889937cd1e8bd6d34f5aa0fe8161d..feb2e709b00f494314848ecc9d149b3979f13757 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/hezhi/mapper/TbRegionMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/hezhi/mapper/TbRegionMapper.java @@ -38,6 +38,20 @@ public interface TbRegionMapper */ public List selectTbRegionList(TbRegion tbRegion); + /** + * 查询所有省份及其下级(使用JOIN) + * + * @param tbRegion 行政区域 + * @return 行政区域集合 + */ + public List findAllRegions(TbRegion tbRegion); + + // 根据类型查询区域 + List findByType(@Param("type") Integer type); + + // 根据父ID查询子区域 + List findByPid(@Param("pid") Long pid); + /** * 新增行政区域 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/ITbRegionService.java b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/ITbRegionService.java index f863a1495dc4c71d0401f07ecec38682a1fc2326..0fce6959ce82dee9b1f1b0c4ab17fcc3b8e01369 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/ITbRegionService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/ITbRegionService.java @@ -29,6 +29,14 @@ public interface ITbRegionService */ public List selectTbRegionList(TbRegion tbRegion); + /** + * 查询行政区域列表 + * + * @param tbRegion 行政区域 + * @return 行政区域集合 + */ + public List selectTbRegionTreeList(TbRegion tbRegion); + /** * 新增行政区域 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamRegistrationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamRegistrationServiceImpl.java index 28040be83d0c811ed7c4ebccf10911326c37f89a..985262bab48f2f26a495964208c1cf63cec4cd9c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamRegistrationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamRegistrationServiceImpl.java @@ -454,9 +454,21 @@ public class TbExamRegistrationServiceImpl implements ITbExamRegistrationService registration.setGraduationSchool(examRegistrationDTO.getGraduationSchool()); registration.setEntranceYear(examRegistrationDTO.getEntranceYear()); registration.setContactInformation(examRegistrationDTO.getContactInformation()); - registration.setProvinceId(examRegistrationDTO.getProvinceId()); - registration.setCityId(examRegistrationDTO.getCityId()); - registration.setAreaId(examRegistrationDTO.getAreaId()); + if (null != examRegistrationDTO.getProvinceId()) { + registration.setProvinceId(examRegistrationDTO.getProvinceId()); + TbRegion region = tbRegionMapper.selectTbRegionById(registration.getProvinceId()); + registration.setProvinceName(null != region ? region.getName(): null); + } + if (null != examRegistrationDTO.getCityId()) { + registration.setCityId(examRegistrationDTO.getCityId()); + TbRegion region = tbRegionMapper.selectTbRegionById(registration.getCityId()); + registration.setCityName(null != region ? region.getName(): null); + } + if (null != examRegistrationDTO.getAreaId()) { + registration.setAreaId(examRegistrationDTO.getAreaId()); + TbRegion region = tbRegionMapper.selectTbRegionById(registration.getAreaId()); + registration.setAreaName(null != region ? region.getName(): null); + } registration.setAddress(examRegistrationDTO.getAddress()); registration.setZipCode(examRegistrationDTO.getZipCode()); registration.setContactPhone(examRegistrationDTO.getContactPhone()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamServiceImpl.java index 107fd2522b0bde2f5a29ba832839eec5e2094238..074045418df0d78aceb65ce1170369af82a79e57 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbExamServiceImpl.java @@ -192,6 +192,7 @@ public class TbExamServiceImpl implements ITbExamService * @param tbExam 考试 * @return 结果 */ + @Transactional(rollbackFor = Exception.class) @Override public int updateTbExam(TbExam tbExam) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbRegionServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbRegionServiceImpl.java index 72e0267b8828be75f04f9c8e46c3d4548028f543..26f12a72a59c773e320df5416fc87c2ed0a6b718 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbRegionServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/hezhi/service/impl/TbRegionServiceImpl.java @@ -47,6 +47,32 @@ public class TbRegionServiceImpl implements ITbRegionService return tbRegionMapper.selectTbRegionList(tbRegion); } + /** + * 查询行政区域列表 + * + * @param tbRegion 行政区域 + * @return 行政区域集合 + */ + @Override + public List selectTbRegionTreeList(TbRegion tbRegion) { + // 1. 查询所有省份 + List provinces = tbRegionMapper.findByType(1); + + // 2. 为每个省份查询城市 + for (TbRegion province : provinces) { + List cities = tbRegionMapper.findByPid(province.getId()); + + // 3. 为每个城市查询区县 + for (TbRegion city : cities) { + List districts = tbRegionMapper.findByPid(city.getId()); + city.setChildren(districts); + } + province.setChildren(cities); + } + + return provinces; + } + /** * 新增行政区域 * diff --git a/ruoyi-system/src/main/resources/mapper/hezhi/TbExamRegistrationMapper.xml b/ruoyi-system/src/main/resources/mapper/hezhi/TbExamRegistrationMapper.xml index cc5892e2329d295a4e8d1a8c487f9a53b18d89c1..5d5018052d0c615c8d661e60a4955a2de0e4cb12 100644 --- a/ruoyi-system/src/main/resources/mapper/hezhi/TbExamRegistrationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/hezhi/TbExamRegistrationMapper.xml @@ -889,7 +889,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ter.pay_type AS payType, CONVERT(IFNULL(te.name, ''), CHAR) AS examName, tmo.pay_price AS payPrice, - CONVERT(IFNULL(ter.registration_batch, ''), CHAR) AS registrationBatch, + CONVERT(IFNULL(teb.exam_batch, ''), CHAR) AS registrationBatch, CONVERT(IFNULL(DATE_FORMAT(teb.exam_start_time,'%Y-%m-%d %H:%i:%s'), ''), CHAR) AS examStartTime, CONVERT(IFNULL(DATE_FORMAT(teb.exam_end_time,'%Y-%m-%d %H:%i:%s'), ''), CHAR) AS examEndTime, @@ -919,18 +919,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE tsc.member_user_id = ter.member_user_id AND tsc.course_id = ter.course_id) AS total from tb_exam_registration ter - INNER JOIN ( - SELECT exam_id, MAX(create_time) as create_time - FROM tb_exam_registration - WHERE STATUS = 0 AND del_flag = 0 - - and member_user_id = #{memberUserId} - - - and is_pay = #{isPay} - - GROUP BY exam_id - ) AS ter2 ON ter.create_time = ter2.create_time and ter.exam_id = ter2.exam_id + + INNER JOIN ( + SELECT exam_id, MAX(create_time) as create_time + FROM tb_exam_registration + WHERE STATUS = 0 AND del_flag = 0 + + and member_user_id = #{memberUserId} + + + and is_pay = #{isPay} + + GROUP BY exam_id + ) AS ter2 ON ter.create_time = ter2.create_time and ter.exam_id = ter2.exam_id + left join tb_course tc on tc.course_id = ter.course_id left join tb_member_order tmo on tmo.data_id = ter.exam_registration_id left join tb_exam te on ter.exam_id = te.exam_id @@ -973,8 +975,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ter.is_pay = #{isPay} - GROUP BY - ter.exam_id + + + GROUP BY ter.exam_id + + + GROUP BY ter.exam_registration_id + + order by ter.create_time desc diff --git a/ruoyi-system/src/main/resources/mapper/hezhi/TbRegionMapper.xml b/ruoyi-system/src/main/resources/mapper/hezhi/TbRegionMapper.xml index 6fdc7d56437f010aed0174e737cc50031be8213f..5a3ed506e6229bd89190c7e239c1f03b3978dcbc 100644 --- a/ruoyi-system/src/main/resources/mapper/hezhi/TbRegionMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/hezhi/TbRegionMapper.xml @@ -173,4 +173,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + diff --git a/ruoyi-ui/src/views/hezhi/exam/examBatch.vue b/ruoyi-ui/src/views/hezhi/exam/examBatch.vue index a4a273fff97ccab5dd91cd932594717b68465802..fe04613bd462a7c5a008f21d49a91d39797e00c5 100644 --- a/ruoyi-ui/src/views/hezhi/exam/examBatch.vue +++ b/ruoyi-ui/src/views/hezhi/exam/examBatch.vue @@ -60,7 +60,7 @@ - + @@ -83,7 +83,9 @@ v-model="form.examStartTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" - placeholder="选择考试开始时间"> + placeholder="选择考试开始时间" + style="width: 100%" + > @@ -91,7 +93,8 @@ v-model="form.examEndTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" - placeholder="选择考试结束时间"> + placeholder="选择考试结束时间" + style="width: 100%">