|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import com.alibaba.excel.util.CollectionUtils; |
|
|
|
|
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.TestDTO; |
|
|
|
|
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.service.ITestScoreService; |
|
|
|
|
import com.hnac.hzims.safeproduct.service.ITestService; |
|
|
|
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -56,21 +56,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
|
|
|
|
|
// 查询是否存在同月编号
|
|
|
|
|
String lastCode = getLastCode(currentMonth); |
|
|
|
|
// 若不存在,新增编号
|
|
|
|
|
String code; |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth); |
|
|
|
|
testEntity.setCode(code); |
|
|
|
|
boolean saveTest = this.save(testEntity); |
|
|
|
|
// 若新增考试记录成功,添加相关的参考人员数据
|
|
|
|
@ -81,13 +67,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
|
|
|
|
|
String people = test.getPeopleName(); |
|
|
|
|
String[] person = people.split(",|,"); |
|
|
|
|
// 新增参考人员成绩数据
|
|
|
|
|
List<TestScoreEntity> scoreList = new ArrayList<>(); |
|
|
|
|
for(String name : person) { |
|
|
|
|
TestScoreEntity testScoreEntity = new TestScoreEntity(); |
|
|
|
|
testScoreEntity.setTestId(test.getId()); |
|
|
|
|
testScoreEntity.setName(name); |
|
|
|
|
scoreList.add(testScoreEntity); |
|
|
|
|
} |
|
|
|
|
List<TestScoreEntity> scoreList = getReferenceTestScore(test, person); |
|
|
|
|
return R.status(testScoreService.saveBatch(scoreList)); |
|
|
|
|
} |
|
|
|
|
return R.fail("新增考试记录失败"); |
|
|
|
@ -185,6 +165,20 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
|
|
|
|
|
if (removeByIds) { |
|
|
|
|
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<>(); |
|
|
|
|
for (String name : person) { |
|
|
|
|
TestScoreEntity testScoreEntity = new TestScoreEntity(); |
|
|
|
@ -192,10 +186,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
|
|
|
|
|
testScoreEntity.setName(name); |
|
|
|
|
res.add(testScoreEntity); |
|
|
|
|
} |
|
|
|
|
return testScoreService.saveBatch(res); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|