|
@@ -5,14 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
|
+import com.xjrsoft.module.textbook.dto.ConfirmDistributeDto;
|
|
|
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.mapper.WfTextbookClaimItemMapper;
|
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
|
+import com.xjrsoft.module.textbook.service.ITextbookService;
|
|
|
+import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
|
import com.xjrsoft.module.textbook.service.IWfTextbookClaimService;
|
|
|
import com.xjrsoft.module.textbook.vo.WfTextbookClaimItemVo;
|
|
|
import com.xjrsoft.module.textbook.vo.WfTextbookClaimPageVo;
|
|
@@ -27,11 +33,11 @@ import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
-* @title: 教材申领
|
|
|
-* @Author szs
|
|
|
-* @Date: 2023-12-26
|
|
|
-* @Version 1.0
|
|
|
-*/
|
|
|
+ * @title: 教材申领
|
|
|
+ * @Author szs
|
|
|
+ * @Date: 2023-12-26
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookClaimMapper, WfTextbookClaim> implements IWfTextbookClaimService {
|
|
@@ -41,6 +47,10 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
|
|
|
private final XjrUserMapper xjrUserMapper;
|
|
|
|
|
|
+ private final ITextbookService textbookService;
|
|
|
+
|
|
|
+ private final ITextbookStudentClaimService textbookStudentClaimService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -81,7 +91,7 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
}
|
|
|
}
|
|
|
//已经不存在的id 删除
|
|
|
- if(wfTextbookClaimItemRemoveIds.size() > 0){
|
|
|
+ if (wfTextbookClaimItemRemoveIds.size() > 0) {
|
|
|
wfTextbookClaimWfTextbookClaimItemMapper.deleteBatchIds(wfTextbookClaimItemRemoveIds);
|
|
|
}
|
|
|
}
|
|
@@ -101,12 +111,12 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
|
|
|
@Override
|
|
|
public IPage<WfTextbookClaimPageVo> getPage(WfTextbookClaimPageDto dto) {
|
|
|
- IPage<WfTextbookClaimPageVo> page = wfTextbookClaimWfTextbookClaimMapper.getPage(ConventPage.getPage(dto),dto);
|
|
|
+ IPage<WfTextbookClaimPageVo> page = wfTextbookClaimWfTextbookClaimMapper.getPage(ConventPage.getPage(dto), dto);
|
|
|
|
|
|
for (WfTextbookClaimPageVo wfTextbookClaimPageVo : page.getRecords()) {
|
|
|
//拆分代领人
|
|
|
String receiveUserIdStr = wfTextbookClaimPageVo.getReceiveUserId();
|
|
|
- if(ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")){
|
|
|
+ if (ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")) {
|
|
|
String[] receiveUserIdStrs = receiveUserIdStr.split(",");
|
|
|
List<Long> receiveUserIdList = new ArrayList<>();
|
|
|
for (String str : receiveUserIdStrs) {
|
|
@@ -114,12 +124,12 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
}
|
|
|
LambdaQueryWrapper<XjrUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper
|
|
|
- .in(XjrUser::getId,receiveUserIdStr);
|
|
|
+ .in(XjrUser::getId, receiveUserIdStr);
|
|
|
List<XjrUser> xjrUserList = xjrUserMapper.selectList(queryWrapper);
|
|
|
- if (ObjectUtil.isNotNull(xjrUserList) && xjrUserList.size() > 0){
|
|
|
+ if (ObjectUtil.isNotNull(xjrUserList) && xjrUserList.size() > 0) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (XjrUser xjrUser : xjrUserList) {
|
|
|
- sb.append(","+xjrUser.getName());
|
|
|
+ sb.append("," + xjrUser.getName());
|
|
|
}
|
|
|
wfTextbookClaimPageVo.setReceiveUserIdCN(sb.toString());
|
|
|
}
|
|
@@ -127,7 +137,7 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
//加上申领项
|
|
|
List<WfTextbookClaimItemVo> wfTextbookClaimItemVoList = wfTextbookClaimWfTextbookClaimItemMapper.getListByWfTextbookClaimId(Long.parseLong(wfTextbookClaimPageVo.getId()));
|
|
|
|
|
|
- if(ObjectUtil.isNotNull(wfTextbookClaimItemVoList) && wfTextbookClaimItemVoList.size() > 0){
|
|
|
+ if (ObjectUtil.isNotNull(wfTextbookClaimItemVoList) && wfTextbookClaimItemVoList.size() > 0) {
|
|
|
wfTextbookClaimPageVo.setWfTextbookClaimItemList(wfTextbookClaimItemVoList);
|
|
|
}
|
|
|
}
|
|
@@ -137,10 +147,10 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
@Override
|
|
|
public WfTextbookClaimVo infoDistribute(Long id) {
|
|
|
WfTextbookClaimVo wfTextbookClaimVo = wfTextbookClaimWfTextbookClaimMapper.infoDistribute(id);
|
|
|
- if(ObjectUtil.isNotNull(wfTextbookClaimVo)){
|
|
|
+ if (ObjectUtil.isNotNull(wfTextbookClaimVo)) {
|
|
|
//拆分代领人
|
|
|
String receiveUserIdStr = wfTextbookClaimVo.getReceiveUserId();
|
|
|
- if(ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")){
|
|
|
+ if (ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")) {
|
|
|
String[] receiveUserIdStrs = receiveUserIdStr.split(",");
|
|
|
List<Long> receiveUserIdList = new ArrayList<>();
|
|
|
for (String str : receiveUserIdStrs) {
|
|
@@ -148,12 +158,12 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
}
|
|
|
LambdaQueryWrapper<XjrUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper
|
|
|
- .in(XjrUser::getId,receiveUserIdList);
|
|
|
+ .in(XjrUser::getId, receiveUserIdList);
|
|
|
List<XjrUser> xjrUserList = xjrUserMapper.selectList(queryWrapper);
|
|
|
- if (ObjectUtil.isNotNull(xjrUserList) && xjrUserList.size() > 0){
|
|
|
+ if (ObjectUtil.isNotNull(xjrUserList) && xjrUserList.size() > 0) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (XjrUser xjrUser : xjrUserList) {
|
|
|
- sb.append(","+xjrUser.getName());
|
|
|
+ sb.append("," + xjrUser.getName());
|
|
|
}
|
|
|
wfTextbookClaimVo.setReceiveUserIdCN(sb.toString());
|
|
|
}
|
|
@@ -161,10 +171,83 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
//加上申领项
|
|
|
List<WfTextbookClaimItemVo> wfTextbookClaimItemVoList = wfTextbookClaimWfTextbookClaimItemMapper.getListByWfTextbookClaimId(Long.parseLong(wfTextbookClaimVo.getId()));
|
|
|
|
|
|
- if(ObjectUtil.isNotNull(wfTextbookClaimItemVoList) && wfTextbookClaimItemVoList.size() > 0){
|
|
|
+ if (ObjectUtil.isNotNull(wfTextbookClaimItemVoList) && wfTextbookClaimItemVoList.size() > 0) {
|
|
|
wfTextbookClaimVo.setWfTextbookClaimItemList(wfTextbookClaimItemVoList);
|
|
|
}
|
|
|
}
|
|
|
return wfTextbookClaimVo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean confirmDistribute(ConfirmDistributeDto dto) {
|
|
|
+ WfTextbookClaim wfTextbookClaim = this.getById(dto.getTextbookClaimId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(wfTextbookClaim) || ObjectUtil.isNull(dto.getTextbookClaimItemList()) || dto.getTextbookClaimItemList().size() <= 0) {
|
|
|
+ throw new MyException("未找到申领数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ //操作每一个申领项
|
|
|
+ for (ConfirmDistributeDto.TextbookClaimItem textbookClaimItem : dto.getTextbookClaimItemList()) {
|
|
|
+
|
|
|
+ WfTextbookClaimItem wfTextbookClaimItem = wfTextbookClaimWfTextbookClaimItemMapper.selectById(textbookClaimItem.getTextbookClaimItemId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(wfTextbookClaimItem)) {
|
|
|
+ throw new MyException("未找到申领数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ Textbook textbook = textbookService.getById(wfTextbookClaimItem.getTextbookId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(textbook)) {
|
|
|
+ throw new MyException("未找到相关教材数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断总发放数量是否超出该申请项的申请数量
|
|
|
+ if (wfTextbookClaimItem.getIssueNumber() + textbookClaimItem.getConfirmNumber() > wfTextbookClaimItem.getApplicantNumber()) {
|
|
|
+ throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断总发放数量是否超出该申请像的申请数量
|
|
|
+ Integer stock = textbook.getStock();
|
|
|
+ if (stock < textbookClaimItem.getConfirmNumber()) {
|
|
|
+ throw new MyException(textbook.getBookName() + "库存不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新教材管理中的库存数量
|
|
|
+ Textbook newTextbook = new Textbook();
|
|
|
+ newTextbook.setId(textbook.getId());
|
|
|
+ newTextbook.setStock(stock - textbookClaimItem.getConfirmNumber());
|
|
|
+ textbookService.updateById(newTextbook);
|
|
|
+
|
|
|
+ //TODO 增加出库记录
|
|
|
+
|
|
|
+ //更新申领项中的已经发放数量
|
|
|
+ WfTextbookClaimItem newWfTextbookClaimItem = new WfTextbookClaimItem();
|
|
|
+ newWfTextbookClaimItem.setId(wfTextbookClaimItem.getId());
|
|
|
+ newWfTextbookClaimItem.setIssueNumber(wfTextbookClaimItem.getIssueNumber() + textbookClaimItem.getConfirmNumber());
|
|
|
+ wfTextbookClaimWfTextbookClaimItemMapper.updateById(newWfTextbookClaimItem);
|
|
|
+
|
|
|
+ //为班级每个学生生成领取(确认信息)认领记录
|
|
|
+ //查出班上的所有学生id
|
|
|
+ List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(userIdList)){
|
|
|
+ throw new MyException("申领班级有误,请核实");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TextbookStudentClaim> textbookStudentClaimsList = new ArrayList<>();
|
|
|
+ for (Long userId : userIdList) {
|
|
|
+ TextbookStudentClaim textbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ textbookStudentClaim.setStudentUserId(userId);
|
|
|
+ textbookStudentClaim.setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
|
|
|
+ textbookStudentClaim.setClassId(wfTextbookClaim.getClassId());
|
|
|
+ textbookStudentClaim.setTextbookId(wfTextbookClaimItem.getTextbookId());
|
|
|
+
|
|
|
+ textbookStudentClaimsList.add(textbookStudentClaim);
|
|
|
+ }
|
|
|
+ textbookStudentClaimService.saveBatch(textbookStudentClaimsList);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|