From ed99549b99b711fd47ce8efcae02b954afe32768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Mon, 23 Sep 2024 10:25:51 +0800 Subject: [PATCH] =?UTF-8?q?9.23=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HitCompetitionStudentInfoController.java | 7 +- .../cms/domain/HitCompetitionStudentInfo.java | 3 +- .../vo/HitCompetitionStudentInfoImportVo.java | 131 ++++++++++++++++++ .../IHitCompetitionStudentInfoService.java | 3 +- .../HitCompetitionStudentInfoServiceImpl.java | 24 +++- 5 files changed, 156 insertions(+), 12 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/HitCompetitionStudentInfoImportVo.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java index fa4c7fa..1ba1b59 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/HitCompetitionStudentInfoController.java @@ -1,5 +1,6 @@ package com.ruoyi.cms.controller; +import com.ruoyi.cms.domain.vo.HitCompetitionStudentInfoImportVo; import com.ruoyi.common.annotation.Log; import com.ruoyi.cms.domain.HitCompetitionStudentInfo; import com.ruoyi.cms.service.IHitCompetitionStudentInfoService; @@ -176,15 +177,15 @@ public class HitCompetitionStudentInfoController extends BaseController { @PostMapping("/importTemplate") public void importTemplate(HttpServletResponse response) { - ExcelUtil util = new ExcelUtil(HitCompetitionStudentInfo.class); + ExcelUtil util = new ExcelUtil<>(HitCompetitionStudentInfoImportVo.class); util.importTemplateExcel(response, "用户数据"); } @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { - ExcelUtil util = new ExcelUtil(HitCompetitionStudentInfo.class); - List hitList = util.importExcel(file.getInputStream()); + ExcelUtil util = new ExcelUtil<>(HitCompetitionStudentInfoImportVo.class); + List hitList = util.importExcel(file.getInputStream()); String message = hitCompetitionStudentInfoService.importData(hitList); return success(message); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java index 32b3251..02becde 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/HitCompetitionStudentInfo.java @@ -22,6 +22,7 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import static com.ruoyi.common.annotation.Excel.Type.EXPORT; +import static com.ruoyi.common.annotation.Excel.Type.IMPORT; /** *

@@ -90,7 +91,7 @@ public class HitCompetitionStudentInfo implements Serializable { @ApiModelProperty(value = "学生证") private String studentIdCard; -// @Excel(name = "个人选拔赛分数") + @Excel(name = "个人选拔赛分数",type = IMPORT) @ApiModelProperty(value = "个人选拔赛分数") private BigDecimal trialsScore; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/HitCompetitionStudentInfoImportVo.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/HitCompetitionStudentInfoImportVo.java new file mode 100644 index 0000000..2d4623b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/HitCompetitionStudentInfoImportVo.java @@ -0,0 +1,131 @@ +package com.ruoyi.cms.domain.vo; + +import com.baomidou.mybatisplus.annotation.*; +import com.ruoyi.cms.domain.HitRegInfo; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.HitRegistrationTeachInfo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +import static com.ruoyi.common.annotation.Excel.Type.EXPORT; +import static com.ruoyi.common.annotation.Excel.Type.IMPORT; + +/** + *

+ * 大赛学生表 + *

+ * + * @author author + * @since 2024-08-26 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("hit_competition_student_info") +@ApiModel(value="HitCompetitionStudentInfo对象", description="大赛学生表") +public class HitCompetitionStudentInfoImportVo implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "团队报名主键") + private String hitRegId; + +// @Excel(name = "学生姓名",type = EXPORT) + @ApiModelProperty(value = "学生姓名") + private String stuName; + + //用户主键 + private Long userId; + + @ApiModelProperty(value = "学号") + private String studentId; + +// @Excel(name = "学校名称",type = EXPORT) + @ApiModelProperty(value = "学校名称") + private String schoolName; + +// @Excel(name = "院系名称",type = EXPORT) + @ApiModelProperty(value = "院系名称") + private String collegeName; + private String sex; + + @ApiModelProperty(value = "专业") + private String major; + +// @Excel(name = "所属赛区",type = EXPORT) + @ApiModelProperty(value = "所属赛区") + private String division; + + @TableField(exist = false) + private String competition; + + + @TableField(exist = false) + private String divisionLabel; + + @Excel(name = "手机号") + @ApiModelProperty(value = "手机号") + private String phoneNumber; + +// @Excel(name = "邮箱",type = EXPORT) + @ApiModelProperty(value = "邮箱") + private String email; + + @ApiModelProperty(value = "学生证") + private String studentIdCard; + + @Excel(name = "个人选拔赛分数") + @ApiModelProperty(value = "个人选拔赛分数") + private BigDecimal trialsScore; + +// @Excel(name = "是否被选为参加地区选拔赛人员", readConverterExp = "false=待审核,true=已入选",type = EXPORT) + @ApiModelProperty(value = "是否被选为参加初赛人员 (0: 否, 1: 是)") + private Boolean isPreliminary; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "逻辑删除 0未删除 1真删除") + private Boolean delFlag; + +// @Excel(name = "报名时间", dateFormat = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建时间(默认时间当前)") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "创建人") + private String createBy; + + @ApiModelProperty(value = "更新时间(默认时间当前)") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + @ApiModelProperty(value = "更新人") + private String updateBy; + @TableField(exist = false) + private String year; + @TableField(exist = false) + private HitRegistrationTeachInfo ldTeacherInfo; + @TableField(exist = false) + private List zdTeacherList; + @TableField(exist = false) + private List tdStudentList; + @TableField(exist = false) + private String zdStatus; + @TableField(exist = false) + private HitRegInfo hitRegInfo; + @TableField(exist = false) + private String zdTeacherStr; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/IHitCompetitionStudentInfoService.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/IHitCompetitionStudentInfoService.java index 028c635..c882a34 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/IHitCompetitionStudentInfoService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/IHitCompetitionStudentInfoService.java @@ -3,6 +3,7 @@ package com.ruoyi.cms.service; import com.ruoyi.cms.domain.HitCompetitionStudentInfo; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.cms.domain.HitTeamMembers; +import com.ruoyi.cms.domain.vo.HitCompetitionStudentInfoImportVo; import com.ruoyi.cms.domain.vo.TeamsVo; import java.util.List; @@ -98,5 +99,5 @@ public interface IHitCompetitionStudentInfoService extends IService hitList); + String importData(List hitList); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/HitCompetitionStudentInfoServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/HitCompetitionStudentInfoServiceImpl.java index c7d5b5c..b518698 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/HitCompetitionStudentInfoServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/HitCompetitionStudentInfoServiceImpl.java @@ -1,10 +1,12 @@ package com.ruoyi.cms.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.cms.domain.*; +import com.ruoyi.cms.domain.vo.HitCompetitionStudentInfoImportVo; import com.ruoyi.cms.domain.vo.TeamsVo; import com.ruoyi.cms.mapper.HitCompetitionStudentInfoMapper; import com.ruoyi.cms.mapper.HitRegistrationTeachInfoMapper; @@ -157,6 +159,7 @@ public class HitCompetitionStudentInfoServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(HitCompetitionStudentInfo::getSchoolName, hitCompetitionStudentInfo.getSchoolName()); + queryWrapper.eq(HitCompetitionStudentInfo::getIsPreliminary,true); DateTime now = DateUtil.date(); DateTime dateTime = DateUtil.beginOfYear(now); DateTime dateTime1 = DateUtil.endOfYear(now); @@ -364,7 +367,7 @@ public class HitCompetitionStudentInfoServiceImpl extends ServiceImpl hitList) { + public String importData(List hitList) { //获取当前时间 DateTime now = DateUtil.date(); Date date = new Date(); @@ -377,12 +380,19 @@ public class HitCompetitionStudentInfoServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); -// queryWrapper.likeRight(HitCompetitionStudentInfo::getYear, year); - queryWrapper.eq(HitCompetitionStudentInfo::getPhoneNumber, item.getPhoneNumber()); - queryWrapper.between(HitCompetitionStudentInfo::getCreateTime, DateUtil.beginOfYear(now), DateUtil.endOfYear(now)); - item.setUpdateTime(date); - hitCompetitionStudentInfoMapper.update(item, queryWrapper); + //添加trycatch 如果报错继续往下面修改 + try { + HitCompetitionStudentInfo hitCompetitionStudentInfo = BeanUtil.copyProperties(item, HitCompetitionStudentInfo.class); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HitCompetitionStudentInfo::getPhoneNumber, item.getPhoneNumber()); + queryWrapper.between(HitCompetitionStudentInfo::getCreateTime, DateUtil.beginOfYear(now), DateUtil.endOfYear(now)); + item.setUpdateTime(date); + hitCompetitionStudentInfo.setUpdateTime(date); + hitCompetitionStudentInfoMapper.update(hitCompetitionStudentInfo, queryWrapper); + } catch (Exception e){ + log.error("更新学生信息失败,phoneNumber: " + item.getPhoneNumber(), e); + } + } });