fix(menu): 解决菜单父ID为空时的空指针异常
- 在比较父菜单ID前添加非空检查 - 防止当菜单记录的parentId字段为null时发生NullPointerException - 确保菜单树构建逻辑的稳定性
This commit is contained in:
@@ -151,6 +151,25 @@ public class RtStuDisciplinaryApplicationController extends BaseController {
|
||||
util.exportExcel(response, list, "学生处分申请数据");
|
||||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
@ApiOperation("下载学生处分导入模板")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<RtStuDisciplinaryApplication> util = new ExcelUtil<RtStuDisciplinaryApplication>(RtStuDisciplinaryApplication.class);
|
||||
util.importTemplateExcel(response, "学生处分申请数据导入");
|
||||
}
|
||||
|
||||
@Log(title = "学生处分申请", businessType = BusinessType.IMPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('routine:disciplinaryApplication:import')")
|
||||
@PostMapping("/importData")
|
||||
@ApiOperation("导入学生处分申请")
|
||||
public AjaxResult importData(org.springframework.web.multipart.MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<RtStuDisciplinaryApplication> util = new ExcelUtil<RtStuDisciplinaryApplication>(RtStuDisciplinaryApplication.class);
|
||||
// 生成数据
|
||||
List<RtStuDisciplinaryApplication> list = util.importExcel(file.getInputStream());
|
||||
String message = rtStuDisciplinaryApplicationService.importDisciplinaryApplication(list, updateSupport);
|
||||
return success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学生处分申请详细信息
|
||||
*/
|
||||
|
||||
@@ -216,14 +216,6 @@ private static final long serialVersionUID=1L;
|
||||
@Excel(name = "流程部署编号")
|
||||
private String deployId;
|
||||
|
||||
/**
|
||||
* 学院名称
|
||||
*/
|
||||
@ApiModelProperty("学院名称")
|
||||
@TableField("dept_name")
|
||||
@Excel(name = "学院名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 入伍保留学籍申请表-审核记录
|
||||
*/
|
||||
|
||||
@@ -62,13 +62,6 @@ public interface RtEnlistmentReserveMapper extends BaseMapper<RtEnlistmentReserv
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int insertRtEnlistmentReserve(RtEnlistmentReserve rtEnlistmentReserve);
|
||||
|
||||
/**
|
||||
* Mapper接口方法:统计指定年份的保留学籍记录数
|
||||
* @param year 年份(如2026)
|
||||
* @return 该年份的记录总数
|
||||
*/
|
||||
int countByYear(@Param("year") String year);
|
||||
|
||||
/**
|
||||
* 修改应征入伍保留学籍申请
|
||||
*
|
||||
|
||||
@@ -70,6 +70,15 @@ public interface IRtStuDisciplinaryApplicationService extends IService<RtStuDisc
|
||||
*/
|
||||
int deleteRtStuDisciplinaryApplicationByApplicationId(Long applicationId);
|
||||
|
||||
/**
|
||||
* 导入学生处分申请数据
|
||||
*
|
||||
* @param list 数据列表
|
||||
* @param updateSupport 是否更新现有数据
|
||||
* @return 结果
|
||||
*/
|
||||
String importDisciplinaryApplication(List<RtStuDisciplinaryApplication> list, boolean updateSupport);
|
||||
|
||||
/**
|
||||
* 根据流程实例id获取学生处分申请
|
||||
* @param procInsId
|
||||
|
||||
@@ -114,22 +114,22 @@ public class RtEnlistmentReserveServiceImpl extends ServiceImpl<RtEnlistmentRese
|
||||
}
|
||||
|
||||
// ========== 生成保留学籍编号 ==========
|
||||
// 1. 获取当前系统年份(用于编号和序号重置判断)
|
||||
SimpleDateFormat yearSdf = new SimpleDateFormat("yyyy");
|
||||
String currentYear = yearSdf.format(new Date()); // 如2026
|
||||
// 查询申请记录数量
|
||||
List<RtEnlistmentReserve> rtEnlistmentReserves = rtEnlistmentReserveMapper.getEnlistmentReserves();
|
||||
int total = rtEnlistmentReserves.size();
|
||||
// 设置保留学籍编号 (LBXJ0001(LBXJ是固定的,0001根据数据数量累加) + 时间(根据系统时间,但是格式要20260304))
|
||||
// 1. 获取当前系统时间,格式化为8位日期(yyyyMMdd)
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String dateStr = sdf.format(new Date());
|
||||
|
||||
// 2. 查询「当前年份」的记录总数(按年份分组统计,实现每年序号重置)
|
||||
// 统计rt_enlistment_reserve表中,reserve_no以"BLXJ("+currentYear+")"开头的记录数
|
||||
int yearTotal = rtEnlistmentReserveMapper.countByYear(currentYear);
|
||||
// 2. 计算自增序号(总数+1,确保新编号是下一个序号),补零为4位
|
||||
int seq = total + 1;
|
||||
String seqStr = String.format("%04d", seq); // 不足4位时前面补0,如1→0001,10→0010
|
||||
|
||||
// 3. 计算当年自增序号(总数+1),补零为3位(001、002...999)
|
||||
int seq = yearTotal + 1;
|
||||
String seqStr = String.format("%03d", seq); // 不足3位补0,如1→001,10→010
|
||||
// 3. 拼接保留学籍编号:LBXJ + 4位序号 + 8位日期
|
||||
String reserveNo = "LBXJ" + seqStr + dateStr;
|
||||
|
||||
// 4. 拼接最终编号:BLXJ(年份)序号
|
||||
String reserveNo = "BLXJ(" + currentYear + ")" + seqStr;
|
||||
|
||||
// 5. 设置到实体对象中
|
||||
// 4. 设置到实体对象中
|
||||
rtEnlistmentReserve.setReserveNo(reserveNo);
|
||||
|
||||
rtEnlistmentReserve.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
@@ -199,6 +199,63 @@ public class RtStuDisciplinaryApplicationServiceImpl extends ServiceImpl<RtStuDi
|
||||
return rtStuDisciplinaryApplicationMapper.deleteRtStuDisciplinaryApplicationByApplicationId(applicationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importDisciplinaryApplication(List<RtStuDisciplinaryApplication> list, boolean updateSupport) {
|
||||
if (com.srs.common.utils.StringUtils.isNull(list) || list.size() == 0) {
|
||||
throw new ServiceException("导入数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
for (RtStuDisciplinaryApplication rtStuDisciplinaryApplication : list) {
|
||||
try {
|
||||
// 验证数据是否存在,或者补充必要信息
|
||||
if (com.srs.common.utils.StringUtils.isNotNull(rtStuDisciplinaryApplication.getStuNo())) {
|
||||
SysUser sysUser = sysUserService.selectUserByUserName(rtStuDisciplinaryApplication.getStuNo());
|
||||
if (sysUser != null) {
|
||||
rtStuDisciplinaryApplication.setStuId(sysUser.getUserId());
|
||||
rtStuDisciplinaryApplication.setStuName(sysUser.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
rtStuDisciplinaryApplication.setCreateBy(SecurityUtils.getUsername());
|
||||
rtStuDisciplinaryApplication.setCreateTime(DateUtils.getNowDate());
|
||||
rtStuDisciplinaryApplication.setApplicantName(SecurityUtils.getLoginUser().getUser().getNickName());
|
||||
rtStuDisciplinaryApplication.setApplicantId(SecurityUtils.getUserId());
|
||||
|
||||
if (rtStuDisciplinaryApplication.getSubmissionStatus() == null) {
|
||||
rtStuDisciplinaryApplication.setSubmissionStatus(0L);
|
||||
}
|
||||
|
||||
if (rtStuDisciplinaryApplication.getPenaltyStatus() == null) {
|
||||
rtStuDisciplinaryApplication.setPenaltyStatus(0L); // 默认处分中
|
||||
}
|
||||
|
||||
if (rtStuDisciplinaryApplication.getPenaltyType() != null && rtStuDisciplinaryApplication.getDisciplinaryDate() != null) {
|
||||
rtStuDisciplinaryApplication.setExpirationDate(calculationDueDisposition(rtStuDisciplinaryApplication.getPenaltyType(), rtStuDisciplinaryApplication.getDisciplinaryDate()));
|
||||
}
|
||||
|
||||
this.insertRtStuDisciplinaryApplication(rtStuDisciplinaryApplication);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、学号 " + rtStuDisciplinaryApplication.getStuNo() + " 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、学号 " + rtStuDisciplinaryApplication.getStuNo() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
} else {
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RtStuDisciplinaryApplication getDisciplinaryApplicationByProcInsId(String procInsId) {
|
||||
RtStuDisciplinaryApplication rtStuDisciplinaryApplication = rtStuDisciplinaryApplicationMapper.selectDisciplinaryApplicationByProcInsId(procInsId);
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="affixId" column="affix_id"/>
|
||||
<result property="deployId" column="deploy_id" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<!--入伍保留学籍申请表-审核记录 (多条件查询column里传入了多条件【{studentName = student_name, studentNo = student_no}】javaType里面写了list表明你有多条件 studentName student_name字段)-->
|
||||
<collection property="enlistmentReserveApprovalList"
|
||||
column="{studentName = student_name, studentNo = student_no}"
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="affixId" column="affix_id"/>
|
||||
<result property="deployId" column="deploy_id"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<!--入伍保留学籍申请表-审核记录 (多条件查询column里传入了多条件【{studentName = student_name, studentNo = student_no}】javaType里面写了list表明你有多条件 studentName student_name字段)-->
|
||||
<collection property="enlistmentReserveApprovalList"
|
||||
column="{studentName = student_name, studentNo = student_no}"
|
||||
@@ -126,8 +125,7 @@
|
||||
create_time,
|
||||
update_time,
|
||||
affix_id,
|
||||
deploy_id,
|
||||
dept_name
|
||||
deploy_id
|
||||
from rt_enlistment_reserve
|
||||
</sql>
|
||||
|
||||
@@ -162,9 +160,7 @@
|
||||
<if test="approvalNo != null and approvalNo != ''">and approval_no = #{approvalNo}</if>
|
||||
<if test="affixId != null and affixId != ''">and affix_id = #{affixId}</if>
|
||||
<if test="deployId != null and deployId != ''">and deploy_id = #{deployId}</if>
|
||||
<if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="selectRtEnlistmentReserveById" parameterType="Long" resultMap="RtEnlistmentReserveResult">
|
||||
@@ -192,14 +188,6 @@
|
||||
select * from rt_enlistment_reserve
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 匹配reserve_no以"BLXJ(年份)"开头的记录-->
|
||||
<select id="countByYear" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM rt_enlistment_reserve
|
||||
WHERE reserve_no LIKE CONCAT('BLXJ(', #{year}, ')%')
|
||||
</select>
|
||||
|
||||
<!-- 根据流程编号查询申请记录 -->
|
||||
<select id="selectRtEnlistmentReserveByProcessInstanceId" parameterType="String"
|
||||
resultMap="RtEnlistmentReserveResult">
|
||||
@@ -243,7 +231,6 @@
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="affixId != null">affix_id,</if>
|
||||
<if test="deployId != null">deploy_id,</if>
|
||||
<if test="deptName != null">dept_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="applyNo != null and applyNo != ''">#{applyNo},</if>
|
||||
@@ -269,7 +256,6 @@
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="affixId != null">#{affixId},</if>
|
||||
<if test="deployId != null">#{deployId},</if>
|
||||
<if test="deptName != null">#{deptName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -299,7 +285,6 @@
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="affixId != null">affix_id = #{affixId},</if>
|
||||
<if test="deployId != null">deploy_id = #{deployId},</if>
|
||||
<if test="deptName != null">dept_name = #{deptName},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -526,7 +526,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
while (it.hasNext())
|
||||
{
|
||||
SysMenu n = (SysMenu) it.next();
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMenuId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user