Browse Source

部门导入

夏文涛 1 year atrás
parent
commit
e3a4ac2272

+ 27 - 0
src/main/java/com/template/api/GraduateControllerAPI.java

@@ -0,0 +1,27 @@
+package com.template.api;
+
+import com.template.model.pojo.RepairAdmin;
+import com.template.model.request.changePasswordRequest;
+import com.template.model.request.loginRequest;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+
+@RequestMapping("/api/graduate")
+@Api(tags = {"GraduateController"}, value = "毕业")
+public interface GraduateControllerAPI {
+
+    /**
+     * 截至班级数
+     * @param classNo
+     * @return
+     */
+    @GetMapping(value = "/graduateDepartments")
+    @ApiOperation(value = "生成毕业部门操作", notes = "生成毕业部门操作", httpMethod = "GET")
+    CommonResult getAesStr(@RequestParam int classNo) throws Exception;
+
+}

+ 6 - 2
src/main/java/com/template/common/utils/TimeExchange.java

@@ -808,8 +808,12 @@ public class TimeExchange {
 //        String purePhoneNumber = String.valueOf(jsonErroObject.get("purePhoneNumber"));
 //        System.out.println(purePhoneNumber);
 
-        String date = getDate();
-        System.out.println("date = " + date);
+//        String date = getDate();
+//        System.out.println("date = " + date);
+
+        String str = "万载县第三中学/学生部/七年级学生/七1班学生";
+        String[] strs = str.split("/");
+        System.out.println("");
     }
 
 

+ 836 - 0
src/main/java/com/template/controller/GraduateController.java

