|
|
@@ -11,20 +11,14 @@ import com.xjrsoft.common.enums.ClaimTypeEnum;
|
|
|
import com.xjrsoft.common.enums.IssueModeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.utils.SortCodeUtil;
|
|
|
import com.xjrsoft.module.organization.mapper.RoleMapper;
|
|
|
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.TextbookClaimUser;
|
|
|
-import com.xjrsoft.module.textbook.entity.TextbookIssueRecord;
|
|
|
-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.TextbookClaimUserMapper;
|
|
|
-import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
|
|
|
-import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
|
+import com.xjrsoft.module.textbook.entity.*;
|
|
|
+import com.xjrsoft.module.textbook.mapper.*;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookIssueRecordService;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookService;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
|
@@ -33,8 +27,10 @@ import com.xjrsoft.module.textbook.vo.WfTextbookClaimItemVo;
|
|
|
import com.xjrsoft.module.textbook.vo.WfTextbookClaimPageVo;
|
|
|
import com.xjrsoft.module.textbook.vo.WfTextbookClaimVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.glassfish.jersey.server.internal.process.MappableException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -57,16 +53,18 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
|
|
|
private final XjrUserMapper xjrUserMapper;
|
|
|
|
|
|
- private final RoleMapper roleMapper;
|
|
|
+ private final TextbookMapper textbookMapper;
|
|
|
|
|
|
- private final ITextbookService textbookService;
|
|
|
+ private final TextbookStudentClaimMapper textbookStudentClaimMapper;
|
|
|
|
|
|
- private final ITextbookStudentClaimService textbookStudentClaimService;
|
|
|
+ private final TextbookSubscriptionItemMapper textbookSubscriptionItemMapper;
|
|
|
|
|
|
- private final ITextbookIssueRecordService textbookIssueRecordService;
|
|
|
+ private final TextbookIssueRecordMapper textbookIssueRecordMapper;
|
|
|
|
|
|
private final TextbookClaimUserMapper textbookClaimUserMapper;
|
|
|
|
|
|
+ private final ClaimItemSubscriptionItemMapper claimItemSubscriptionItemMapper;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean add(WfTextbookClaim wfTextbookClaim) {
|
|
|
@@ -213,54 +211,71 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
WfTextbookClaimItem wfTextbookClaimItem = wfTextbookClaimWfTextbookClaimItemMapper.selectById(textbookClaimItem.getTextbookClaimItemId());
|
|
|
|
|
|
if (ObjectUtil.isNull(wfTextbookClaimItem)) {
|
|
|
- throw new MyException("未找到申领数据");
|
|
|
+ throw new MyException("未找到申领项详细数据");
|
|
|
}
|
|
|
|
|
|
- Textbook textbook = textbookService.getById(wfTextbookClaimItem.getTextbookId());
|
|
|
-
|
|
|
+ Textbook textbook = textbookMapper.selectById(textbookClaimItem.getTextbookId());
|
|
|
if (ObjectUtil.isNull(textbook)) {
|
|
|
throw new MyException("未找到相关教材数据");
|
|
|
}
|
|
|
|
|
|
//判断总发放数量是否超出该申请项的申请数量
|
|
|
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();//申领总数量
|
|
|
+ Integer confirmNumber = ObjectUtil.isNull(textbookClaimItem.getConfirmTotalNumber()) ? 0 : textbookClaimItem.getConfirmTotalNumber();//本次发放
|
|
|
if (issueNumber + confirmNumber > applicantNumber) {
|
|
|
throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
|
|
|
}
|
|
|
|
|
|
- //判断发放量是否多于库存量
|
|
|
+ for (ConfirmDistributeDto.TextbookSubscriptionItems textbookSubscriptionItems : textbookClaimItem.getTextbookSubscriptionItems()){
|
|
|
+ TextbookSubscriptionItem textbookSubscriptionItem = textbookSubscriptionItemMapper.selectById(textbookSubscriptionItems.getTextbookSubscriptionItemId());
|
|
|
+ if (ObjectUtils.isEmpty(textbookSubscriptionItem)) {
|
|
|
+ throw new MyException("未找到征订项详细数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新教材征订中的的库存数量
|
|
|
+ textbookSubscriptionItemMapper.updateById(new TextbookSubscriptionItem() {{
|
|
|
+ setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ setModifyDate(new Date());
|
|
|
+ setId(textbookSubscriptionItem.getId());
|
|
|
+ setOutStockNum(ObjectUtil.isNull(textbookSubscriptionItem.getOutStockNum()) ? 0 : textbookSubscriptionItem.getOutStockNum()
|
|
|
+ + confirmNumber);
|
|
|
+ }});
|
|
|
+
|
|
|
+ claimItemSubscriptionItemMapper.insert(new ClaimItemSubscriptionItem(){{
|
|
|
+ setWfTextbookClaimItemId(wfTextbookClaimItem.getId());
|
|
|
+ setTextbookSubscriptionItemId(textbookSubscriptionItem.getId());
|
|
|
+ setIssueNumber(confirmNumber);
|
|
|
+ }});
|
|
|
+ }
|
|
|
|
|
|
//增加出库记录
|
|
|
- textbookIssueRecordService.save(new TextbookIssueRecord() {{
|
|
|
+ textbookIssueRecordMapper.insert(new TextbookIssueRecord() {{
|
|
|
setCreateDate(new Date());
|
|
|
- setTextbookId(wfTextbookClaimItem.getTextbookId());
|
|
|
- setDataId(wfTextbookClaim.getId());
|
|
|
- setDataItemId(wfTextbookClaimItem.getId());
|
|
|
- setIssueNumber(confirmNumber);
|
|
|
- setRemainingNumber(applicantNumber - issueNumber - confirmNumber);
|
|
|
- setReceiveUserId(dto.getReceiveUserId());
|
|
|
- setIssueUserId(StpUtil.getLoginIdAsLong());
|
|
|
if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
|
|
|
setIssueMode(IssueModeEnum.Imtudent.getCode());
|
|
|
}
|
|
|
if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimTeacher.getCode())) {
|
|
|
setIssueMode(IssueModeEnum.ImTeacher.getCode());
|
|
|
}
|
|
|
+
|
|
|
+ setDataId(wfTextbookClaim.getId());
|
|
|
+ setDataItemId(wfTextbookClaimItem.getId());
|
|
|
+
|
|
|
+ setTextbookId(wfTextbookClaimItem.getTextbookId());
|
|
|
+ setIssueNumber(confirmNumber);
|
|
|
+
|
|
|
+ setRemainingNumber(applicantNumber - issueNumber - confirmNumber);
|
|
|
+
|
|
|
+ setReceiveUserId(dto.getReceiveUserId());
|
|
|
+ setIssueUserId(StpUtil.getLoginIdAsLong());
|
|
|
+
|
|
|
setRemark(dto.getRemark());
|
|
|
- QueryWrapper<TextbookIssueRecord> queryWrapperSortcode = new QueryWrapper<>();
|
|
|
- queryWrapperSortcode.select("IFNULL(MAX(sort_code),0) as sortCode");
|
|
|
- TextbookIssueRecord t = textbookIssueRecordService.getOne(queryWrapperSortcode);
|
|
|
- setSortCode(t.getSortCode()+1);
|
|
|
|
|
|
- }});
|
|
|
+ int sortCode = SortCodeUtil.getMaxSortCode(textbookIssueRecordMapper, TextbookIssueRecord.class, "sort_code");
|
|
|
+
|
|
|
+ setSortCode(sortCode + 1);
|
|
|
|
|
|
- //更新教材管理中的库存数量
|
|
|
- textbookService.updateById(new Textbook() {{
|
|
|
- setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
- setModifyDate(new Date());
|
|
|
- setId(textbook.getId());
|
|
|
}});
|
|
|
|
|
|
//更新申领项中的已经发放数量
|
|
|
@@ -271,35 +286,34 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
|
|
|
setIssueNumber(issueNumber + confirmNumber);
|
|
|
}});
|
|
|
|
|
|
-
|
|
|
- //当申领类型为学生的时候,为班级每个学生生成领取(确认信息)认领记录
|
|
|
- if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
|
|
|
- //查出班上的所有学生id
|
|
|
- List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
|
|
|
-
|
|
|
- if (ObjectUtil.isNull(userIdList) && userIdList.size() == 0) {
|
|
|
- throw new MyException("申领班级有误,请核实");
|
|
|
- }
|
|
|
- //验证当前领取教材是否已经生成领取记录
|
|
|
- LambdaQueryWrapper<TextbookStudentClaim> queryWrapperRecord = new LambdaQueryWrapper<>();
|
|
|
- queryWrapperRecord
|
|
|
- .eq(TextbookStudentClaim::getTextbookId, wfTextbookClaimItem.getTextbookId())
|
|
|
- .eq(TextbookStudentClaim::getClassId, wfTextbookClaim.getClassId());
|
|
|
- Long count = textbookStudentClaimService.count(queryWrapperRecord);
|
|
|
- //为0的时候表示该班级该书没有生成领取记录
|
|
|
- if(count <= 0){
|
|
|
- for (Long userId : userIdList) {
|
|
|
- textbookStudentClaimService.save(new TextbookStudentClaim() {{
|
|
|
- setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- setCreateDate(new Date());
|
|
|
- setStudentUserId(userId);
|
|
|
- setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
|
|
|
- setClassId(wfTextbookClaim.getClassId());
|
|
|
- setTextbookId(wfTextbookClaimItem.getTextbookId());
|
|
|
- }});
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // 当申领类型为学生的时候,为班级每个学生生成领取(确认信息)认领记录
|
|
|
+// if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
|
|
|
+// //查出班上的所有学生id
|
|
|
+// List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
|
|
|
+//
|
|
|
+// if (ObjectUtil.isNull(userIdList) && userIdList.size() == 0) {
|
|
|
+// throw new MyException("申领班级有误,请核实");
|
|
|
+// }
|
|
|
+// //验证当前领取教材是否已经生成领取记录
|
|
|
+// LambdaQueryWrapper<TextbookStudentClaim> queryWrapperRecord = new LambdaQueryWrapper<>();
|
|
|
+// queryWrapperRecord
|
|
|
+// .eq(TextbookStudentClaim::getTextbookId, wfTextbookClaimItem.getTextbookId())
|
|
|
+// .eq(TextbookStudentClaim::getClassId, wfTextbookClaim.getClassId());
|
|
|
+// Long count = textbookStudentClaimMapper.selectCount(queryWrapperRecord);
|
|
|
+// //为0的时候表示该班级该书没有生成领取记录
|
|
|
+// if(count <= 0){
|
|
|
+// for (Long userId : userIdList) {
|
|
|
+// textbookStudentClaimMapper.insert(new TextbookStudentClaim() {{
|
|
|
+// setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+// setCreateDate(new Date());
|
|
|
+// setStudentUserId(userId);
|
|
|
+// setBaseSemesterId(wfTextbookClaim.getBaseSemesterId());
|
|
|
+// setClassId(wfTextbookClaim.getClassId());
|
|
|
+// setTextbookId(wfTextbookClaimItem.getTextbookId());
|
|
|
+// }});
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return true;
|
|
|
}
|