|
@@ -10,12 +10,18 @@ import com.qmth.paper.library.business.entity.PaperScanTaskDetail;
|
|
import com.qmth.paper.library.business.mapper.PaperLibraryMapper;
|
|
import com.qmth.paper.library.business.mapper.PaperLibraryMapper;
|
|
import com.qmth.paper.library.business.service.PaperLibraryService;
|
|
import com.qmth.paper.library.business.service.PaperLibraryService;
|
|
import com.qmth.paper.library.business.service.PaperScanTaskDetailService;
|
|
import com.qmth.paper.library.business.service.PaperScanTaskDetailService;
|
|
|
|
+import com.qmth.paper.library.common.contant.SystemConstant;
|
|
import com.qmth.paper.library.common.entity.SysUser;
|
|
import com.qmth.paper.library.common.entity.SysUser;
|
|
import com.qmth.paper.library.common.enums.ExceptionResultEnum;
|
|
import com.qmth.paper.library.common.enums.ExceptionResultEnum;
|
|
|
|
+import com.qmth.paper.library.common.lock.LockService;
|
|
|
|
+import com.qmth.paper.library.common.lock.LockType;
|
|
import com.qmth.paper.library.common.util.ServletUtil;
|
|
import com.qmth.paper.library.common.util.ServletUtil;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -28,6 +34,9 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
|
|
@Resource
|
|
@Resource
|
|
PaperScanTaskDetailService paperScanTaskDetailService;
|
|
PaperScanTaskDetailService paperScanTaskDetailService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ LockService lockService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public IPage<PaperLibraryResult> pageUnbindData(Long paperScanTaskId, Integer pageNumber, Integer pageSize) {
|
|
public IPage<PaperLibraryResult> pageUnbindData(Long paperScanTaskId, Integer pageNumber, Integer pageSize) {
|
|
return this.baseMapper.pageUnbindData(new Page<>(pageNumber, pageSize), paperScanTaskId);
|
|
return this.baseMapper.pageUnbindData(new Page<>(pageNumber, pageSize), paperScanTaskId);
|
|
@@ -50,8 +59,6 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean bind(Long paperLibraryId, Long paperScanTaskDetailId) {
|
|
public boolean bind(Long paperLibraryId, Long paperScanTaskDetailId) {
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
-
|
|
|
|
PaperScanTaskDetail paperScanTaskDetail = paperScanTaskDetailService.getById(paperScanTaskDetailId);
|
|
PaperScanTaskDetail paperScanTaskDetail = paperScanTaskDetailService.getById(paperScanTaskDetailId);
|
|
if (paperScanTaskDetail == null) {
|
|
if (paperScanTaskDetail == null) {
|
|
throw ExceptionResultEnum.ERROR.exception("绑定对象有误,任务下无该考生,请刷新数据再试");
|
|
throw ExceptionResultEnum.ERROR.exception("绑定对象有误,任务下无该考生,请刷新数据再试");
|
|
@@ -62,4 +69,44 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
|
|
return this.update(updateWrapper);
|
|
return this.update(updateWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<PaperLibraryResult> toBindPaper() {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ Long schoolId = SystemConstant.convertIdToLong(String.valueOf(ServletUtil.getRequestHeaderSchoolId()));
|
|
|
|
+
|
|
|
|
+ // 查询下一个待绑定任务
|
|
|
|
+ List<PaperLibrary> waitPaperLibraryList = this.baseMapper.selectBatchData(schoolId, sysUser.getId());
|
|
|
|
+ if (waitPaperLibraryList.isEmpty()) {
|
|
|
|
+ waitPaperLibraryList = createBindData(sysUser.getId(), schoolId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<PaperLibraryResult> paperLibraryResultList = new ArrayList<>();
|
|
|
|
+ if (!waitPaperLibraryList.isEmpty()) {
|
|
|
|
+ for (PaperLibrary paperLibrary : waitPaperLibraryList) {
|
|
|
|
+ PaperLibraryResult paperLibraryResult = new PaperLibraryResult();
|
|
|
|
+ BeanUtils.copyProperties(paperLibrary, paperLibraryResult);
|
|
|
|
+ // todo 图片地址
|
|
|
|
+ paperLibraryResult.setFileUrl("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return paperLibraryResultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<PaperLibrary> createBindData(Long userId, Long schoolId) {
|
|
|
|
+ try {
|
|
|
|
+ lockService.waitlock(LockType.BIND_PAPER_TASK, schoolId);
|
|
|
|
+ List<PaperLibrary> paperLibraryList = this.baseMapper.listUnBindData(schoolId);
|
|
|
|
+ if (!paperLibraryList.isEmpty()) {
|
|
|
|
+ paperLibraryList.forEach(m -> m.setUserId(userId));
|
|
|
|
+ this.updateBatchById(paperLibraryList);
|
|
|
|
+ }
|
|
|
|
+ return paperLibraryList;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ lockService.unlock(LockType.BIND_PAPER_TASK, schoolId);
|
|
|
|
+ }
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|