Ver código fonte

Merge branch 'pre'

dzx 7 meses atrás
pai
commit
8f29def2e5

+ 0 - 1
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java

@@ -462,7 +462,6 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
                         .eq(BandingTask::getGradeId, baseClass.getGradeId())
                         .eq(BandingTask::getEnrollType, baseClass.getEnrollType())
                         .orderByDesc(BandingTask::getId)
-                        .eq(BandingTask::getStatus, 0)
         );
         if(bandingTasks.isEmpty()){
             return true;

+ 1 - 1
src/main/java/com/xjrsoft/module/hikvision/util/DataUtil.java

@@ -394,7 +394,7 @@ public class DataUtil {
         }
 
         //插入记录表
-        //insertRecord(tableName, idMap);
+        insertRecord(tableName, idMap);
         return idMap;
     }
 

+ 84 - 2
src/main/java/com/xjrsoft/module/job/OfficialDocumentReceivedHandleTask.java

@@ -1,8 +1,20 @@
 package com.xjrsoft.module.job;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.oa.entity.OfficialDocumentReceived;
+import com.xjrsoft.module.oa.entity.OfficialDocumentReceivedHandle;
 import com.xjrsoft.module.oa.service.IOfficialDocumentReceivedHandleService;
+import com.xjrsoft.module.oa.service.IOfficialDocumentReceivedService;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
+import com.xjrsoft.module.organization.vo.WeChatPageVO;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsCalendarInfoDto;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsGraduationInfoDto;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsInfoDto;
@@ -12,8 +24,10 @@ import com.xjrsoft.module.student.service.IPbCseFeeobjupdateService;
 import com.xjrsoft.module.student.vo.EnrollmentStatisticsCalendarInfoVo;
 import com.xjrsoft.module.student.vo.EnrollmentStatisticsGraduationInfoVo;
 import com.xjrsoft.module.student.vo.EnrollmentStatisticsInfoVo;
+import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
 import com.yomahub.liteflow.util.JsonUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -21,9 +35,13 @@ import org.springframework.stereotype.Component;
 
 import java.time.DayOfWeek;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 将招生计划数据固化
