Browse Source

update: 更新培训管理部分逻辑

zhongwei
liwen 11 months ago
parent
commit
5d8bbbb678
  1. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java
  2. 31
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/TrainStatusEnum.java
  3. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java
  4. 3
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java
  5. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml
  6. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml
  7. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  8. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  9. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java

@ -8,6 +8,9 @@ package com.hnac.hzims.safeproduct.constants;
*/
public interface SafeProductConstant {
int SUCCESS = 1;
int FAILURE = 0;
int TRAIN_PLAN_HAS_TEST = 1;
int TRAIN_PLAN_HAS_NO_TEST = 0;
}

31
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/TrainStatusEnum.java

@ -0,0 +1,31 @@
package com.hnac.hzims.safeproduct.enums;
/**
* 培训计划状态枚举类
*
* @author liwen
* @date 2023-12-27
*/
public enum TrainStatusEnum {
WAITING("WAITING", "未开始"),
UNFINISHED("UNFINISHED", "未完成"),
FINISHED("FINISHED", "已完成");
private final String value;
private final String desc;
TrainStatusEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
}

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java

@ -12,6 +12,9 @@ import lombok.Data;
@ApiModel(value = "考试成绩VO类")
public class TestScoreVO {
@ApiModelProperty("考试成绩id")
private Long id;
@ApiModelProperty("姓名")
private String name;

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

@ -175,6 +175,7 @@ public class TrainController extends BladeController {
@GetMapping("/testPage")
@ApiImplicitParams({
@ApiImplicitParam(name = "trainPlanId", value = "培训计划id", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "trainRecordId", value = "培训记录id", dataType = "query", paramType = "string")
})
@ApiOperation(value = "考试记录分页")
@ -203,7 +204,7 @@ public class TrainController extends BladeController {
@PostMapping("/updateBatchScore")
@ApiOperation(value = "批量填写分数")
@ApiOperationSupport(order = 19)
public R updateBatchScore(TestScoreDTO testScoreDTO) {
public R updateBatchScore(@RequestBody TestScoreDTO testScoreDTO) {
return R.status(testScoreService.updateBatchScore(testScoreDTO));
}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml

@ -4,7 +4,7 @@
<select id="testScoreList" resultType="com.hnac.hzims.safeproduct.vo.TestScoreVO">
SELECT
name, score
id, name, score
FROM
hzims_test_score
WHERE

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml

@ -9,7 +9,7 @@
hzims_train_plan
WHERE
is_deleted = 0
AND scheduled_train_time like concat('%', #{month}, '%')
AND scheduled_end_time like concat('%', #{month}, '%')
GROUP BY
unit
ORDER BY
@ -23,7 +23,7 @@
hzims_train_plan
WHERE
is_deleted = 0
AND scheduled_train_time like concat('%', #{month}, '%')
AND scheduled_end_time like concat('%', #{month}, '%')
AND train_status = 'FINISHED'
GROUP BY
unit
@ -38,26 +38,26 @@
hzims_train_plan
WHERE
is_deleted = 0
AND actual_train_time like concat('%', #{year}, '%')
AND scheduled_end_time like concat('%', #{year}, '%')
ORDER BY
unit
</select>
<select id="selectFinishedDataByUnit" resultType="com.hnac.hzims.safeproduct.dto.AnalysisYearDTO">
SELECT
unit, DATE_FORMAT(actual_train_time, '%m') as dateTime, count(1) as finished_num
unit, DATE_FORMAT(scheduled_end_time, '%m') as dateTime, count(1) as finished_num
FROM
hzims_train_plan
WHERE
is_deleted = 0
AND actual_train_time like concat('%', #{year}, '%')
AND scheduled_end_time like concat('%', #{year}, '%')
AND train_status = 'FINISHED'
AND unit in
<foreach collection="unitList" item="unit" open="(" close=")" separator=",">
#{unit}
</foreach>
GROUP BY
unit, DATE_FORMAT(actual_train_time, '%m')
unit, DATE_FORMAT(scheduled_end_time, '%m')
ORDER BY
unit
</select>

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java

@ -41,6 +41,7 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
scoreList.forEach(score -> {
TestScoreEntity testScoreEntity = new TestScoreEntity();
BeanUtils.copyProperties(score, testScoreEntity);
testScoreEntity.setTestId(testScoreDTO.getTestId());
testScoreEntities.add(testScoreEntity);
});
return this.updateBatchById(testScoreEntities);

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

@ -14,7 +14,6 @@ import com.hnac.hzims.safeproduct.mapper.TestMapper;
import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.vo.TestScoreVO;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -24,6 +23,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 考试记录服务实现类
@ -175,7 +175,8 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
}
// 若存在变化,查询并删除关联考试成绩
List<TestScoreEntity> testScoreList = testScoreService.getRelativeTestScore(testEntity.getId());
boolean removeByIds = testScoreService.removeByIds(testScoreList);
List<Long> scoreIds = testScoreList.stream().map(TestScoreEntity::getId).collect(Collectors.toList());
boolean removeByIds = testScoreService.removeByIds(scoreIds);
// 若删除成功,新增新的考试成绩数据
if (removeByIds) {
String[] person = testEntity.getPeopleName().split(",|,");

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

@ -11,10 +11,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.dto.TrainRecordDTO;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
import com.hnac.hzims.safeproduct.entity.TrainRecordEntity;
import com.hnac.hzims.safeproduct.enums.TrainStatusEnum;
import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper;
import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.service.ITrainRecordService;
@ -23,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -43,9 +46,13 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
@Autowired
ITestService testService;
@Resource
TrainPlanMapper trainPlanMapper;
/**
* 新增培训记录
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveTrainRecord(TrainRecordEntity trainRecordEntity) {
// 获取当月时间(yyyymm)
@ -69,7 +76,14 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train
}
}
trainRecordEntity.setCode(code);
return this.save(trainRecordEntity);
boolean save = this.save(trainRecordEntity);
// 若培训记录新增成功,修改培训计划状态为已完成
if (save) {
TrainPlanEntity trainPlanEntity = trainPlanMapper.selectById(trainRecordEntity.getTrainPlanId());
trainPlanEntity.setTrainStatus(TrainStatusEnum.FINISHED.getValue());
return trainPlanMapper.updateById(trainPlanEntity) == SafeProductConstant.SUCCESS;
}
return false;
}
/**

Loading…
Cancel
Save