培训计划管理上传修改

master
徐杰盟 2024-11-15 14:52:02 +08:00
parent 120bad3358
commit f9d0aad3fb
1 changed files with 33 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import com.gunshi.project.xyt.service.FileAssociationsService;
import com.gunshi.project.xyt.service.PersonnelPlanService;
import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Update;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
@ -182,8 +183,12 @@ public class PersonnelPlanController extends AbstractCommonFileController {
List<PersonnelPlan> plans = util.importExcel(file.getInputStream());
if (CollectionUtils.isNotEmpty(plans)) {
checkData(plans);
Date regDate = new Date();
plans.forEach(o -> o.setId(IdWorker.getId()).setRegDate(regDate));
plans.forEach(o -> o.setId(IdWorker.getId())
.setRegDate(regDate)
.setStatus(1)
.setApplicant(SecurityUtils.getUsername()));
boolean b = service.saveBatch(plans);
if (!b) {
throw new IllegalArgumentException("上传失败");
@ -193,6 +198,33 @@ public class PersonnelPlanController extends AbstractCommonFileController {
return R.ok(plans);
}
/**
*
* name type,stm ,etm , , addr, unit, content,numPeople,scope
* stm etm
*/
private void checkData(List<PersonnelPlan> list){
if (CollectionUtils.isEmpty(list)){
throw new IllegalArgumentException("上传数据为空");
}
long count = list.stream().filter(o ->
StringUtils.isBlank(o.getName())
|| Objects.isNull(o.getType())
|| Objects.isNull(o.getStm())
|| Objects.isNull(o.getEtm())
|| Objects.isNull(o.getNumPeople())
|| StringUtils.isBlank(o.getAddr())
|| StringUtils.isBlank(o.getContent())
|| StringUtils.isBlank(o.getScope())
)
.count();
if (count != list.size()){
throw new IllegalArgumentException("数据中存在必传项为空的数据");
}
}
@PostMapping("/download")
@Operation(summary = "下载")