|
|
|
@ -1,16 +1,22 @@
|
|
|
|
|
package cn.iocoder.yudao.module.archives.service.borrowapply;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.string.StringUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.RecordUpdateReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
|
|
|
|
|
import cn.iocoder.yudao.module.archives.dal.dataobject.turnover.TurnOverDO;
|
|
|
|
|
import cn.iocoder.yudao.module.archives.service.record.RecordService;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.dal.dataobject.quotationsheet.QuotationSheetDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bs.enums.BillTypeEnum;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -26,6 +32,7 @@ import cn.iocoder.yudao.module.archives.convert.borrowapply.BorrowApplyConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.archives.dal.mysql.borrowapply.BorrowApplyMapper;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
|
|
|
|
|
import static com.baomidou.mybatisplus.extension.toolkit.Db.saveOrUpdate;
|
|
|
|
|
import static com.baomidou.mybatisplus.extension.toolkit.Db.updateById;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -66,16 +73,26 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
|
|
|
|
|
if (StringUtils.isNotNull(borrowApplyDOPageResult)){
|
|
|
|
|
List<BorrowApplyDO> list = borrowApplyDOPageResult.getList();
|
|
|
|
|
for (BorrowApplyDO b:list) {
|
|
|
|
|
if (b.getBorrowState().equals("0")){
|
|
|
|
|
return CommonResult.error("档案已被借阅");
|
|
|
|
|
//通过案卷号判断是否被借阅
|
|
|
|
|
if (StringUtils.isNotNull(b.getFilesNum())) {
|
|
|
|
|
if (b.getFilesNum().equals(createReqVO.getFilesNum()) && b.getFilesNum().equals("0")) {
|
|
|
|
|
return CommonResult.error("档案已被借阅");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//这里设置工作流属性
|
|
|
|
|
|
|
|
|
|
borrowApply.setBillType("BORROW");
|
|
|
|
|
borrowApplyMapper.insert(borrowApply);
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
variables.put("billId", borrowApply.getId());
|
|
|
|
|
//这个if判断这个申请单是暂存还是提交 因为暂存和提交都是会调这个接口 所以会重复新增条数
|
|
|
|
|
if (StringUtils.isNull(borrowApply.getProcessInstanceId())){
|
|
|
|
|
borrowApply.setBillType("BORROW");
|
|
|
|
|
borrowApplyMapper.insert(borrowApply);
|
|
|
|
|
variables.put("billId", borrowApply.getId());
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isNull(variables.get("billId"))){
|
|
|
|
|
variables.put("billId", this.borrowApplyMapper.selectOne(BorrowApplyDO::getProcessInstanceId, borrowApply.getProcessInstanceId()).getId());
|
|
|
|
|
}
|
|
|
|
|
variables.put("userName", createReqVO.getUserName());
|
|
|
|
|
variables.put("deptName", createReqVO.getDeptName());
|
|
|
|
|
variables.put("billName", "档案借阅申请单");
|
|
|
|
@ -84,7 +101,8 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
|
|
|
|
|
String processInstanceId = processInstanceApi.createProcessInstance(loginUser.getId(),
|
|
|
|
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
|
|
|
|
.setVariables(variables).setBusinessKey(String.valueOf(borrowApply.getId())));
|
|
|
|
|
this.borrowApplyMapper.updateById(new BorrowApplyDO().setId(borrowApply.getId()).setProcessInstanceId(processInstanceId));
|
|
|
|
|
int i = this.borrowApplyMapper.updateById(new BorrowApplyDO().setId(borrowApply.getId()).setProcessInstanceId(processInstanceId).setStatus(createReqVO.getStatus()));
|
|
|
|
|
|
|
|
|
|
// 返回
|
|
|
|
|
return CommonResult.success(borrowApply);
|
|
|
|
|
}
|
|
|
|
@ -148,6 +166,7 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
|
|
|
|
|
@Override
|
|
|
|
|
public BorrowApplyDO getBorrowApply(Long id) {
|
|
|
|
|
BorrowApplyDO borrowApplyDO = borrowApplyMapper.selectById(id);
|
|
|
|
|
borrowApplyDO.setIsAuthorised(borrowApplyDO.getStatus()==1 ? true : false);
|
|
|
|
|
RecordDO record = recordService.getRecord(borrowApplyDO.getRecordId());
|
|
|
|
|
return borrowApplyDO.setSite(record.getSite()).setFileType(record.getFileType()).setFilesNum(record.getFilesNum());
|
|
|
|
|
}
|
|
|
|
|