@@ -0,0 +1,836 @@
+package com.template.controller;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.seewo.open.sdk.DefaultSeewoClient;
+import com.seewo.open.sdk.SeewoClient;
+import com.seewo.open.sdk.auth.Account;
+import com.template.annotation.DESRespondSecret;
+import com.template.api.GraduateControllerAPI;
+import com.template.api.RepairAdminControllerAPI;
+import com.template.common.utils.*;
+import com.template.config.ControlConfig;
+import com.template.config.SeewoConfig;
+import com.template.model.enumModel.eIsSuper;
+import com.template.model.enumModel.eStatu;
+import com.template.model.pojo.*;
+import com.template.model.request.freezeRepairAdminRequest;
+import com.template.model.request.updateRepairAdminRequest;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
+import com.template.model.seewo.*;
+import com.template.model.vo.*;
+import com.template.services.*;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.time.LocalDate;
+import java.time.Year;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static com.template.common.utils.AesTestOne.decrypt;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2023-07-05
+ */
+@RestController
+//返回参数加密注解
+@DESRespondSecret
+public class GraduateController implements GraduateControllerAPI {
+
+    private static Logger logger = LoggerFactory.getLogger(GraduateController.class);
+    @Resource
+    private ControlConfig controlConfig;
+    @Resource
+    private SeewoConfig seewoConfig;
+    @Autowired
+    private SmartDepartmentService smartDepartmentService;
+    @Autowired
+    private SmartUserService smartUserService;
+    @Autowired
+    private SmartClassService smartClassService;
+    @Autowired
+    private SmartGradeService smartGradeService;
+    @Autowired
+    private SmartVisitorParentsConfigService smartVisitorParentsConfigService;
+
+    @Override
+    public CommonResult getAesStr(int classNo) throws Exception {
+        if (classNo <= 0) {
+            return CommonResult.fail("生成班级数必须大于0");
+        }
+        String year = String.valueOf(Year.now().getValue() - 3);
+
+        //region
+        //region 部门批量新增
+        List<SmartDepartment> departments = smartDepartmentService.list(null);
+
+        String yearS = year + "级毕业学生";
+        Optional<SmartDepartment> existDataS = departments.stream().filter(e -> e.getName().equals(yearS)).findFirst();
+        if (existDataS != null && existDataS.isPresent()) {
+            return CommonResult.fail("本年度已进行过毕业操作,请勿重复操作");
+        }
+
+        String yearP = year + "级毕业家长";
+        Optional<SmartDepartment> existDataP = departments.stream().filter(e -> e.getName().equals(yearP)).findFirst();
+        if (existDataP != null && existDataP.isPresent()) {
+            return CommonResult.fail("本年度已进行过毕业操作,请勿重复操作");
+        }
+
+        Optional<SmartDepartment> oDepartment = departments.stream().filter(e -> e.getName().equals("学生部")).findFirst();
+        if (!(oDepartment != null && oDepartment.isPresent())) {
+            return CommonResult.fail("学生部部门数据不存在");
+        }
+
+        Optional<SmartDepartment> oDepartmentpd = departments.stream().filter(e -> e.getName().equals("家长部")).findFirst();
+        if (!(oDepartmentpd != null && oDepartmentpd.isPresent())) {
+            return CommonResult.fail("家长部部门数据不存在");
+        }
+        //部门升级规则
+        //将七年级升为八年级
+        //将八年级升为九年级
+        //将九年级升为对应入学年份
+        List<SmartDepartment> insertDepartments = new ArrayList<>();
+        List<SmartDepartment> updateDepartments = new ArrayList<>();
+        List<SmartDepartment> foreachDepartments = new ArrayList<>();
+
+        //百胜不允许重复名称的部门数据存在 所以先弄九年级 再弄八年级 再弄七年级
+        //region 九年级
+        List<SmartDepartment> studentDepartments = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("九") && e.getParentId().equals(oDepartment.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(studentDepartments);
+        List<SmartDepartment> parentDepartments = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("九") && e.getParentId().equals(oDepartmentpd.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(parentDepartments);
+        for (SmartDepartment fd : foreachDepartments) {
+            if (fd.getName().contains("九")) {
+                String fdName = null;
+                if (fd.getName().contains("九")) {
+                    fdName = fd.getName().replace("九年级", year + "级毕业");
+                }
+                fd.setName(fdName);
+                CommonResult resultNine = updateDepartmentToBs(fd);
+                if (!resultNine.isSuccess()) {
+                    return CommonResult.fail("百胜部门更新失败1");
+                }
+                SmartDepartment newFd = new SmartDepartment();
+                newFd = fd;
+                updateDepartments.add(newFd);
+
+                List<SmartDepartment> sdParentChilds = departments.stream().filter(e -> e.getParentId().equals(fd.getId())).collect(Collectors.toList());
+                for (SmartDepartment sdp : sdParentChilds) {
+                    String sdpName = null;
+                    if (sdp.getName().contains("九")) {
+                        sdpName = sdp.getName().replace("九", year + "级");
+                    }
+                    sdp.setName(sdpName);
+                    CommonResult resultSdp = updateDepartmentToBs(sdp);
+                    if (!resultSdp.isSuccess()) {
+                        return CommonResult.fail("百胜部门更新失败2");
+                    }
+                    SmartDepartment newSdp = new SmartDepartment();
+                    newSdp = sdp;
+                    updateDepartments.add(newSdp);
+                    List<SmartDepartment> sdChilds = departments.stream().filter(e -> e.getParentId().equals(sdp.getId())).collect(Collectors.toList());
+                    for (SmartDepartment sdc : sdChilds) {
+                        String sdcName = null;
+                        if (sdc.getName().contains("九")) {
+                            sdcName = sdc.getName().replace("九", year + "级");
+                        }
+                        sdc.setName(sdcName);
+                        CommonResult resultSdc = updateDepartmentToBs(sdc);
+                        if (!resultSdc.isSuccess()) {
+                            return CommonResult.fail("百胜部门更新失败3");
+                        }
+                        SmartDepartment newSdc = new SmartDepartment();
+                        newSdc = sdc;
+                        updateDepartments.add(newSdc);
+                    }
+                }
+            }
+        }
+        //endregion
+        foreachDepartments = new ArrayList<>();
+        //region 八年级
+        List<SmartDepartment> studentDepartments1 = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("八") && e.getParentId().equals(oDepartment.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(studentDepartments1);
+        List<SmartDepartment> parentDepartments1 = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("八") && e.getParentId().equals(oDepartmentpd.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(parentDepartments1);
+        for (SmartDepartment fd : foreachDepartments) {
+            if (fd.getName().contains("八")) {
+                String fdName = null;
+                if (fd.getName().contains("八")) {
+                    fdName = fd.getName().replace("八", "九");
+                }
+                fd.setName(fdName);
+                CommonResult resultfd = updateDepartmentToBs(fd);
+                if (!resultfd.isSuccess()) {
+                    return CommonResult.fail("百胜部门更新失败4");
+                }
+                SmartDepartment newFd = new SmartDepartment();
+                newFd = fd;
+                updateDepartments.add(newFd);
+
+                List<SmartDepartment> sdParentChilds = departments.stream().filter(e -> e.getParentId().equals(fd.getId())).collect(Collectors.toList());
+                for (SmartDepartment sdp : sdParentChilds) {
+                    String sdpName = null;
+                    if (sdp.getName().contains("八")) {
+                        sdpName = sdp.getName().replace("八", "九");
+                    }
+                    sdp.setName(sdpName);
+                    CommonResult resultSdp = updateDepartmentToBs(sdp);
+                    if (!resultSdp.isSuccess()) {
+                        return CommonResult.fail("百胜部门更新失败5");
+                    }
+                    SmartDepartment newSdp = new SmartDepartment();
+                    newSdp = sdp;
+                    updateDepartments.add(newSdp);
+                    List<SmartDepartment> sdChilds = departments.stream().filter(e -> e.getParentId().equals(sdp.getId())).collect(Collectors.toList());
+                    for (SmartDepartment sdc : sdChilds) {
+                        String sdcName = null;
+                        if (sdc.getName().contains("八")) {
+                            sdcName = sdc.getName().replace("八", "九");
+                        }
+                        sdc.setName(sdcName);
+                        CommonResult resultSdc = updateDepartmentToBs(sdc);
+                        if (!resultSdc.isSuccess()) {
+                            return CommonResult.fail("百胜部门更新失败6");
+                        }
+                        SmartDepartment newSdc = new SmartDepartment();
+                        newSdc = sdc;
+                        updateDepartments.add(newSdc);
+                    }
+                }
+            }
+        }
+        //endregion
+        foreachDepartments = new ArrayList<>();
+        //region 七年级
+        List<SmartDepartment> studentDepartments2 = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("七") && e.getParentId().equals(oDepartment.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(studentDepartments2);
+        List<SmartDepartment> parentDepartments2 = departments.stream().filter(e -> !e.getName().contains("毕业") && e.getName().contains("七") && e.getParentId().equals(oDepartmentpd.get().getId())).collect(Collectors.toList());
+        foreachDepartments.addAll(parentDepartments2);
+        for (SmartDepartment fd : foreachDepartments) {
+            if (fd.getName().contains("七")) {
+                String fdName = null;
+                if (fd.getName().contains("七")) {
+                    fdName = fd.getName().replace("七", "八");
+                }
+                fd.setName(fdName);
+                CommonResult resultfd = updateDepartmentToBs(fd);
+                if (!resultfd.isSuccess()) {
+                    return CommonResult.fail("百胜部门更新失败7");
+                }
+                SmartDepartment newFd = new SmartDepartment();
+                newFd = fd;
+                updateDepartments.add(newFd);
+
+                List<SmartDepartment> sdParentChilds = departments.stream().filter(e -> e.getParentId().equals(fd.getId())).collect(Collectors.toList());
+                for (SmartDepartment sdp : sdParentChilds) {
+                    String sdpName = null;
+                    if (sdp.getName().contains("七")) {
+                        sdpName = sdp.getName().replace("七", "八");
+                    }
+                    sdp.setName(sdpName);
+                    CommonResult resultsdp = updateDepartmentToBs(sdp);
+                    if (!resultsdp.isSuccess()) {
+                        return CommonResult.fail("百胜部门更新失败8");
+                    }
+                    SmartDepartment newSdp = new SmartDepartment();
+                    newSdp = sdp;
+                    updateDepartments.add(newSdp);
+                    List<SmartDepartment> sdChilds = departments.stream().filter(e -> e.getParentId().equals(sdp.getId())).collect(Collectors.toList());
+                    for (SmartDepartment sdc : sdChilds) {
+                        String sdcName = null;
+                        if (sdc.getName().contains("七")) {
+                            sdcName = sdc.getName().replace("七", "八");
+                        }
+                        sdc.setName(sdcName);
+                        CommonResult resultsdc = updateDepartmentToBs(sdc);
+                        if (!resultsdc.isSuccess()) {
+                            return CommonResult.fail("百胜部门更新失败9");
+                        }
+                        SmartDepartment newSdc = new SmartDepartment();
+                        newSdc = sdc;
+                        updateDepartments.add(newSdc);
+                    }
+                }
+            }
+        }
+        //endregion
+
+        if (updateDepartments != null && updateDepartments.size() > 0) {
+            boolean updateBatchs = smartDepartmentService.updateBatchById(updateDepartments);
+            if (!updateBatchs) {
+                return CommonResult.fail("批量升级部门失败");
+            }
+        }
+
+        String bss = insertDepartmentToBs("七年级学生");
+        if (bss == null) {
+            return CommonResult.fail("百胜添加部门数据失败");
+        }
+
+
+        String bsp = insertDepartmentToBs("七年级家长");
+        if (bsp == null) {
+            return CommonResult.fail("百胜添加部门数据失败");
+        }
+
+        List<SmartDepartment> sd = new ArrayList<>();
+
+        SmartDepartment sds = new SmartDepartment();
+        sds.setParentId(oDepartment.get().getId());
+        sds.setName("七年级学生");
+        sds.setBsDepartmentNo(bss);
+        sd.add(sds);
+        SmartDepartment sdpd = new SmartDepartment();
+        sdpd.setParentId(oDepartmentpd.get().getId());
+        sdpd.setName("七年级家长");
+        sdpd.setBsDepartmentNo(bsp);
+        sd.add(sdpd);
+
+        boolean insertDepartmentBatch = smartDepartmentService.saveBatch(sd);
+        if (!insertDepartmentBatch) {
+            return CommonResult.fail("新增部门数据失败");
+        }
+        departments = smartDepartmentService.list(null);
+
+        List<SmartDepartment> insertD = new ArrayList<>();
+        for (int i = 1; i <= classNo; i++) {
+            //region 学生部门
+            String classStr = "七" + i + "班学生";
+            //百胜不允许部门名称重复
+            Optional<SmartDepartment> exist = departments.stream().filter(e -> e.getName().equals(classStr)).findFirst();
+            if (exist != null && exist.isPresent()) {
+                continue;
+            }
+
+            String bsData = insertDepartmentToBs(classStr);
+            Optional<SmartDepartment> exisStudent = departments.stream().filter(e -> e.getName().equals("七年级学生")).findFirst();
+            if (!(exisStudent != null && exisStudent.isPresent())) {
+                return CommonResult.fail("七年级学生数据为空");
+            }
+            SmartDepartment sdStudent = new SmartDepartment();
+            sdStudent.setParentId(exisStudent.get().getId());
+            sdStudent.setName(classStr);
+            sdStudent.setBsDepartmentNo(bsData);
+            insertD.add(sdStudent);
+            //endregion
+
+            //region 家长部门
+            String classStrP = "七" + i + "班家长";
+            //百胜不允许部门名称重复
+            Optional<SmartDepartment> existP = departments.stream().filter(e -> e.getName().equals(classStrP)).findFirst();
+            if (existP != null && existP.isPresent()) {
+                continue;
+            }
+
+            String bsDataP = insertDepartmentToBs(classStrP);
+            Optional<SmartDepartment> exisParent = departments.stream().filter(e -> e.getName().equals("七年级家长")).findFirst();
+            if (!(exisParent != null && exisParent.isPresent())) {
+                return CommonResult.fail("七年级家长数据为空");
+            }
+            SmartDepartment sdParent = new SmartDepartment();
+            sdParent.setParentId(exisParent.get().getId());
+            sdParent.setName(classStrP);
+            sdParent.setBsDepartmentNo(bsDataP);
+            insertD.add(sdParent);
+            //endregion
+        }
+        boolean insertBatch = smartDepartmentService.saveBatch(insertD);
+        if (!insertBatch) {
+            return CommonResult.fail("部门数据批量新增失败");
+        }
+        //endregion
+
+        //region 班级名称修改 需要将班级名称修改到百胜
+        List<String> grades = new ArrayList<>();
+        for (int i = Year.now().getValue() - 3; i < Year.now().getValue(); i++) {
+            grades.add(i + "级");
+        }
+        List<SmartGrade> gradeDatas = smartGradeService.getSmartGrades(grades);
+        List<Integer> gradeIds = gradeDatas.stream().map(SmartGrade::getId).collect(Collectors.toList());
+        List<SmartClass> classDatas = smartClassService.getSmartClasssByGrade(gradeIds);
+        //百胜不允许重复名称的部门数据存在 所以先弄九年级 再弄八年级 再弄七年级
+        //升级规则(希沃会自己改班级名称)
+        //将七年级升为八年级
+        //将八年级升为九年级
+        //将九年级升为对应入学年份
+        List<SmartClass> updateClassBatchs = new ArrayList<>();
+        List<SmartClass> nineClasss = classDatas.stream().filter(e -> e.getName().contains("九")).collect(Collectors.toList());
+        for (SmartClass sc : nineClasss) {
+            String newName = null;
+            if (sc.getName().contains("九")) {
+                newName = sc.getName().replace("九年", year);
+            }
+            CommonResult result = updateClassName(newName, sc.getBsClassNo());
+            if (!result.isSuccess()) {
+                continue;
+            }
+
+            sc.setName(newName);
+
+            SmartClass newSc = new SmartClass();
+            newSc = sc;
+            updateClassBatchs.add(newSc);
+        }
+
+        List<SmartClass> eightClasss = classDatas.stream().filter(e -> e.getName().contains("八")).collect(Collectors.toList());
+        for (SmartClass sc : eightClasss) {
+            String newName = null;
+            if (sc.getName().contains("八")) {
+                newName = sc.getName().replace("八", "九");
+            }
+            CommonResult result = updateClassName(newName, sc.getBsClassNo());
+            if (!result.isSuccess()) {
+                continue;
+            }
+
+            sc.setName(newName);
+
+            SmartClass newSc = new SmartClass();
+            newSc = sc;
+            updateClassBatchs.add(newSc);
+        }
+
+        List<SmartClass> sevenClasss = classDatas.stream().filter(e -> e.getName().contains("七")).collect(Collectors.toList());
+        for (SmartClass sc : sevenClasss) {
+            String newName = null;
+            if (sc.getName().contains("七")) {
+                newName = sc.getName().replace("七", "八");
+            }
+            CommonResult result = updateClassName(newName, sc.getBsClassNo());
+            if (!result.isSuccess()) {
+                continue;
+            }
+
+            sc.setName(newName);
+
+            SmartClass newSc = new SmartClass();
+            newSc = sc;
+            updateClassBatchs.add(newSc);
+        }
+        boolean updateBatchClass = smartClassService.updateBatchById(updateClassBatchs);
+        if (!updateBatchClass) {
+            return CommonResult.fail("班级名称更新失败");
+        }
+        //endregion
+
+        //endregion
+
+        //region 新增新班级
+        SmartGrade grade = smartGradeService.querySmartGradeByName(Year.now().getValue() + "级");
+        Integer gradeId = null;
+        if (grade == null) {
+            CommonResult<Integer> insertGrade = insertGrade(Year.now().getValue() + "级");
+            if (insertGrade.isSuccess()) {
+                gradeId = insertGrade.getData();
+            }
+        } else {
+            gradeId = grade.getId();
+        }
+        SmartGrade gradeData = smartGradeService.querySmartGradeById(gradeId);
+        List<SmartClass> scss = new ArrayList<>();
+        for (int i = 1; i <= classNo; i++) {
+            String className = "七年级" + i + "班";
+            //判断重复性
+            int existCount = smartClassService.existSmartClass(className, grade.getId());
+            if (existCount > 0) {
+                return CommonResult.fail("该班级数据已在系统中存在,请勿重复添加");
+            }
+
+            SmartClass sc = insertClass(i, className, gradeData.getBsGradeNo(), gradeData.getId(), gradeData);
+            if (sc == null) {
+                continue;
+            }
+            scss.add(sc);
+        }
+
+        if (scss != null && scss.size() > 0) {
+            boolean insertClassBatch = smartClassService.saveBatch(scss);
+            if (!insertClassBatch) {
+                return CommonResult.fail("新增新生班级失败");
+            }
+        }
+
+        List<SmartClass> clsssEs = smartClassService.getSmartClasssLikeName("七年级");
+        List<SmartVisitorParentsConfig> pcs = new ArrayList<>();
+        for (SmartClass data : clsssEs) {
+            //添加班级配置
+            SmartVisitorParentsConfig svpc = new SmartVisitorParentsConfig();
+            svpc.setClassId(data.getId());
+            svpc.setAppAuditConfig(1);
+            svpc.setAppPushConfig(5);
+            svpc.setAppCancelConfig(6);
+            svpc.setAppAuditConfig(1);
+            svpc.setAppPushConfig(5);
+            svpc.setAppCancelConfig(6);
+            svpc.setAccessConfig(0);
+            svpc.setCarConfig(1);
+            pcs.add(svpc);
+        }
+
+        smartVisitorParentsConfigService.saveBatch(pcs);
+        //endregion
+
+        return CommonResult.ok("毕业操作成功");
+    }
+
+    public CommonResult<Integer> insertGrade(String gradeName) throws Exception {
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "grade/create";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"grade_name\":\"" + gradeName + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+
+        //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
+        String md5Str = "appid=" + appId + "&data={\"grade_name\":\"" + gradeName + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (result.contains("添加成功")) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            BsGradeVo grade = objectMapper.readValue(result, BsGradeVo.class);
+
+            // URL解码
+            String decodedUrl = URLDecoder.decode(grade.getData(), "UTF-8");
+
+            BsGradeNoVo gradeNo = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsGradeNoVo.class);
+
+            SmartGrade smartGrade = new SmartGrade();
+            smartGrade.setGradeNo(7);
+            smartGrade.setName(gradeName);
+            smartGrade.setBsGradeNo(gradeNo.getGrade_no());
+
+            int insertResult = smartGradeService.insertSmartGrade(smartGrade);
+
+            return insertResult > 0 ? CommonResult.ok(insertResult) : CommonResult.fail("添加失败");
+
+        } else {
+            return CommonResult.fail("添加失败");
+        }
+    }
+
+    public CommonResult updateClassName(String className, String bsClassNo) throws Exception {
+        //region 修改百胜中的班级数据
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "classtab/update";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"classtab_no\":\"" + bsClassNo + "\",\"classtab_name\":\"" + className + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+        String md5Str = "appid=" + appId + "&data={\"classtab_no\":\"" + bsClassNo + "\",\"classtab_name\":\"" + className + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (!result.contains("更新成功")) {
+            return CommonResult.fail("班级信息更新失败");
+
+        }
+
+        return CommonResult.ok("班级信息更新成功");
+    }
+
+    public CommonResult updateDepartmentToBs(SmartDepartment sd) throws Exception {
+        //region 百胜添加部门数据
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "department/update";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"department_no\":\"" + sd.getBsDepartmentNo() + "\",\"department_name\":\"" + sd.getName() + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+
+        String md5Str = "appid=" + appId + "&data={\"department_no\":\"" + sd.getBsDepartmentNo() + "\",\"department_name\":\"" + sd.getName() + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (bsResult.contains("更新成功")) {
+            return CommonResult.ok();
+        }
+        //endregion
+
+        return CommonResult.fail();
+    }
+
+
+    public String insertDepartmentToBs(String name) throws Exception {
+        //region 百胜添加部门数据
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "department/create";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"department_name\":\"" + name + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+
+        String md5Str = "appid=" + appId + "&data={\"department_name\":\"" + name + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (bsResult.contains("添加成功")) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            BsDepartmentVo department = objectMapper.readValue(bsResult, BsDepartmentVo.class);
+
+            // URL解码
+            String decodedUrl = URLDecoder.decode(department.getData(), "UTF-8");
+
+            BsDepartmentNoVo departmentData = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsDepartmentNoVo.class);
+
+            return departmentData.getDepartment_no();
+        }
+        //endregion
+
+        return null;
+    }
+
+    public SmartClass insertClass(Integer classNo, String className, String gradeBsNo, Integer gradeId, SmartGrade grade) throws Exception {
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "classtab/create";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"grade_no\":\"" + gradeBsNo + "\",\"classtab_name\":\"" + className + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+
+        String md5Str = "appid=" + appId + "&data={\"grade_no\":\"" + gradeBsNo + "\",\"classtab_name\":\"" + className + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (result.contains("添加成功")) {
+
+            //希沃班级传输特点:
+            //当前月份小于9月份就传当前年份 - 1 ;如果大于9月份就传当前年份
+            Integer nowMonth = Integer.valueOf(TimeExchange.getNowMonth());
+            //初始化客户端
+            SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
+
+            //region 将K12校区的班级数据初始化
+            K12Class(seewoClient, 7, nowMonth);
+            //endregion
+
+            //region 将数据加入希沃系统中
+            CommonResult<String[]> saveClass = SeewoInsertOrUpdateClass(seewoClient, classNo, className, 7, nowMonth);
+            if (!saveClass.isSuccess()) {
+                return null;
+            }
+            //endregion
+
+            //希沃添加年级和班级数据是:存在就覆盖 不存在就新增
+            //要拿到希沃的年级Uid和班级Uid
+            String gradeUid = saveClass.getData()[0];
+            String classUid = saveClass.getData()[1];
+
+            ObjectMapper objectMapper = new ObjectMapper();
+            BsClassVo classVo = objectMapper.readValue(result, BsClassVo.class);
+
+            // URL解码
+            String decodedUrl = URLDecoder.decode(classVo.getData(), "UTF-8");
+
+            BsClassNoVo bsClassNo = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsClassNoVo.class);
+
+            if (classNo == null) {
+                return null;
+            }
+
+            SmartClass smartClass = new SmartClass();
+            smartClass.setGradeId(gradeId);
+            smartClass.setClassUid(classUid);
+            smartClass.setName(className);
+            smartClass.setClassNo(classNo);
+            smartClass.setBsClassNo(bsClassNo.getClasstab_no());
+
+
+            if (grade.getGradeUid() == null) {
+                grade.setGradeUid(gradeUid);
+                int updateGrade = smartGradeService.updateSmartGrade(grade);
+                if (updateGrade <= 0) {
+                    return null;
+                }
+            }
+
+            return smartClass;
+        }
+        return null;
+    }
+
+    //K12班级
+    private void K12Class(SeewoClient seewoClient, Integer gradeNo, Integer nowMonth) {
+
+        OrganizationNodeServiceInitSchoolClassesParam kParam = new OrganizationNodeServiceInitSchoolClassesParam();
+        //响应体,MimeType为 application/json
+        OrganizationNodeServiceInitSchoolClassesParam.RequestBody kRequestBody = OrganizationNodeServiceInitSchoolClassesParam.RequestBody.builder()
+                .build();
+        kParam.setRequestBody(kRequestBody);
+        //query
+        OrganizationNodeServiceInitSchoolClassesParam.Query kQuery = OrganizationNodeServiceInitSchoolClassesParam.Query.builder()
+                .appId(seewoConfig.getAppId())
+                .unitUid(seewoConfig.getSchoolId())
+                .campusName("宜阳学校")
+                .build();
+        kRequestBody.setQuery(kQuery);
+        //新增班级列表(最大200条)
+        OrganizationNodeServiceInitSchoolClassesParam.Object kClassList = OrganizationNodeServiceInitSchoolClassesParam.Object.builder()
+                .stageName("初中")
+                .gradeYear(ClassYear.getAdmissionYear(gradeNo, Year.now().getValue(), LocalDate.now()))
+                .build();
+        kQuery.setClassList(java.util.Collections.singletonList(kClassList));
+        kParam.setRequestBody(kRequestBody);
+        OrganizationNodeServiceInitSchoolClassesRequest kRequest = new OrganizationNodeServiceInitSchoolClassesRequest(kParam);
+        logger.info("入参:" + kRequest);
+        //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
+        //request.setServerUrl("https://openapi.test.seewo.com")
+        //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
+        OrganizationNodeServiceInitSchoolClassesResult kResult = seewoClient.invoke(kRequest);
+        logger.info("出参:" + kResult);
+    }
+
+    //新增班级和年级
+    public CommonResult<String[]> SeewoInsertOrUpdateClass(SeewoClient seewoClient, Integer classNo, String className, Integer gradeNo, Integer nowMonth) {
+        String[] result = new String[2];
+        //初始化客户端
+        //SeewoClient seewoClient = new DefaultSeewoClient(new Account(seewoConfig.getAppId(), seewoConfig.getAppSecret()));
+        ClassServiceBatchSaveClassParam param = new ClassServiceBatchSaveClassParam();
+        //请求体,MimeType为 application/json
+        ClassServiceBatchSaveClassParam.JSONRequestBody requestBody = ClassServiceBatchSaveClassParam.JSONRequestBody.builder()
+                .build();
+        param.setRequestBody(requestBody);
+        //查询条件
+        ClassServiceBatchSaveClassParam.ClassSaveQuery query = ClassServiceBatchSaveClassParam.ClassSaveQuery.builder()
+                .appId(seewoConfig.getAppId())
+                .schoolUid(seewoConfig.getSchoolId())
+                .build();
+        requestBody.setQuery(query);
+
+        //班级信息列表
+        ClassServiceBatchSaveClassParam.ClassInfo classList = ClassServiceBatchSaveClassParam.ClassInfo.builder()
+                .stageCode("CodeSchoolStage_1")
+                .clazz(classNo)
+                .nickName(className)
+                .grade(gradeNo)
+                .gradeYear(ClassYear.getAdmissionYear(gradeNo, Year.now().getValue(), LocalDate.now()))
+                .build();
+        query.setClassList(java.util.Collections.singletonList(classList));
+        param.setRequestBody(requestBody);
+        ClassServiceBatchSaveClassRequest request = new ClassServiceBatchSaveClassRequest(param);
+        logger.info("入参:" + request);
+        logger.info("入参body:" + JSON.toJSON(requestBody));
+        //如果想要调用沙箱环境,请通过设置 request 对象的 serverUrl 属性,如:
+        // request.setServerUrl("https://openapi.test.seewo.com")
+        //执行请求,如果想获取到com.seewo.open.sdk.HttpResponse对象,请调用 seewoClient.execute 方法
+        ClassServiceBatchSaveClassResult xwResult = seewoClient.invoke(request);
+        logger.info("出参:" + xwResult);
+
+        if (xwResult == null) {
+            return CommonResult.fail("希沃班级数据新增失败!");
+        }
+
+        if (!xwResult.getResponseBody().getCode().equals("000000")) {
+            return CommonResult.fail(xwResult.getResponseBody().getMessage());
+        }
+
+        String gradeUid = xwResult.getResponseBody().getData().get(0).getGradeUid();
+        String classUid = xwResult.getResponseBody().getData().get(0).getUid();
+        result[0] = gradeUid;
+        result[1] = classUid;
+        return CommonResult.ok(result);
+    }
+    //endregion
+
+    /**
+     * 根据父级ID获取树形数据
+     *
+     * @param parentID 父级ID
+     * @param lists    数据集合
+     * @return
+     */
+    private List<DepartmentTreeVo> QueryDepartmentTreeRecords
+    (Integer
+             parentID, List<SmartDepartment> lists, List<Integer> departmentIds) {
+        List<DepartmentTreeVo> newTrees = new ArrayList<>();
+
+        List<SmartDepartment> datas = lists.stream().filter(e -> e.getParentId().equals(parentID)).collect(Collectors.toList());
+
+        for (SmartDepartment data : datas) {
+            departmentIds.add(data.getId());
+            QueryDepartmentTreeRecords(data.getId(), lists, departmentIds);
+        }
+
+        return newTrees;
+    }
+    //endregion
+}
+

