培训计划管理上传修改
parent
120bad3358
commit
f9d0aad3fb
|
|
@ -12,6 +12,7 @@ import com.gunshi.project.xyt.service.FileAssociationsService;
|
||||||
import com.gunshi.project.xyt.service.PersonnelPlanService;
|
import com.gunshi.project.xyt.service.PersonnelPlanService;
|
||||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
import com.gunshi.project.xyt.validate.markers.Update;
|
import com.gunshi.project.xyt.validate.markers.Update;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
@ -182,8 +183,12 @@ public class PersonnelPlanController extends AbstractCommonFileController {
|
||||||
List<PersonnelPlan> plans = util.importExcel(file.getInputStream());
|
List<PersonnelPlan> plans = util.importExcel(file.getInputStream());
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(plans)) {
|
if (CollectionUtils.isNotEmpty(plans)) {
|
||||||
|
checkData(plans);
|
||||||
Date regDate = new Date();
|
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);
|
boolean b = service.saveBatch(plans);
|
||||||
if (!b) {
|
if (!b) {
|
||||||
throw new IllegalArgumentException("上传失败");
|
throw new IllegalArgumentException("上传失败");
|
||||||
|
|
@ -193,6 +198,33 @@ public class PersonnelPlanController extends AbstractCommonFileController {
|
||||||
return R.ok(plans);
|
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")
|
@PostMapping("/download")
|
||||||
@Operation(summary = "下载")
|
@Operation(summary = "下载")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue