Pārlūkot izejas kodu

新生导入bug修复

dzx 4 mēneši atpakaļ
vecāks
revīzija
1601787cbd

+ 45 - 22
src/main/java/com/xjrsoft/module/banding/controller/BandingTaskClassController.java

@@ -44,6 +44,8 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -103,39 +105,60 @@ public class BandingTaskClassController {
     @PostMapping
     @ApiOperation(value = "新增新生分班")
     @SaCheckPermission("bandingTaskClass:add")
-    public RT<Boolean> add(@Valid @RequestBody AddBandingTaskClassDto dto){
-        if(dto.getSortCode() != null){
-            List<BandingTaskClass> list = bandingTaskClassService.list(
-                    new QueryWrapper<BandingTaskClass>().lambda()
-                            .eq(BandingTaskClass::getSortCode, dto.getSortCode())
-                            .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
-            );
-            if(!list.isEmpty()){
-                return RT.error("班级编号重复");
+    public RT<Boolean> add(@Valid @RequestBody List<AddBandingTaskClassDto> dtoList){
+        List<BandingTaskClass> dataList = new ArrayList<>();
+        List<String> errorList = new ArrayList<>();
+        for (AddBandingTaskClassDto dto : dtoList) {
+            if(dto.getSortCode() != null){
+                List<BandingTaskClass> list = bandingTaskClassService.list(
+                        new QueryWrapper<BandingTaskClass>().lambda()
+                                .eq(BandingTaskClass::getSortCode, dto.getSortCode())
+                                .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
+                );
+                if(!list.isEmpty()){
+                    errorList.add(dto.getName());
+                }
             }
+
+            BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
+            bandingTask.setCreateDate(new Date());
+        }
+        if(!errorList.isEmpty()){
+            return RT.error(errorList.toString().replace("[", "").replace("]", "") + ",分班排序重复");
         }
 
-        BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
-        boolean isSuccess = bandingTaskClassService.add(bandingTask);
+        boolean isSuccess = bandingTaskClassService.saveBatch(dataList);
         return RT.ok(isSuccess);
     }
 
     @PutMapping
     @ApiOperation(value = "修改新生分班")
     @SaCheckPermission("bandingTaskClass:edit")
-    public RT<Boolean> update(@Valid @RequestBody UpdateBandingClassDto dto){
-        if(dto.getSortCode() != null){
-            List<BandingTaskClass> list = bandingTaskClassService.list(
-                    new QueryWrapper<BandingTaskClass>().lambda()
-                            .eq(BandingTaskClass::getSortCode, dto.getSortCode())
-                            .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
-            );
-            if(!list.isEmpty()){
-                return RT.error("班级编号重复");
+    public RT<Boolean> update(@Valid @RequestBody List<UpdateBandingClassDto> dtoList){
+        List<BandingTaskClass> dataList = new ArrayList<>();
+        List<String> errorList = new ArrayList<>();
+        for (UpdateBandingClassDto dto : dtoList) {
+            if(dto.getSortCode() != null){
+                List<BandingTaskClass> list = bandingTaskClassService.list(
+                        new QueryWrapper<BandingTaskClass>().lambda()
+                                .eq(BandingTaskClass::getSortCode, dto.getSortCode())
+                                .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
+                                .ne(BandingTaskClass::getId, dto.getId())
+                );
+                if(!list.isEmpty()){
+                    errorList.add(dto.getName());
+                }
             }
+
+            BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
+            bandingTask.setModifyDate(new Date());
+        }
+        if(!errorList.isEmpty()){
+            return RT.error(errorList.toString().replace("[", "").replace("]", "") + ",分班排序重复");
         }
-        BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
-        return RT.ok(bandingTaskClassService.update(bandingTask));
+
+        boolean isSuccess = bandingTaskClassService.updateBatchById(dataList);
+        return RT.ok(isSuccess);
     }
 
     @DeleteMapping

+ 7 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java

@@ -31,6 +31,8 @@ import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseMajorSet;
+import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
 import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
@@ -91,6 +93,8 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
     private final IBaseStudentService studentService;
     private final IBaseStudentFamilyService familyService;
 
+    private final BaseMajorSetMapper majorSetMapper;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -457,6 +461,8 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         //查询出需要新增的班级信息
         List<Long> classIds = classStudents.stream().map(BandingTaskClassStudent::getBandingTaskClassId).collect(Collectors.toList());
         List<BandingTaskClass> classList = taskClassMapper.selectList(new QueryWrapper<BandingTaskClass>().lambda().in(BandingTaskClass::getId, classIds));
+
+        Map<Long, Long> majorDeptMap = majorSetMapper.selectList(new QueryWrapper<BaseMajorSet>()).stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
         for (BandingTaskClass taskClass : classList) {
             BaseClass baseClass = new BaseClass() {{
                 setName(taskClass.getName());
@@ -467,6 +473,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                 setGradeId(bandingTask.getGradeId());
                 setDeleteMark(DeleteMark.NODELETE.getCode());
                 setEnrollType(bandingTask.getEnrollType());
+                setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
             }};
 
             classService.save(baseClass);

+ 8 - 0
src/main/java/com/xjrsoft/module/banding/vo/BandingTaskPageVo.java

@@ -60,4 +60,12 @@ public class BandingTaskPageVo {
     @ApiModelProperty("任务状态(0:未确认 1:已确认)")
     private Integer status;
 
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("已录取人数")
+    private Integer admissionsCount;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("已分班人数")
+    private Integer dividedCount;
+
 }