feat(oa): 添加日记账批量更新接口并优化流程实例启动逻辑
- 在 IOaJournalAccountService 中添加 batchUpdate 方法 - 在 OaJournalAccountBo 中添加 journalIds 字段用于批量更新 - 实现 OaJournalAccountController 中的 batchUpdate 接口 - 在 OaJournalAccountServiceImpl 中实现 batchUpdate 方法,用于批量更新日记账的 batchId - 优化 WfProcessServiceImpl 中的 startProcess
This commit is contained in:
@@ -37,7 +37,12 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
public class OaJournalAccountController extends BaseController {
|
||||
|
||||
private final IOaJournalAccountService iOaJournalAccountService;
|
||||
|
||||
//需要一个接口用来批量修改batch_id字段,传入一个batch_id和多个journal_ids
|
||||
@Log(title = "日记账(绑定封账批次,未封账数据batch_id为NULL)", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/batchUpdate")
|
||||
public R<Void> batchUpdate(@RequestBody OaJournalAccountBo bo) {
|
||||
return toAjax(iOaJournalAccountService.batchUpdate(bo));
|
||||
}
|
||||
/**
|
||||
* 查询日记账(绑定封账批次,未封账数据batch_id为NULL)列表
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.Date;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
@@ -73,6 +75,8 @@ public class OaJournalAccountBo extends BaseEntity {
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
//需要批量修改batchId的日记账记录ID
|
||||
private List<Long> journalIds;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -46,4 +46,6 @@ public interface IOaJournalAccountService {
|
||||
* 校验并批量删除日记账(绑定封账批次,未封账数据batch_id为NULL)信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
int batchUpdate(OaJournalAccountBo bo);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.ruoyi.oa.domain.vo.OaJournalAccountVo;
|
||||
import com.ruoyi.oa.domain.OaJournalAccount;
|
||||
import com.ruoyi.oa.mapper.OaJournalAccountMapper;
|
||||
import com.ruoyi.oa.service.IOaJournalAccountService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -131,4 +132,38 @@ public class OaJournalAccountServiceImpl implements IOaJournalAccountService {
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int batchUpdate(OaJournalAccountBo bo) {
|
||||
// 参数校验
|
||||
if (bo.getJournalIds() == null || bo.getJournalIds().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bo.getBatchId() == null) {
|
||||
throw new ServiceException("批次ID不能为空");
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
// 循环遍历list数组然后修改batchId
|
||||
for (Long journalId : bo.getJournalIds()) {
|
||||
// 检查记录是否存在且未封账
|
||||
OaJournalAccount existing = baseMapper.selectById(journalId);
|
||||
if (existing == null) {
|
||||
throw new ServiceException("记录不存在,ID: " + journalId);
|
||||
}
|
||||
|
||||
if (existing.getBatchId() != null) {
|
||||
throw new ServiceException("记录已封账,不能重复封账,ID: " + journalId);
|
||||
}
|
||||
|
||||
OaJournalAccount oaJournalAccount = new OaJournalAccount();
|
||||
oaJournalAccount.setJournalId(journalId);
|
||||
oaJournalAccount.setBatchId(bo.getBatchId());
|
||||
count += baseMapper.updateById(oaJournalAccount);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user