@@ -37,15 +55,79 @@ public class OfficialDocumentReceivedHandleTask {
 
 
     @Autowired
-    private IOfficialDocumentReceivedHandleService officialDocumentReceivedHandleService;
+    private IOfficialDocumentReceivedHandleService handleService;
+
+    @Autowired
+    private IUserService userService;
+
+    @Autowired
+    private IOfficialDocumentReceivedService receivedService;
+
+    @Autowired
+    private IWeChatService weChatService;
 
     @Async
-    @Scheduled(cron = "00 0/30 * * * ?")
+    @Scheduled(cron = "00 0/60 * * * ?")
     public void execute() {
         doExecute();
     }
 
     void doExecute() {
+        LocalDateTime now = LocalDateTime.now().withMinute(0).withSecond(0);
+        List<User> list = userService.list(
+                new MPJLambdaWrapper<User>()
+                        .select(User::getId)
+                        .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
+                        .innerJoin(OfficialDocumentReceivedHandle.class, OfficialDocumentReceivedHandle::getCreateUserId, User::getId)
+                        .eq(OfficialDocumentReceivedHandle::getAlertTime, now)
+                        .isNotNull(User::getOpenId)
+        );
+
+        List<OfficialDocumentReceived> documentReceivedList = receivedService.list(
+                new MPJLambdaWrapper<OfficialDocumentReceived>()
+                        .select(OfficialDocumentReceived::getId)
+                        .select(OfficialDocumentReceived.class, x -> VoToColumnUtil.fieldsToColumns(OfficialDocumentReceived.class).contains(x.getProperty()))
+                        .innerJoin(WorkflowFormRelation.class, WorkflowFormRelation::getFormKeyValue, OfficialDocumentReceived::getId)
+                        .eq(WorkflowFormRelation::getCurrentState, HistoricProcessInstance.STATE_COMPLETED)
+        );
+
+        Map<Long, OfficialDocumentReceived> documentReceivedMap = documentReceivedList.stream().collect(Collectors.toMap(OfficialDocumentReceived::getId, x -> x));
+
+        List<OfficialDocumentReceivedHandle> handleList = handleService.list(
+                new QueryWrapper<OfficialDocumentReceivedHandle>().lambda()
+                        .eq(OfficialDocumentReceivedHandle::getAlertTime, now)
+        );
+        Map<Long, List<OfficialDocumentReceivedHandle>> handleGroupMap = handleList.stream().collect(Collectors.groupingBy(OfficialDocumentReceivedHandle::getCreateUserId));
+
+        for (User user : list) {
+            List<OfficialDocumentReceivedHandle> handles = handleGroupMap.get(user.getId());
+            for (OfficialDocumentReceivedHandle handle : handles) {
+                if(handle.getIsHandle() == 1){
+                    continue;
+                }
+                OfficialDocumentReceived received = documentReceivedMap.get(handle.getOfficialDocumentReceivedId());
+
+                WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                weChatSendMessageDto.setUserId(user.getOpenId());
+                weChatSendMessageDto.setTemplateId("qmpXORPM1Cocqn503Qa4On6BJhR92UZ00eod2-6IcGo");
+                //weChatSendMessageDto.setUrl(StrUtil.format("{}/pages/message/notice/detail?id={}", commonPropertiesConfig.getDomainApp(), id));
+                weChatSendMessageDto.setMsgId(handle.getId().toString());
+                JSONObject data = new JSONObject();
+
+                JSONObject thing23 = new JSONObject();
+                thing23.put("value", "您有一个行政收文待处理");
+                data.put("thing23", thing23);
+
+                JSONObject data2 = new JSONObject();
+                data2.put("value", user.getName());
+                data.put("thing29", data2);
 
+                JSONObject data3 = new JSONObject();
+                data3.put("value", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+                data.put("time17", data3);
+                weChatSendMessageDto.setContent(data);
+                weChatService.sendTemplateMessage(weChatSendMessageDto);
+            }
+        }
     }
 }

+ 28 - 0
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -7,6 +7,7 @@ import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
@@ -40,9 +41,11 @@ import com.xjrsoft.module.organization.service.*;
 import com.xjrsoft.module.organization.utils.OrganizationUtil;
 import com.xjrsoft.module.organization.vo.*;
 import com.xjrsoft.module.oss.factory.OssFactory;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.entity.BaseStudent;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.system.entity.File;
@@ -115,6 +118,7 @@ public class UserController {
     private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
     private final IWhitelistManagementService whitelistManagementService;
     private final IWorkflowCirculatedService circulatedService;
+    private final IBaseNewStudentService baseNewStudentService;
 
     @GetMapping(value = "/list")
     @ApiOperation(value = "用户列表(不分页)")
@@ -741,6 +745,30 @@ public class UserController {
     @ApiOperation(value = "家长注册")
     @XjrLog(value = "家长注册", saveResponseData = true)
     public R register(@Valid @RequestBody RegisterDto dto) {
+        //验证家长手机号是否已经注册
+        LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        userLambdaQueryWrapper
+                .eq(User::getMobile, dto.getMobile())
+                .eq(User::getDeleteMark, DeleteMark.NODELETE.getCode())
+                .last("limit 1")
+                ;
+        User user =  userService.getOne(userLambdaQueryWrapper);
+        if(ObjectUtils.isNotEmpty(user)){
+            throw new MyException("当前手机号已被" + user.getName() + "使用,请更换手机号注册!");
+        }
+
+        //验证新生注册家长的手机号是否是学生自己的
+        LambdaQueryWrapper<BaseNewStudent> baseNewStudentLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        baseNewStudentLambdaQueryWrapper
+                .eq(BaseNewStudent::getMobile, dto.getMobile())
+                .eq(BaseNewStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
+                .last("limit 1")
+        ;
+        BaseNewStudent baseNewStudent =  baseNewStudentService.getOne(baseNewStudentLambdaQueryWrapper);
+        if(ObjectUtils.isNotEmpty(baseNewStudent)){
+            throw new MyException("当前手机号为学生" + baseNewStudent.getName() + "填写的学生手机号,请更换手机号注册!");
+        }
+
         // 验证验证码
         if (!smsCtcc.captchaVerify(dto.getMobile(), dto.getSmsCode())) {
             return R.error("验证码不正确!");

+ 47 - 14
src/main/java/com/xjrsoft/module/student/service/impl/StudentManagerServiceImpl.java

@@ -18,6 +18,7 @@ import com.xjrsoft.common.enums.*;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.TreeUtil;
+import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseGrade;
@@ -507,6 +508,8 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         //查询所有学生的用户信息,组装起来备用
         List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
                 new MPJLambdaWrapper<BaseStudentUser>()
+                        .select(BaseStudentUser::getId)
+                        .select(BaseStudentUser.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentUser.class).contains(x.getProperty()))
                         .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentUser::getId)
                         .in(BaseStudentUser::getCredentialNumber, idNumbers)
         );
@@ -519,6 +522,8 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         //查询所有的学生信息,组装起来备用
         List<BaseStudent> baseStudents = baseStudentService.selectJoinList(BaseStudent.class,
                 new MPJLambdaWrapper<BaseStudent>()
+                        .select(BaseStudent::getId)
+                        .select(BaseStudent.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudent.class).contains(x.getProperty()))
                         .leftJoin(BaseStudentUser.class, BaseStudentUser::getId, BaseStudent::getUserId)
                         .in(BaseStudentUser::getCredentialNumber, idNumbers)
         );
@@ -537,6 +542,8 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
 
         List<BaseStudentSchoolRoll> baseStudentSchoolRolls = schoolRollService.selectJoinList(BaseStudentSchoolRoll.class,
                 new MPJLambdaWrapper<BaseStudentSchoolRoll>()
+                        .select(BaseStudentSchoolRoll::getId)
+                        .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
                         .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
                         .in(!userIds.isEmpty(), BaseStudentSchoolRoll::getUserId, userIds)
         );
@@ -555,9 +562,9 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         }
         //查询班级
         List<BaseClass> classList = baseClassMapper.selectList(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode()));