+ 3 - 8
src/main/java/com/template/controller/SmartDepartmentController.java

@@ -160,6 +160,7 @@ public class SmartDepartmentController implements SmartDepartmentControllerAPI {
         sd.setId(udr.getId());
         sd.setParentId(udr.getParentId());
         sd.setName(udr.getName());
+        sd.setBsDepartmentNo(oldData.getBsDepartmentNo());
 
         //region 百胜添加部门数据
         String appId = controlConfig.getAppId();
@@ -184,15 +185,9 @@ public class SmartDepartmentController implements SmartDepartmentControllerAPI {
         //返回的结果中 code为1表示成功
         String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
 
-        if (bsResult.contains("添加成功")) {
-            ObjectMapper objectMapper = new ObjectMapper();
-            BsDepartmentVo department = objectMapper.readValue(bsResult, BsDepartmentVo.class);
-
-            // URL解码
-            String decodedUrl = URLDecoder.decode(department.getData(), "UTF-8");
+        if (!bsResult.contains("更新成功")) {
+            return CommonResult.fail("修改失败");
 
-            BsDepartmentNoVo departmentData = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsDepartmentNoVo.class);
-            sd.setBsDepartmentNo(departmentData.getDepartment_no());
         }
         //endregion
 

+ 160 - 83
src/main/java/com/template/controller/SmartUserController.java

@@ -759,7 +759,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 familyIndex.setIndexData(i);
                                 familyIndexs.add(familyIndex);
                                 ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem data = ParentServiceBatchSaveOrUpdateParentsParam.ParentsItem.builder()
-                                        .name(parent.getName())
+                                        .name(parent.getShip())
                                         .phone(parent.getPhone())
                                         .index(i)
                                         .build();
@@ -1118,65 +1118,69 @@ public class SmartUserController implements SmartUserControllerAPI {
                             if (!schoolClass.equals("班级")) {
                                 return CommonResult.fail("导入数据第一列为班级");
                             }
-                            String cardNo = dataFormatter.formatCellValue(row.getCell(2));//学号
+                            String departmentNo = dataFormatter.formatCellValue(row.getCell(2));//部门
+                            if (!departmentNo.equals("部门")) {
+                                return CommonResult.fail("导入数据第二列为部门");
+                            }
+                            String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
                             if (!cardNo.equals("学号")) {
                                 return CommonResult.fail("导入数据第二列为学号");
                             }
-                            String name = dataFormatter.formatCellValue(row.getCell(3));//姓名
+                            String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
                             if (!name.equals("姓名")) {
                                 return CommonResult.fail("导入数据第三列为姓名");
                             }
-                            String sex = dataFormatter.formatCellValue(row.getCell(4));//性别
+                            String sex = dataFormatter.formatCellValue(row.getCell(5));//性别
                             if (!sex.equals("性别")) {
                                 return CommonResult.fail("导入数据第四列为性别");
                             }
-                            String nation = dataFormatter.formatCellValue(row.getCell(5));//民族
+                            String nation = dataFormatter.formatCellValue(row.getCell(6));//民族
                             if (!nation.equals("民族")) {
                                 return CommonResult.fail("导入数据第五列为民族");
                             }
-                            String cardId = dataFormatter.formatCellValue(row.getCell(6));//身份证
+                            String cardId = dataFormatter.formatCellValue(row.getCell(7));//身份证
                             if (!cardId.equals("身份证")) {
                                 return CommonResult.fail("导入数据第六列为身份证");
                             }
-                            String headImage = dataFormatter.formatCellValue(row.getCell(7));//照片
+                            String headImage = dataFormatter.formatCellValue(row.getCell(8));//照片
                             if (!headImage.equals("照片")) {
                                 return CommonResult.fail("导入数据第七列为照片");
                             }
-                            String timeGroup = dataFormatter.formatCellValue(row.getCell(8));//常规时间组
+                            String timeGroup = dataFormatter.formatCellValue(row.getCell(9));//常规时间组
                             if (!timeGroup.equals("常规时间组")) {
                                 return CommonResult.fail("导入数据第八列为常规时间组");
                             }
-                            String address = dataFormatter.formatCellValue(row.getCell(9));//住址
+                            String address = dataFormatter.formatCellValue(row.getCell(10));//住址
                             if (!address.equals("住址")) {
                                 return CommonResult.fail("导入数据第九列为住址");
                             }
-                            String phone = dataFormatter.formatCellValue(row.getCell(10));//联系电话
+                            String phone = dataFormatter.formatCellValue(row.getCell(11));//联系电话
                             if (!phone.equals("联系电话")) {
                                 return CommonResult.fail("导入数据第十列为联系电话");
                             }
-                            String family = dataFormatter.formatCellValue(row.getCell(11));//家属
+                            String family = dataFormatter.formatCellValue(row.getCell(12));//家属
                             if (!family.equals("家属")) {
                                 return CommonResult.fail("导入数据第十一列为家属");
                             }
-                            String familyShip = dataFormatter.formatCellValue(row.getCell(12));//家属与本人关系
+                            String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
                             if (!familyShip.equals("家属与本人关系")) {
                                 return CommonResult.fail("导入数据第十二列为家属与本人关系");
                             }
-                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(13));//联系电话2
+                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
                             if (!phoneTwo.equals("联系电话2")) {
                                 return CommonResult.fail("导入数据第十三列为联系电话2");
                             }
-                            String familyTwo = dataFormatter.formatCellValue(row.getCell(14));//家属2
+                            String familyTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
                             if (!familyTwo.equals("家属2")) {
                                 return CommonResult.fail("导入数据第十四列为家属2");
                             }
-                            String familyShipTwo = dataFormatter.formatCellValue(row.getCell(15));//家属与本人关系2
+                            String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
                             if (!familyShipTwo.equals("家属与本人关系2")) {
                                 return CommonResult.fail("导入数据第十五列为家属与本人关系2");
                             }
                         } else {
                             SmartUser user = new SmartUser();
-                            String name = dataFormatter.formatCellValue(row.getCell(3));
+                            String name = dataFormatter.formatCellValue(row.getCell(4));
                             //                        if (ObjectUtils.isEmpty(name)) {
                             //                            return CommonResult.fail("第" + (rowNum + 1) + "条数据的名称不能为空");
                             //                        }
@@ -1195,7 +1199,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             //不判断重复性 因为会出现双胞胎
-                            String phone = dataFormatter.formatCellValue(row.getCell(10));
+                            String phone = dataFormatter.formatCellValue(row.getCell(11));
                             //                        if (!ObjectUtils.isEmpty(phone)) {
                             //                            phones.add(phone);
                             //                        }
@@ -1205,35 +1209,50 @@ public class SmartUserController implements SmartUserControllerAPI {
 
 
                             //性别是否为空判断
-                            String sex = dataFormatter.formatCellValue(row.getCell(4));
+                            String sex = dataFormatter.formatCellValue(row.getCell(5));
                             if (ObjectUtils.isEmpty(sex)) {
                                 return CommonResult.fail(name + "的性别不能为空");
                             }
 
                             //家庭住址是否为空判断
-                            String address = dataFormatter.formatCellValue(row.getCell(9));
+                            String address = dataFormatter.formatCellValue(row.getCell(10));
 
                             //民族是否为空判断
-                            String nation = dataFormatter.formatCellValue(row.getCell(5));
+                            String nation = dataFormatter.formatCellValue(row.getCell(6));
                             if (ObjectUtils.isEmpty(nation)) {
                                 return CommonResult.fail(name + "的民族不能为空");
                             }
 
                             //部门是否为空判断
-                            String department = dataFormatter.formatCellValue(row.getCell(1)).replace("年级", "") + "学生";
-                            if (ObjectUtils.isEmpty(department)) {
+                            String department = dataFormatter.formatCellValue(row.getCell(2));
+                            if (ObjectUtils.isEmpty(nation)) {
                                 return CommonResult.fail(name + "的部门不能为空");
                             }
+                            Integer parentDid = null;
                             Integer departmentId = null;
-                            Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department)).findFirst();
-                            if (departModel != null && departModel.isPresent()) {
-                                departmentId = departModel.get().getId();
-                            } else {
-                                departmentId = 1;
+                            String[] departmentStrs = department.split("/");
+                            for (int i = 0; i < departmentStrs.length; i++) {
+                                String departmentName = departmentStrs[i];
+                                Optional<SmartDepartment> oD = departments.stream().filter(e -> e.getName().equals(departmentName)).findFirst();
+                                if(oD != null && oD.isPresent()){
+                                    parentDid = oD.get().getId();
+                                }else{
+                                    String bsDepartment = insertDepartmentToBs(departmentName);
+                                    if(bsDepartment == null){
+                                        return CommonResult.fail(name + "的部门添加到百胜失败");
+                                    }
+                                    SmartDepartment sdParent = new SmartDepartment();
+                                    sdParent.setParentId(parentDid);
+                                    sdParent.setName(departmentName);
+                                    sdParent.setBsDepartmentNo(bsDepartment);
+                                    int departmentData = smartDepartmentService.insertSmartDepartment(sdParent);
+                                    departmentId = departmentData;
+                                    parentDid = departmentData;
+                                }
                             }
 
                             //学号重复判断
-                            String cardNo = dataFormatter.formatCellValue(row.getCell(2));
+                            String cardNo = dataFormatter.formatCellValue(row.getCell(3));
                             if (!ObjectUtils.isEmpty(cardNo)) {
                                 cardNos.add(cardNo);
                             }
@@ -1242,7 +1261,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             //身份证重复判断
-                            String idCard = dataFormatter.formatCellValue(row.getCell(6));
+                            String idCard = dataFormatter.formatCellValue(row.getCell(7));
                             if (!ObjectUtils.isEmpty(idCard)) {
                                 idCards.add(idCard);
                             }
@@ -1255,7 +1274,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             user.setIdCard(idCard == null ? "" : idCard);
                             user.setSexId(sex == null ? eSexStatu.Man.getValue() : eSexStatu.integerOf(sex));
                             user.setDepartmentId(departmentId);
-                            String cellImage = dataFormatter.formatCellValue(row.getCell(7));
+                            String cellImage = dataFormatter.formatCellValue(row.getCell(8));
                             user.setHeadImage(cellImage);
                             user.setDormitoryNumber("");
                             String grade = schoolGrade == null ? "" : schoolGrade;
@@ -1284,7 +1303,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             user.setOfStudent("");
                             user.setGraduate("");
                             user.setDuties(null);
-                            String timeGroup = dataFormatter.formatCellValue(row.getCell(8));
+                            String timeGroup = dataFormatter.formatCellValue(row.getCell(9));
                             Optional<SmartTimeGroup> groupData = timeGroups.stream().filter(e -> e.getName().equals(timeGroup)).findFirst();
                             if (groupData != null && groupData.isPresent()) {
                                 user.setTimeGroupId(groupData.get().getId());
@@ -1315,7 +1334,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 }
 
                                 SmartUser familyOne = new SmartUser();
-                                String family = dataFormatter.formatCellValue(row.getCell(11));//家属
+                                String family = dataFormatter.formatCellValue(row.getCell(12));//家属
                                 familyOne.setName(!ObjectUtils.isEmpty(family) ? family : "家长");
                                 familyOne.setDepartmentId(familyDepartmentId);
                                 familyOne.setPhone(phone);
@@ -1323,18 +1342,18 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 familyOne.setSexId(eSexStatu.Man.getValue());
                                 familyOne.setIsCancel(eLogOff.Unlogout.getValue());
                                 familyOne.setAffiliate(user.getCardNo());
-                                String familyShip = dataFormatter.formatCellValue(row.getCell(12));//家属与本人关系
+                                String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
                                 familyOne.setShip(familyShip == null ? "其他" : familyShip);
                                 result.add(familyOne);
                             }
 
-                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(13));//联系电话2
+                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
                             if (!ObjectUtils.isEmpty(phoneTwo)) {
                                 if (phoneTwo.length() != 11) {
                                     return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
                                 }
                                 SmartUser familyTwo = new SmartUser();
-                                String familyNameTwo = dataFormatter.formatCellValue(row.getCell(14));//家属2
+                                String familyNameTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
                                 familyTwo.setName(!ObjectUtils.isEmpty(familyNameTwo) ? familyNameTwo : "家长");
                                 familyTwo.setDepartmentId(familyDepartmentId);
                                 familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
@@ -1342,21 +1361,21 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 familyTwo.setSexId(eSexStatu.Man.getValue());
                                 familyTwo.setIsCancel(eLogOff.Unlogout.getValue());
                                 familyTwo.setAffiliate(user.getCardNo());
-                                String familyShipTwo = dataFormatter.formatCellValue(row.getCell(15));//家属与本人关系2
+                                String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
                                 familyTwo.setShip(familyShipTwo == null ? "其他" : familyShipTwo);
                                 result.add(familyTwo);
                             }
                             //endregion
 
                             //希沃不允许一个学生家长的两个手机号重复 所以做一个重复性判断
-                            if (!ObjectUtils.isEmpty(phone) && !ObjectUtils.isEmpty(dataFormatter.formatCellValue(row.getCell(13)))) {
-                                if (phone.equals(dataFormatter.formatCellValue(row.getCell(13)))) {
+                            if (!ObjectUtils.isEmpty(phone) && !ObjectUtils.isEmpty(dataFormatter.formatCellValue(row.getCell(14)))) {
+                                if (phone.equals(dataFormatter.formatCellValue(row.getCell(14)))) {
                                     return CommonResult.fail(name + "的学生家长手机号不可重复");
                                 }
                             }
                             //endregion
                         }
-                    } else {
+                    }  else {
                         //教师导入
                         //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
                         //所以先使用setCellType()方法先将该单元格的类型设置为STRING
@@ -1572,65 +1591,69 @@ public class SmartUserController implements SmartUserControllerAPI {
                             if (!schoolClass.equals("班级")) {
                                 return CommonResult.fail("导入数据第一列为班级");
                             }
-                            String cardNo = dataFormatter.formatCellValue(row.getCell(2));//学号
+                            String departmentNo = dataFormatter.formatCellValue(row.getCell(2));//部门
+                            if (!departmentNo.equals("部门")) {
+                                return CommonResult.fail("导入数据第二列为部门");
+                            }
+                            String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
                             if (!cardNo.equals("学号")) {
                                 return CommonResult.fail("导入数据第二列为学号");
                             }
-                            String name = dataFormatter.formatCellValue(row.getCell(3));//姓名
+                            String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
                             if (!name.equals("姓名")) {
                                 return CommonResult.fail("导入数据第三列为姓名");
                             }
-                            String sex = dataFormatter.formatCellValue(row.getCell(4));//性别
+                            String sex = dataFormatter.formatCellValue(row.getCell(5));//性别
                             if (!sex.equals("性别")) {
                                 return CommonResult.fail("导入数据第四列为性别");
                             }
-                            String nation = dataFormatter.formatCellValue(row.getCell(5));//民族
+                            String nation = dataFormatter.formatCellValue(row.getCell(6));//民族
                             if (!nation.equals("民族")) {
                                 return CommonResult.fail("导入数据第五列为民族");
                             }
-                            String cardId = dataFormatter.formatCellValue(row.getCell(6));//身份证
+                            String cardId = dataFormatter.formatCellValue(row.getCell(7));//身份证
                             if (!cardId.equals("身份证")) {
                                 return CommonResult.fail("导入数据第六列为身份证");
                             }
-                            String headImage = dataFormatter.formatCellValue(row.getCell(7));//照片
+                            String headImage = dataFormatter.formatCellValue(row.getCell(8));//照片
                             if (!headImage.equals("照片")) {
                                 return CommonResult.fail("导入数据第七列为照片");
                             }
-                            String timeGroup = dataFormatter.formatCellValue(row.getCell(8));//常规时间组
+                            String timeGroup = dataFormatter.formatCellValue(row.getCell(9));//常规时间组
                             if (!timeGroup.equals("常规时间组")) {
                                 return CommonResult.fail("导入数据第八列为常规时间组");
                             }
-                            String address = dataFormatter.formatCellValue(row.getCell(9));//住址
+                            String address = dataFormatter.formatCellValue(row.getCell(10));//住址
                             if (!address.equals("住址")) {
                                 return CommonResult.fail("导入数据第九列为住址");
                             }
-                            String phone = dataFormatter.formatCellValue(row.getCell(10));//联系电话
+                            String phone = dataFormatter.formatCellValue(row.getCell(11));//联系电话
                             if (!phone.equals("联系电话")) {
                                 return CommonResult.fail("导入数据第十列为联系电话");
                             }
-                            String family = dataFormatter.formatCellValue(row.getCell(11));//家属
+                            String family = dataFormatter.formatCellValue(row.getCell(12));//家属
                             if (!family.equals("家属")) {
                                 return CommonResult.fail("导入数据第十一列为家属");
                             }
-                            String familyShip = dataFormatter.formatCellValue(row.getCell(12));//家属与本人关系
+                            String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
                             if (!familyShip.equals("家属与本人关系")) {
                                 return CommonResult.fail("导入数据第十二列为家属与本人关系");
                             }
-                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(13));//联系电话2
+                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
                             if (!phoneTwo.equals("联系电话2")) {
                                 return CommonResult.fail("导入数据第十三列为联系电话2");
                             }
-                            String familyTwo = dataFormatter.formatCellValue(row.getCell(14));//家属2
+                            String familyTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
                             if (!familyTwo.equals("家属2")) {
                                 return CommonResult.fail("导入数据第十四列为家属2");
                             }
-                            String familyShipTwo = dataFormatter.formatCellValue(row.getCell(15));//家属与本人关系2
+                            String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
                             if (!familyShipTwo.equals("家属与本人关系2")) {
                                 return CommonResult.fail("导入数据第十五列为家属与本人关系2");
                             }
                         } else {
                             SmartUser user = new SmartUser();
-                            String name = dataFormatter.formatCellValue(row.getCell(3));
+                            String name = dataFormatter.formatCellValue(row.getCell(4));
                             //                        if (ObjectUtils.isEmpty(name)) {
                             //                            return CommonResult.fail("第" + (rowNum + 1) + "条数据的名称不能为空");
                             //                        }
@@ -1649,7 +1672,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             //不判断重复性 因为会出现双胞胎
-                            String phone = dataFormatter.formatCellValue(row.getCell(10));
+                            String phone = dataFormatter.formatCellValue(row.getCell(11));
                             //                        if (!ObjectUtils.isEmpty(phone)) {
                             //                            phones.add(phone);
                             //                        }
@@ -1659,35 +1682,50 @@ public class SmartUserController implements SmartUserControllerAPI {
 
 
                             //性别是否为空判断
-                            String sex = dataFormatter.formatCellValue(row.getCell(4));
+                            String sex = dataFormatter.formatCellValue(row.getCell(5));
                             if (ObjectUtils.isEmpty(sex)) {
                                 return CommonResult.fail(name + "的性别不能为空");
                             }
 
                             //家庭住址是否为空判断
-                            String address = dataFormatter.formatCellValue(row.getCell(9));
+                            String address = dataFormatter.formatCellValue(row.getCell(10));
 
                             //民族是否为空判断
-                            String nation = dataFormatter.formatCellValue(row.getCell(5));
+                            String nation = dataFormatter.formatCellValue(row.getCell(6));
                             if (ObjectUtils.isEmpty(nation)) {
                                 return CommonResult.fail(name + "的民族不能为空");
                             }
 
                             //部门是否为空判断
-                            String department = dataFormatter.formatCellValue(row.getCell(1)).replace("年级", "") + "学生";
-                            if (ObjectUtils.isEmpty(department)) {
+                            String department = dataFormatter.formatCellValue(row.getCell(2));
+                            if (ObjectUtils.isEmpty(nation)) {
                                 return CommonResult.fail(name + "的部门不能为空");
                             }
+                            Integer parentDid = null;
                             Integer departmentId = null;
-                            Optional<SmartDepartment> departModel = departments.stream().filter(e -> e.getName().equals(department)).findFirst();
-                            if (departModel != null && departModel.isPresent()) {
-                                departmentId = departModel.get().getId();
-                            } else {
-                                departmentId = 1;
+                            String[] departmentStrs = department.split("/");
+                            for (int i = 0; i < departmentStrs.length; i++) {
+                                String departmentName = departmentStrs[i];
+                                Optional<SmartDepartment> oD = departments.stream().filter(e -> e.getName().equals(departmentName)).findFirst();
+                                if(oD != null && oD.isPresent()){
+                                    parentDid = oD.get().getId();
+                                }else{
+                                    String bsDepartment = insertDepartmentToBs(departmentName);
+                                    if(bsDepartment == null){
+                                        return CommonResult.fail(name + "的部门添加到百胜失败");
+                                    }
+                                    SmartDepartment sdParent = new SmartDepartment();
+                                    sdParent.setParentId(parentDid);
+                                    sdParent.setName(departmentName);
+                                    sdParent.setBsDepartmentNo(bsDepartment);
+                                    int departmentData = smartDepartmentService.insertSmartDepartment(sdParent);
+                                    departmentId = departmentData;
+                                    parentDid = departmentData;
+                                }
                             }
 
                             //学号重复判断
-                            String cardNo = dataFormatter.formatCellValue(row.getCell(2));
+                            String cardNo = dataFormatter.formatCellValue(row.getCell(3));
                             if (!ObjectUtils.isEmpty(cardNo)) {
                                 cardNos.add(cardNo);
                             }
@@ -1696,7 +1734,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             }
 
                             //身份证重复判断
-                            String idCard = dataFormatter.formatCellValue(row.getCell(6));
+                            String idCard = dataFormatter.formatCellValue(row.getCell(7));
                             if (!ObjectUtils.isEmpty(idCard)) {
                                 idCards.add(idCard);
                             }
@@ -1709,7 +1747,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             user.setIdCard(idCard == null ? "" : idCard);
                             user.setSexId(sex == null ? eSexStatu.Man.getValue() : eSexStatu.integerOf(sex));
                             user.setDepartmentId(departmentId);
-                            String cellImage = dataFormatter.formatCellValue(row.getCell(7));
+                            String cellImage = dataFormatter.formatCellValue(row.getCell(8));
                             user.setHeadImage(cellImage);
                             user.setDormitoryNumber("");
                             String grade = schoolGrade == null ? "" : schoolGrade;
@@ -1738,7 +1776,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                             user.setOfStudent("");
                             user.setGraduate("");
                             user.setDuties(null);
-                            String timeGroup = dataFormatter.formatCellValue(row.getCell(8));
+                            String timeGroup = dataFormatter.formatCellValue(row.getCell(9));
                             Optional<SmartTimeGroup> groupData = timeGroups.stream().filter(e -> e.getName().equals(timeGroup)).findFirst();
                             if (groupData != null && groupData.isPresent()) {
                                 user.setTimeGroupId(groupData.get().getId());
@@ -1769,7 +1807,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 }
 
                                 SmartUser familyOne = new SmartUser();
-                                String family = dataFormatter.formatCellValue(row.getCell(11));//家属
+                                String family = dataFormatter.formatCellValue(row.getCell(12));//家属
                                 familyOne.setName(!ObjectUtils.isEmpty(family) ? family : "家长");
                                 familyOne.setDepartmentId(familyDepartmentId);
                                 familyOne.setPhone(phone);
@@ -1777,18 +1815,18 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 familyOne.setSexId(eSexStatu.Man.getValue());
                                 familyOne.setIsCancel(eLogOff.Unlogout.getValue());
                                 familyOne.setAffiliate(user.getCardNo());
-                                String familyShip = dataFormatter.formatCellValue(row.getCell(12));//家属与本人关系
+                                String familyShip = dataFormatter.formatCellValue(row.getCell(13));//家属与本人关系
                                 familyOne.setShip(familyShip == null ? "其他" : familyShip);
                                 result.add(familyOne);
                             }
 
-                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(13));//联系电话2
+                            String phoneTwo = dataFormatter.formatCellValue(row.getCell(14));//联系电话2
                             if (!ObjectUtils.isEmpty(phoneTwo)) {
                                 if (phoneTwo.length() != 11) {
                                     return CommonResult.fail(name + "的学生家长手机号长度不符合标准");
                                 }
                                 SmartUser familyTwo = new SmartUser();
-                                String familyNameTwo = dataFormatter.formatCellValue(row.getCell(14));//家属2
+                                String familyNameTwo = dataFormatter.formatCellValue(row.getCell(15));//家属2
                                 familyTwo.setName(!ObjectUtils.isEmpty(familyNameTwo) ? familyNameTwo : "家长");
                                 familyTwo.setDepartmentId(familyDepartmentId);
                                 familyTwo.setPhone(phoneTwo == null ? "" : phoneTwo);
@@ -1796,15 +1834,15 @@ public class SmartUserController implements SmartUserControllerAPI {
                                 familyTwo.setSexId(eSexStatu.Man.getValue());
                                 familyTwo.setIsCancel(eLogOff.Unlogout.getValue());
                                 familyTwo.setAffiliate(user.getCardNo());
-                                String familyShipTwo = dataFormatter.formatCellValue(row.getCell(15));//家属与本人关系2
+                                String familyShipTwo = dataFormatter.formatCellValue(row.getCell(16));//家属与本人关系2
                                 familyTwo.setShip(familyShipTwo == null ? "其他" : familyShipTwo);
                                 result.add(familyTwo);
                             }
                             //endregion
 
                             //希沃不允许一个学生家长的两个手机号重复 所以做一个重复性判断
-                            if (!ObjectUtils.isEmpty(phone) && !ObjectUtils.isEmpty(dataFormatter.formatCellValue(row.getCell(13)))) {
-                                if (phone.equals(dataFormatter.formatCellValue(row.getCell(13)))) {
+                            if (!ObjectUtils.isEmpty(phone) && !ObjectUtils.isEmpty(dataFormatter.formatCellValue(row.getCell(14)))) {
+                                if (phone.equals(dataFormatter.formatCellValue(row.getCell(14)))) {
                                     return CommonResult.fail(name + "的学生家长手机号不可重复");
                                 }
                             }
@@ -1973,6 +2011,46 @@ public class SmartUserController implements SmartUserControllerAPI {
     }
     //endregion
 
+
+    public String insertDepartmentToBs(String name) throws Exception {
+        //region 百胜添加部门数据
+        String appId = controlConfig.getAppId();
+        String schoolno = controlConfig.getSchoolCode();
+        String timestamp = TimeExchange.DateNowTimeStamo();
+        String appSecret = controlConfig.getAppSecret();
+        String url = controlConfig.getUrl() + "department/create";
+
+        JSONObject jsonobject = new JSONObject();
+        jsonobject.put("appid", appId);
+        String str = "{\"department_name\":\"" + name + "\"}";
+        String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
+        jsonobject.put("data", aesStr);
+        jsonobject.put("schoolno", schoolno);
+        jsonobject.put("timestamp", timestamp);
+
+        String md5Str = "appid=" + appId + "&data={\"department_name\":\"" + name + "\"}" + "&schoolno=" + schoolno + "&timestamp=" + timestamp + "&key=" + appSecret;
+        String sign = CommonUtil.MD5(md5Str);
+        //sign签名
+        jsonobject.put("sign", sign);
+
+        //返回的结果中 code为1表示成功
+        String bsResult = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+        if (bsResult.contains("添加成功")) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            BsDepartmentVo department = objectMapper.readValue(bsResult, BsDepartmentVo.class);
+
+            // URL解码
+            String decodedUrl = URLDecoder.decode(department.getData(), "UTF-8");
+
+            BsDepartmentNoVo departmentData = objectMapper.readValue(decrypt(decodedUrl, controlConfig.getAppSecret()), BsDepartmentNoVo.class);
+
+            return departmentData.getDepartment_no();
+        }
+        //endregion
+
+        return null;
+    }
     //endregion
 
     //region 批量更新用户
@@ -2523,7 +2601,7 @@ public class SmartUserController implements SmartUserControllerAPI {
 
             //region 希沃新增编辑学生家长信息
             if (useXw == 1) {
-                CommonResult insertOrUpdateStudent = insertOrUpdateStudentParent(seewoClient, studentDatas, isur.getName(), isur.getPhone(), true);
+                CommonResult insertOrUpdateStudent = insertOrUpdateStudentParent(seewoClient, studentDatas, "其他", isur.getPhone(), true);
                 if (!insertOrUpdateStudent.isSuccess()) {
                     return CommonResult.fail("希沃平台:" + insertOrUpdateStudent.getMessage());
                 }
@@ -2855,7 +2933,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                 //region 希沃新增编辑学生家长信息
                 if (useXw == 1) {
                     //学生与家长列表,最大100条
-                    CommonResult insertOrUpdateResult = insertOrUpdateStudentParent(seewoClient, studentDatas, usur.getName(), usur.getPhone(), false);
+                    CommonResult insertOrUpdateResult = insertOrUpdateStudentParent(seewoClient, studentDatas, "其他", usur.getPhone(), false);
                     if (!insertOrUpdateResult.isSuccess()) {
                         return CommonResult.fail("希沃平台:" + insertOrUpdateResult.getMessage());
                     }
@@ -2929,7 +3007,7 @@ public class SmartUserController implements SmartUserControllerAPI {
                         return CommonResult.fail("绑定失败,希沃学生家长最多绑定四个家长");
                     }
 
-                    CommonResult insertOrUpdate = insertOrUpdateStudentParent(seewoClient, studentDatas, su.getName(), su.getPhone(), true);
+                    CommonResult insertOrUpdate = insertOrUpdateStudentParent(seewoClient, studentDatas, su.getShip(), su.getPhone(), true);
                     if (!insertOrUpdate.isSuccess()) {
                         return CommonResult.fail("希沃平台:" + insertOrUpdate.getMessage());
                     }
@@ -3892,8 +3970,7 @@ public class SmartUserController implements SmartUserControllerAPI {
     //endregion
 
     //region 希沃新增编辑学生家长信息
-    public CommonResult insertOrUpdateStudentParent(SeewoClient
-                                                            seewoClient, List<SmartUser> studentDatas, String name, String phone, boolean isInsert) {
+    public CommonResult insertOrUpdateStudentParent(SeewoClient seewoClient, List<SmartUser> studentDatas, String name, String phone, boolean isInsert) {
 
         //region 希沃新增编辑学生家长信息
         //学生与家长列表,最大100条
@@ -5334,8 +5411,8 @@ public class SmartUserController implements SmartUserControllerAPI {
 
         for (int i = 0; i < vos.size(); i++) {
             StatisticsStatementVo vo = vos.get(i);
-            Row dataRow = sheet.createRow(i+1);
-            dataRow.createCell(0).setCellValue(i+1);
+            Row dataRow = sheet.createRow(i + 1);
+            dataRow.createCell(0).setCellValue(i + 1);
             dataRow.createCell(1).setCellValue(vo.getGradeName());
             dataRow.createCell(2).setCellValue(vo.getClassName());
             dataRow.createCell(3).setCellValue(vo.getNormal());

+ 4 - 0
src/main/java/com/template/services/SmartClassService.java

@@ -24,6 +24,8 @@ public interface SmartClassService extends IService<SmartClass> {
 
     List<SmartClass> getSmartClasss();
 
+    List<SmartClass> getSmartClasssLikeName(String name);
+
     int existSmartClass(String className, Integer gradeId);
 
     int insertSmartClass(SmartClass sc);
@@ -44,4 +46,6 @@ public interface SmartClassService extends IService<SmartClass> {
 
     List<SmartClass> getSmartClasss(List<Integer> ids);
 
+    List<SmartClass> getSmartClasssByGrade(List<Integer> gradeIds);
+
 }

+ 4 - 0
src/main/java/com/template/services/SmartGradeService.java

@@ -18,6 +18,8 @@ public interface SmartGradeService extends IService<SmartGrade> {
 
     List<SmartGrade> getSmartGrades();
 
+    List<SmartGrade> getSmartGrades(List<String> names);
+
     int insertSmartGrade(SmartGrade sg);
 
     int updateSmartGrade(SmartGrade sg);
@@ -35,4 +37,6 @@ public interface SmartGradeService extends IService<SmartGrade> {
     List<SmartGrade> queryGradeByIds(List<Integer> ids);
 
     int deleteGradeById(Integer id);
+
+    SmartGrade querySmartGradeByName(String name);
 }

+ 2 - 0
src/main/java/com/template/services/SmartUserService.java

@@ -44,6 +44,8 @@ public interface SmartUserService extends IService<SmartUser> {
 
     List<AffiliateUserVo> queryAffiliateUserById(@Param("id") Integer id);
 
+    List<SmartUser> queryDatasByDepartments(List<Integer> departments);
+
     PageUtils<UserVo> querySmartUserPages(int currentPage, int pageCount, List<Integer> departmentIds, String name);
 
     PageUtils<GradeVo> querySmartSecordPage(int currentPage, int pageCount, String name, Integer userId);

+ 16 - 0
src/main/java/com/template/services/impl/SmartClassServiceImpl.java

@@ -52,6 +52,14 @@ public class SmartClassServiceImpl extends ServiceImpl<SmartClassMapper, SmartCl
     }
 
     @Override
+    public List<SmartClass> getSmartClasssLikeName(String name) {
+        QueryWrapper<SmartClass> queryWrapper = new QueryWrapper<>();
+        queryWrapper.likeRight( "name", name);
+        List<SmartClass> result = smartClassMapper.selectList(queryWrapper);
+        return result;
+    }
+
+    @Override
     public int existSmartClass(String className, Integer gradeId) {
         //查重
         QueryWrapper<SmartClass> queryWrapper = new QueryWrapper<>();
@@ -125,4 +133,12 @@ public class SmartClassServiceImpl extends ServiceImpl<SmartClassMapper, SmartCl
         List<SmartClass> result = smartClassMapper.selectList(queryWrapper);
         return result;
     }
+
+    @Override
+    public List<SmartClass> getSmartClasssByGrade(List<Integer> gradeIds) {
+        QueryWrapper<SmartClass> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("grade_id", gradeIds);
+        List<SmartClass> result = smartClassMapper.selectList(queryWrapper);
+        return result;
+    }
 }

+ 1 - 1
src/main/java/com/template/services/impl/SmartDepartmentServiceImpl.java

@@ -32,7 +32,7 @@ public class SmartDepartmentServiceImpl extends ServiceImpl<SmartDepartmentMappe
     @Override
     public int insertSmartDepartment(SmartDepartment sa) {
         int result = smartDepartmentMapper.insert(sa);
-        return result;
+        return sa.getId();
     }
 
     @Override

+ 17 - 1
src/main/java/com/template/services/impl/SmartGradeServiceImpl.java

@@ -41,9 +41,17 @@ public class SmartGradeServiceImpl extends ServiceImpl<SmartGradeMapper, SmartGr
     }
 
     @Override
+    public List<SmartGrade> getSmartGrades(List<String> names) {
+        QueryWrapper<SmartGrade> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in(names != null && names.size() > 0, "name", names);
+        List<SmartGrade> existCount = smartGradeMapper.selectList(queryWrapper);
+        return existCount;
+    }
+
+    @Override
     public int insertSmartGrade(SmartGrade sg) {
         int result = smartGradeMapper.insert(sg);
-        return result;
+        return sg.getId();
     }
 
     @Override
@@ -101,4 +109,12 @@ public class SmartGradeServiceImpl extends ServiceImpl<SmartGradeMapper, SmartGr
         return delete;
     }
 
+    @Override
+    public SmartGrade querySmartGradeByName(String name) {
+        QueryWrapper<SmartGrade> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("name", name);
+        SmartGrade result = smartGradeMapper.selectOne(queryWrapper);
+        return result;
+    }
+
 }

+ 8 - 0
src/main/java/com/template/services/impl/SmartUserServiceImpl.java

@@ -190,6 +190,14 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
     }
 
     @Override
+    public List<SmartUser> queryDatasByDepartments(List<Integer> departments) {
+        QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
+        queryWrapper.in("department_id", departments);
+        List<SmartUser> users = smartUserMapper.selectList(queryWrapper);
+        return users;
+    }
+
+    @Override
     public List<SmartUser> queryStudentDatas() {
         QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
         queryWrapper.eq("is_cancel", 0);