|
@@ -1,22 +1,23 @@
|
|
package com.xjrsoft.module.textbook.service.impl;
|
|
package com.xjrsoft.module.textbook.service.impl;
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
|
+import com.xjrsoft.common.enums.ClaimTypeEnum;
|
|
|
|
+import com.xjrsoft.common.enums.IssueModeEnum;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
import com.xjrsoft.module.textbook.dto.ConfirmDistributeDto;
|
|
import com.xjrsoft.module.textbook.dto.ConfirmDistributeDto;
|
|
import com.xjrsoft.module.textbook.dto.WfTextbookClaimPageDto;
|
|
import com.xjrsoft.module.textbook.dto.WfTextbookClaimPageDto;
|
|
-import com.xjrsoft.module.textbook.entity.Textbook;
|
|
|
|
-import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
|
|
|
|
-import com.xjrsoft.module.textbook.entity.WfTextbookClaim;
|
|
|
|
-import com.xjrsoft.module.textbook.entity.WfTextbookClaimItem;
|
|
|
|
|
|
+import com.xjrsoft.module.textbook.entity.*;
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
|
|
+import com.xjrsoft.module.textbook.service.ITextbookIssueRecordService;
|
|
import com.xjrsoft.module.textbook.service.ITextbookService;
|
|
import com.xjrsoft.module.textbook.service.ITextbookService;
|
|
import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
import com.xjrsoft.module.textbook.service.IWfTextbookClaimService;
|
|
import com.xjrsoft.module.textbook.service.IWfTextbookClaimService;
|
|
@@ -51,6 +52,8 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
|
|
|
private final ITextbookStudentClaimService textbookStudentClaimService;
|
|
private final ITextbookStudentClaimService textbookStudentClaimService;
|
|
|
|
|
|
|
|
+ private final ITextbookIssueRecordService textbookIssueRecordService;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -203,29 +206,46 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
}
|
|
}
|
|
|
|
|
|
//判断总发放数量是否超出该申请项的申请数量
|
|
//判断总发放数量是否超出该申请项的申请数量
|
|
- Integer issueNumber = ObjectUtil.isNull(wfTextbookClaimItem.getIssueNumber())? 0 : wfTextbookClaimItem.getIssueNumber();
|
|
|
|
- if (issueNumber + textbookClaimItem.getConfirmNumber() > wfTextbookClaimItem.getApplicantNumber()) {
|
|
|
|
|
|
+ Integer issueNumber = ObjectUtil.isNull(wfTextbookClaimItem.getIssueNumber()) ? 0 : wfTextbookClaimItem.getIssueNumber();//已发放
|
|
|
|
+ Integer confirmNumber = ObjectUtil.isNull(textbookClaimItem.getConfirmNumber()) ? 0 : textbookClaimItem.getConfirmNumber();//本次发放
|
|
|
|
+ Integer applicantNumber = ObjectUtil.isNull(wfTextbookClaimItem.getApplicantNumber()) ? 0 : wfTextbookClaimItem.getApplicantNumber();//申领总数量
|
|
|
|
+ if (issueNumber + confirmNumber > applicantNumber) {
|
|
throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
|
|
throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
|
|
}
|
|
}
|
|
|
|
|
|
//判断总发放数量是否超出该申请像的申请数量
|
|
//判断总发放数量是否超出该申请像的申请数量
|
|
- Integer stock = ObjectUtil.isNull(textbook.getStock()) ? 0 : textbook.getStock() ;
|
|
|
|
- if (stock < textbookClaimItem.getConfirmNumber()) {
|
|
|
|
|
|
+ Integer stock = ObjectUtil.isNull(textbook.getStock()) ? 0 : textbook.getStock();
|
|
|
|
+ if (stock < confirmNumber) {
|
|
throw new MyException(textbook.getBookName() + "库存不足");
|
|
throw new MyException(textbook.getBookName() + "库存不足");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //增加出库记录
|
|
|
|
+ textbookIssueRecordService.save(new TextbookIssueRecord() {{
|
|
|
|
+ setWfTextbookClaimId(wfTextbookClaim.getId());
|
|
|
|
+ setWfTextbookClaimItemId(wfTextbookClaimItem.getId());
|
|
|
|
+ setIssueNumber(confirmNumber);
|
|
|
|
+ setRemainingNumber(applicantNumber - issueNumber - confirmNumber);
|
|
|
|
+ setReceiveUserId(dto.getReceiveUserId());
|
|
|
|
+ setIssueUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
+ if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ImStudent.getCode())) {
|
|
|
|
+ setIssueMode(IssueModeEnum.ClaimStudent.getCode());
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ImTeacher.getCode())) {
|
|
|
|
+ setIssueMode(IssueModeEnum.ClaimTeacher.getCode());
|
|
|
|
+ }
|
|
|
|
+ setRemark(dto.getRemark());
|
|
|
|
+ }});
|
|
|
|
+
|
|
//更新教材管理中的库存数量
|
|
//更新教材管理中的库存数量
|
|
- textbookService.updateById(new Textbook(){{
|
|
|
|
|
|
+ textbookService.updateById(new Textbook() {{
|
|
setId(textbook.getId());
|
|
setId(textbook.getId());
|
|
- setStock(stock - textbookClaimItem.getConfirmNumber());
|
|
|
|
|
|
+ setStock(stock - confirmNumber);
|
|
}});
|
|
}});
|
|
|
|
|
|
- //TODO 增加出库记录
|
|
|
|
-
|
|
|
|
//更新申领项中的已经发放数量
|
|
//更新申领项中的已经发放数量
|
|
- wfTextbookClaimWfTextbookClaimItemMapper.updateById(new WfTextbookClaimItem(){{
|
|
|
|
|
|
+ wfTextbookClaimWfTextbookClaimItemMapper.updateById(new WfTextbookClaimItem() {{
|
|
setId(wfTextbookClaimItem.getId());
|
|
setId(wfTextbookClaimItem.getId());
|
|
- setIssueNumber(issueNumber + textbookClaimItem.getConfirmNumber());
|
|
|
|
|
|
+ setIssueNumber(issueNumber + confirmNumber);
|
|
}});
|
|
}});
|
|
|
|
|
|
|
|
|
|
@@ -233,12 +253,12 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
//查出班上的所有学生id
|
|
//查出班上的所有学生id
|
|
List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
|
|
List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
|
|
|
|
|
|
- if(ObjectUtil.isNull(userIdList)){
|
|
|
|
|
|
+ if (ObjectUtil.isNull(userIdList) && userIdList.size() <= 0) {
|
|
throw new MyException("申领班级有误,请核实");
|
|
throw new MyException("申领班级有误,请核实");
|
|
}
|
|
}
|
|
|
|
|
|
for (Long userId : userIdList) {
|
|
for (Long userId : userIdList) {
|
|
- textbookStudentClaimService.save(new TextbookStudentClaim(){{
|
|
|
|
|
|
+ textbookStudentClaimService.save(new TextbookStudentClaim() {{
|
|
setStudentUserId(userId);
|
|
setStudentUserId(userId);
|
|
setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
|
|
setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
|
|
setClassId(wfTextbookClaim.getClassId());
|
|
setClassId(wfTextbookClaim.getClassId());
|