Browse Source

update: 培训管理模块逻辑优化

zhongwei
liwen 11 months ago
parent
commit
f8cb1f7cd2
  1. 7
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java
  2. 1
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java
  3. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java
  4. 45
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  5. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java
  6. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

7
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java

@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -32,12 +33,14 @@ public class TrainPlanEntity extends BaseEntity {
private String unit; private String unit;
@NotNull @NotNull
@ApiModelProperty("计划培训开始时间") @JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("计划开始时间")
@ExcelProperty(value = "计划开始时间", index = 6) @ExcelProperty(value = "计划开始时间", index = 6)
private Date scheduledStartTime; private Date scheduledStartTime;
@NotNull @NotNull
@ApiModelProperty("计划培训结束时间") @JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("计划结束时间")
@ExcelProperty(value = "计划结束时间", index = 7) @ExcelProperty(value = "计划结束时间", index = 7)
private Date scheduledEndTime; private Date scheduledEndTime;

1
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java

@ -41,7 +41,6 @@ public class TrainRecordEntity extends BaseEntity {
@ExcelProperty(value = "培训学员", index = 3) @ExcelProperty(value = "培训学员", index = 3)
private String peopleName; private String peopleName;
@Size(max = 5000, message = "培训内容字段长度超出限制范围")
@ApiModelProperty("培训内容") @ApiModelProperty("培训内容")
@ExcelProperty(value = "培训内容", index = 2) @ExcelProperty(value = "培训内容", index = 2)
private String content; private String content;

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java

@ -83,8 +83,8 @@ public class TrainController extends BladeController {
@GetMapping("/trainPlanPage") @GetMapping("/trainPlanPage")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledStartTime", value = "计划培训开始时间", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledEndTime", value = "计划培训结束时间", dataType = "query", paramType = "string") @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string")
}) })
@ApiOperation(value = "培训计划分页") @ApiOperation(value = "培训计划分页")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)

45
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.util.CollectionUtils; import com.alibaba.excel.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.TestDTO; import com.hnac.hzims.safeproduct.dto.TestDTO;
import com.hnac.hzims.safeproduct.entity.TestEntity; import com.hnac.hzims.safeproduct.entity.TestEntity;
@ -14,6 +13,7 @@ import com.hnac.hzims.safeproduct.mapper.TestMapper;
import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.service.ITestScoreService; import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -56,21 +56,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
// 查询是否存在同月编号 // 查询是否存在同月编号
String lastCode = getLastCode(currentMonth); String lastCode = getLastCode(currentMonth);
// 若不存在,新增编号 // 若不存在,新增编号
String code; String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth);
if (StringUtils.isNull(lastCode)) {
code = "KSJL" + currentMonth + "001";
} else { // 若存在,编号递增
String oldNum = lastCode.substring(lastCode.length() - 3);
int value = Integer.parseInt(oldNum) + 1;
// 根据数位拼接编号
if (value < 10) {
code = "KSJL" + currentMonth + "00" + value;
} else if (value < 100) {
code = "KSJL" + currentMonth + "0" + value;
} else {
code = "KSJL" + currentMonth + value;
}
}
testEntity.setCode(code); testEntity.setCode(code);
boolean saveTest = this.save(testEntity); boolean saveTest = this.save(testEntity);
// 若新增考试记录成功,添加相关的参考人员数据 // 若新增考试记录成功,添加相关的参考人员数据
@ -81,13 +67,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
String people = test.getPeopleName(); String people = test.getPeopleName();
String[] person = people.split(",|,"); String[] person = people.split(",|,");
// 新增参考人员成绩数据 // 新增参考人员成绩数据
List<TestScoreEntity> scoreList = new ArrayList<>(); List<TestScoreEntity> scoreList = getReferenceTestScore(test, person);
for(String name : person) {
TestScoreEntity testScoreEntity = new TestScoreEntity();
testScoreEntity.setTestId(test.getId());
testScoreEntity.setName(name);
scoreList.add(testScoreEntity);
}
return R.status(testScoreService.saveBatch(scoreList)); return R.status(testScoreService.saveBatch(scoreList));
} }
return R.fail("新增考试记录失败"); return R.fail("新增考试记录失败");
@ -185,6 +165,20 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
if (removeByIds) { if (removeByIds) {
String[] person = testEntity.getPeopleName().split(",|,"); String[] person = testEntity.getPeopleName().split(",|,");
// 新增参考人员成绩数据 // 新增参考人员成绩数据
List<TestScoreEntity> scoreList = getReferenceTestScore(testEntity, person);
return testScoreService.saveBatch(scoreList);
}
}
return false;
}
/**
* 获取成绩列表
* @param testEntity 考试记录实体类
* @param person 参考人员
* @return 成绩列表
*/
private List<TestScoreEntity> getReferenceTestScore(TestEntity testEntity, String[] person) {
List<TestScoreEntity> res = new ArrayList<>(); List<TestScoreEntity> res = new ArrayList<>();
for (String name : person) { for (String name : person) {
TestScoreEntity testScoreEntity = new TestScoreEntity(); TestScoreEntity testScoreEntity = new TestScoreEntity();
@ -192,10 +186,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
testScoreEntity.setName(name); testScoreEntity.setName(name);
res.add(testScoreEntity); res.add(testScoreEntity);
} }
return testScoreService.saveBatch(res); return res;
}
}
return false;
} }
/** /**

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

@ -63,6 +63,10 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
IPage<TrainMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); IPage<TrainMonthVO> page = new Page<>(query.getCurrent(), query.getSize());
IPage<TrainMonthVO> unitPage = baseMapper.selectByMonth(page, month); IPage<TrainMonthVO> unitPage = baseMapper.selectByMonth(page, month);
List<TrainMonthVO> unitList = unitPage.getRecords(); List<TrainMonthVO> unitList = unitPage.getRecords();
// 若无数据,返回空页面
if (CollectionUtils.isEmpty(unitList)) {
return unitPage;
}
// 查询当月各单位已完成的培训数据 // 查询当月各单位已完成的培训数据
IPage<TrainMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize()); IPage<TrainMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize());
IPage<TrainMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); IPage<TrainMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month);

18
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

@ -10,7 +10,6 @@ import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; import com.hnac.hzims.safeproduct.dto.TrainRecordDTO;
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
@ -20,6 +19,7 @@ import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper; import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper;
import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.service.ITrainRecordService; import com.hnac.hzims.safeproduct.service.ITrainRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -61,21 +61,7 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
// 查询是否存在同月编号 // 查询是否存在同月编号
String lastCode = getLastCode(currentMonth); String lastCode = getLastCode(currentMonth);
// 若不存在,新增编号 // 若不存在,新增编号
String code; String code = BaseUtil.getUniqueCode("PXJL", lastCode, currentMonth);
if (StringUtils.isNull(lastCode)) {
code = "PXJL" + currentMonth + "001";
} else { // 若存在,编号递增
String oldNum = lastCode.substring(lastCode.length() - 3);
int value = Integer.parseInt(oldNum) + 1;
// 根据数位拼接编号
if (value < 10) {
code = "PXJL" + currentMonth + "00" + value;
} else if (value < 100) {
code = "PXJL" + currentMonth + "0" + value;
} else {
code = "PXJL" + currentMonth + value;
}
}
trainRecordEntity.setCode(code); trainRecordEntity.setCode(code);
boolean save = this.save(trainRecordEntity); boolean save = this.save(trainRecordEntity);
// 若培训记录新增成功,修改培训计划状态为已完成 // 若培训记录新增成功,修改培训计划状态为已完成

Loading…
Cancel
Save