-        Map<String, Long> classMap = new HashMap<>();
-        for (BaseClass grade : classList) {
-            classMap.put(grade.getName(), grade.getId());
+        Map<String, BaseClass> classMap = new HashMap<>();
+        for (BaseClass baseclass : classList) {
+            classMap.put(baseclass.getName(), baseclass);
         }
         //查询专业
         List<BaseMajorSet> majorSetList = baseMajorSetMapper.selectList(new QueryWrapper<BaseMajorSet>().lambda().eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode()));
@@ -861,8 +868,11 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
             if (dataMaps.get(52) != null && !"".equals(dataMaps.get(52).toString())) {
                 schoolRoll.setStudyYear(Double.parseDouble(dataMaps.get(52).toString()));//学制
             }
-            if (dataMaps.get(53) != null && !"".equals(dataMaps.get(53).toString())) {
-                //schoolRoll.setClassId(classMap.get(dataMaps.get(53).toString()));//班级
+            if (dataMaps.get(53) != null && !"".equals(dataMaps.get(53).toString()) && schoolRoll.getId() == null) {
+                schoolRoll.setClassId(classMap.get(dataMaps.get(53).toString()).getId());//班级
+                if(schoolRoll.getMajorSetId() == null){
+                    schoolRoll.setMajorSetId(classMap.get(dataMaps.get(53).toString()).getMajorSetId());
+                }
             }
             if (dataMaps.get(54) != null && !"".equals(dataMaps.get(54).toString())) {
                 schoolRoll.setStudentSource(dictionary.get("student_type" + dataMaps.get(54).toString()));//学生来源
@@ -959,23 +969,46 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
             if (dataMaps.get(83) != null && !"".equals(dataMaps.get(83).toString())) {
                 studentFamily.setRailwayStation(dataMaps.get(83).toString());//离家最近火车站
             }
-            if (studentUserMap.containsKey(credentialNumber)) {
+
+            if(studentUserMap.containsKey(credentialNumber)){
                 updateStudentUserList.add(user);
-                updateBaseStudentList.add(baseStudent);
-                updateSchoolRollList.add(schoolRoll);
-                updateSubsidizeList.add(subsidize);
-                updateFamilyList.add(studentFamily);
-                updateContactList.add(contact);
-            } else {
+            }else{
                 insertStudentUserList.add(user);
+            }
+
+            if(baseStudent.getId() == null){
                 insertBaseStudentList.add(baseStudent);
-                if (schoolRoll.getClassId() != null && schoolRoll.getGradeId() != null && schoolRoll.getMajorSetId() != null) {
-                    insertSchoolRollList.add(schoolRoll);
+            }else{
+                updateBaseStudentList.add(baseStudent);
+            }
+
+            if(schoolRoll.getId() == null){
+                if(schoolRoll.getArchivesStatus() == null){
+                    schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
                 }
+                insertSchoolRollList.add(schoolRoll);
+            }else{
+                updateSchoolRollList.add(schoolRoll);
+            }
+
+            if(subsidize.getId() == null){
                 insertSubsidizeList.add(subsidize);
+            }else{
+                updateSubsidizeList.add(subsidize);
+            }
+
+            if(studentFamily.getId() == null){
                 insertFamilyList.add(studentFamily);
+            }else{
+                updateFamilyList.add(studentFamily);
+            }
+
+            if(contact.getId() == null){
                 insertContactList.add(contact);
+            }else{
+                updateContactList.add(contact);
             }
+
             row++;
         }
         //批量修改

+ 1 - 1
src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java

@@ -446,7 +446,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
                 schoolRoll.setMajorSetId(baseClass.getMajorSetId());
                 schoolRoll.setStduyStatus(student.getStduyStatus());
                 schoolRoll.setEnrollType(baseClass.getEnrollType());
-                schoolRoll.setStudentSource(student.getSource());
+                schoolRoll.setStudentType(student.getSource());
                 schoolRoll.setGradeId(baseClass.getGradeId());
                 schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
                 schoolRoll.setCreateDate(now);

+ 15 - 0
src/main/java/com/xjrsoft/module/textbook/entity/WfTextbookRecede.java

@@ -77,6 +77,21 @@ public class WfTextbookRecede implements Serializable {
      */
     @ApiModelProperty("申请人")
     private Long applicantUserId;
+    /**
+     * 是否是学生
+     */
+    @ApiModelProperty("是否是学生")
+    private Integer isStuFlag;
+    /**
+     * 是否是班主任
+     */
+    @ApiModelProperty("是否是班主任")
+    private Integer isHeadTeaFlag;
+    /**
+     * 是否是班主任为班级退书
+     */
+    @ApiModelProperty("是否是班主任为班级退书")
+    private Integer isClassRecedeFlag;
     /**
      * 学期ID(base_semester)
      */

+ 1 - 0
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookIssueRecordServiceImpl.java

@@ -190,6 +190,7 @@ public class TextbookIssueRecordServiceImpl extends MPJBaseServiceImpl<TextbookI
                 .selectAs(TextbookIssueRecord::getActualIssueNumber, CanReturnTextbookListVo::getActualIssueNumber)
                 .leftJoin(Textbook.class, Textbook::getId, TextbookIssueRecord::getTextbookId)
                 .eq(StringUtils.isNotEmpty(dto.getBaseSemesterId()), TextbookIssueRecord::getBaseSemesterId, dto.getBaseSemesterId())
+                .gt(TextbookIssueRecord::getIssueNumber, TextbookIssueRecord::getRecedeNumber)
         ;
 
         // 个人退书

+ 51 - 8
src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookRecedeServiceImpl.java

@@ -13,6 +13,7 @@ import com.xjrsoft.module.textbook.service.IWfTextbookRecedeService;
 import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
 import com.xjrsoft.module.workflow.mapper.WorkflowFormRelationMapper;
 import lombok.AllArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.camunda.bpm.engine.history.HistoricProcessInstance;
 import org.springframework.stereotype.Service;
@@ -21,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -46,6 +44,8 @@ public class WfTextbookRecedeServiceImpl extends MPJBaseServiceImpl<WfTextbookRe
 
     private final TextbookIssueRecordMapper textbookIssueRecordMapper;
 
+    private final TextbookStudentClaimMapper textbookStudentClaimMapper;
+
     private final WorkflowFormRelationMapper workflowFormRelationMapper;
 
     @Override
@@ -123,6 +123,7 @@ public class WfTextbookRecedeServiceImpl extends MPJBaseServiceImpl<WfTextbookRe
                 && HistoricProcessInstance.STATE_COMPLETED.equals(workflowFormRelation.getCurrentState())
         ) {
             // 退书类型是到教务处
+            // 学生已经领取的教材退书的时候应该将领取状态改为退书
             if (RecedeTypeEnum.RecedeeDansOffice.getCode().equals(wfTextbookRecede.getRecedeType())) {
                 List<WfTextbookRecedeItem> wfTextbookRecedeItemList = wfTextbookRecede.getWfTextbookRecedeItemList();
                 if (ObjectUtils.isNotEmpty(wfTextbookRecedeItemList)) {
@@ -150,23 +151,54 @@ public class WfTextbookRecedeServiceImpl extends MPJBaseServiceImpl<WfTextbookRe
                     Map<Long, TextbookWarehouseRecord> textbookWarehouseRecordMap = textbookWarehouseRecords.stream()
                             .collect(Collectors.toMap(TextbookWarehouseRecord::getId, t -> t, (t1, t2) -> t1));
 
+                    // 获取当前退书班级所有的领取记录
+                    LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    textbookStudentClaimLambdaQueryWrapper
+                            .eq(TextbookStudentClaim::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            ;
+
+                    if(wfTextbookRecede.getIsStuFlag() == 1){
+                        textbookStudentClaimLambdaQueryWrapper
+                                .eq(TextbookStudentClaim::getStudentUserId, wfTextbookRecede.getApplicantUserId())
+                                ;
+                    }
+
+                    // 如果是班主任帮班级退书
+                    if(wfTextbookRecede.getIsStuFlag() == 0){
+                        if(wfTextbookRecede.getIsHeadTeaFlag() == 1
+                                && wfTextbookRecede.getIsClassRecedeFlag() == 1){
+                            textbookStudentClaimLambdaQueryWrapper
+                                    .eq(TextbookStudentClaim::getClassId, wfTextbookRecede.getClassId())
+                            ;
+                        }else {
+                            textbookStudentClaimLambdaQueryWrapper
+                                    .eq(TextbookStudentClaim::getStudentUserId, wfTextbookRecede.getApplicantUserId())
+                            ;
+                        }
+                    }
+                    List<TextbookStudentClaim> textbookStudentClaims = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
+                    Map<Long, List<TextbookStudentClaim>> groupByTextbookId = textbookStudentClaims.stream()
+                            .collect(Collectors.groupingBy(TextbookStudentClaim::getTextbookId));
+
                     //遍历每一个退书申请项
                     TextbookWarehouseRecord oldTextbookWarehouseRecord;
                     TextbookWarehouseRecordDetail textbookWarehouseRecordDetail;
                     TextbookWarehouseRecord updateTextbookWarehouseRecord;
                     TextbookIssueRecord oldTextbookIssueRecord;
-                    TextbookIssueRecord newTextbookIssueRecord;
                     TextbookIssueRecord updateTextbookIssueRecord;
                     for (WfTextbookRecedeItem wfTextbookRecedeItem : wfTextbookRecedeItemList) {
                         // 退书项对应的出库记录
                         oldTextbookIssueRecord = textbookIssueRecordMap.get(wfTextbookRecedeItem.getTextbookIssueRecordId());
+
+                        if(ObjectUtils.isEmpty(oldTextbookIssueRecord)){
+                            continue;
+                        }
+
                         // 退书项对应的出库记录对应的入库记录
                         oldTextbookWarehouseRecord = textbookWarehouseRecordMap.get(oldTextbookIssueRecord.getTextbookWarehouseRecordId());
 
                         // 退书类型是到教务处
-                        if (ObjectUtils.isNotEmpty(oldTextbookWarehouseRecord)
-                                && ObjectUtils.isNotEmpty(oldTextbookIssueRecord)
-                        ) {
+                        if (ObjectUtils.isNotEmpty(oldTextbookWarehouseRecord)) {
                             // 增加入库详情记录
                             textbookWarehouseRecordDetail = new TextbookWarehouseRecordDetail();
                             textbookWarehouseRecordDetail.setTextbookWarehouseRecordId(oldTextbookWarehouseRecord.getId());
@@ -205,6 +237,17 @@ public class WfTextbookRecedeServiceImpl extends MPJBaseServiceImpl<WfTextbookRe
                             updateTextbookIssueRecord.setModifyDate(nowDate);
                             textbookIssueRecordMapper.updateById(updateTextbookIssueRecord);
                         }
+
+                        List<TextbookStudentClaim> claimList = groupByTextbookId.get(wfTextbookRecedeItem.getTextbookId());
+                        if(CollectionUtils.isNotEmpty(claimList)){
+                            for (TextbookStudentClaim textbookStudentClaim : claimList){
+                                TextbookStudentClaim updateTextbookStudentClaim = new TextbookStudentClaim();
+                                updateTextbookStudentClaim.setId(textbookStudentClaim.getId());
+                                updateTextbookStudentClaim.setPrice(BigDecimal.ZERO);
+                                updateTextbookStudentClaim.setIsClaim(2);
+                                textbookStudentClaimMapper.updateById(updateTextbookStudentClaim);
+                            }
+                        }
                     }
                 }
             }

+ 2 - 1
src/main/resources/mapper/student/WfCadreCandidateMapper.xml

@@ -14,7 +14,8 @@
                  LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
                  LEFT JOIN cadre_dept t2 ON (t2.id = t.cadre_dept_id)
                  LEFT JOIN xjr_user t3 ON (t3.id = t.instructor_user_id)
-        WHERE t.delete_mark = 0
+                left join xjr_workflow_form_relation t4 on t.id = CAST(t4.form_key_value AS SIGNED)
+        WHERE t.delete_mark = 0 and t4.current_state = 'COMPLETED'
         <if test="dto.cadreDeptId != null and dto.cadreDeptId > 0">
             and t.cadre_dept_id = #{dto.cadreDeptId}
         </if>

+ 49 - 0
src/test/java/com/xjrsoft/module/job/HikvisionBaseDataTaskTest.java

@@ -615,4 +615,53 @@ class HikvisionBaseDataTaskTest {
         System.out.println(result);
     }
 
+    /**
+     * 同步海康学生信息到hikvision_data表中
+     */
+    @Test
+    void syncStudentId(){
+        String sql = "SELECT t1.* FROM hikvision_data t1" +
+                " INNER JOIN base_class t2 ON t1.source_id LIKE CONCAT(t2.id, '%')" +
+                " WHERE t1.table_name = 'base_class'" +
+                " AND t2.grade_id = 1868532405673439232";
+        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
+        List<String> orgIndexCodes = new ArrayList<>();
+        for (int i = 0; i < list.size(); i ++){
+            Map<String, Object> dataMap = list.get(i);
+            orgIndexCodes.add(dataMap.get("hikvision_id").toString());
+        }
+
+        JsonParser jsonParser = new JsonParser();
+        ApiUtil apiUtil = new ApiUtil();
+        String apiPath = "/api/resource/v2/person/advance/personList";
+
+        Set<String> personIds = new HashSet<>();
+        for (String orgIndexCode : orgIndexCodes) {
+            JsonObject jsonObject = new JsonObject();
+            jsonObject.addProperty("pageNo", 1);
+            jsonObject.addProperty("pageSize", 500);
+            jsonObject.addProperty("orgIndexCodes", orgIndexCode);
+
+            String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
+
+            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+            JsonArray array = resultJson.get("data").getAsJsonObject().get("list").getAsJsonArray();
+            for (JsonElement jsonElement : array) {
+                JsonObject element = jsonElement.getAsJsonObject();
+                String personId = element.get("personId").getAsString();
+                personIds.add(personId);
+            }
+        }
+
+        for (String personId : personIds) {
+            String insertsql = "INSERT INTO hikvision_data(create_date,TABLE_NAME,source_id,hikvision_id) " +
+                    " SELECT NOW(),'base_student','" + personId + "','" + personId + "'" +
+                    " where not EXISTS (" +
+                    " SELECT 1 FROM hikvision_data " +
+                    " WHERE source_id = '" + personId + "'" +
+                    " );";
+            SqlRunnerAdapter.db().insert(insertsql);
+        }
+    }
+
 }

+ 4 - 3
src/test/java/com/xjrsoft/module/liteflow/node/ImportStudentFaceNodeTest.java

@@ -40,9 +40,10 @@ class ImportStudentFaceNodeTest {
     private FaceImportMapper faceImportMapper;
     @Test
     void test(){
-        String sql = "SELECT t1.* FROM xjr_user t1" +
-                " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
-                " WHERE t2.archives_status = 'FB2901' and t1.id = 654321987655958";
+        String sql = "SELECT t3.* FROM base_new_student t1" +
+                " INNER JOIN student_report_record t2 ON t1.id = t2.user_id" +
+                " INNER JOIN xjr_user t3 ON t1.credential_number = t3.credential_number" +
+                " WHERE t2.report_time IS NOT NULL;";
         List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
 
         ApiUtil apiUtil = new ApiUtil();

+ 10 - 0
src/test/java/com/xjrsoft/module/textbook/service/impl/TextbookIssueRecordServiceImplTest.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.textbook.service.impl;
 
+import com.xjrsoft.module.textbook.dto.CanReturnTextbookListDto;
 import com.xjrsoft.module.textbook.dto.TextbookClaimRecordExportDto;
 import com.xjrsoft.module.textbook.service.ITextbookIssueRecordService;
 import com.xjrsoft.module.textbook.service.ITextbookService;
@@ -21,4 +22,13 @@ class TextbookIssueRecordServiceImplTest {
     void claimRecordExportDataQuery() throws IOException {
         textbookIssueRecordService.claimRecordExportDataQuery(new TextbookClaimRecordExportDto());
     }
+
+    @Test
+    void canReturnTextbookList() {
+        textbookIssueRecordService.canReturnTextbookList(new CanReturnTextbookListDto(){{
+            setApplicantUserId("654321987654918");
+            setRecordType(0);
+            setBaseSemesterId("1868532124600545280");
+        }});
+    }
 }