电子请购单优化 库存明细页面
This commit is contained in:
@@ -10,6 +10,7 @@ import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.klp.erp.domain.bo.ErpPurchaseRequisitionBo;
|
||||
import com.klp.erp.domain.vo.ErpPurchaseRequisitionVo;
|
||||
import com.klp.erp.service.IErpPurchaseRequisitionService;
|
||||
@@ -79,4 +80,28 @@ public class ErpPurchaseRequisitionController extends BaseController {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] reqIds) {
|
||||
return toAjax(iErpPurchaseRequisitionService.deleteWithValidByIds(Arrays.asList(reqIds), true));
|
||||
}
|
||||
|
||||
/** 提交审批(草稿 → 审批中) */
|
||||
@Log(title = "请购及采购单", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("erp:purchaseRequisition:approve")
|
||||
@PutMapping("/{reqId}/submit")
|
||||
public R<Void> submitApproval(@NotNull(message = "主键不能为空") @PathVariable Long reqId) {
|
||||
return toAjax(iErpPurchaseRequisitionService.submitApproval(reqId));
|
||||
}
|
||||
|
||||
/** 审批通过(审批中 → 已通过) */
|
||||
@Log(title = "请购及采购单", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("erp:purchaseRequisition:approve")
|
||||
@PutMapping("/{reqId}/approve")
|
||||
public R<Void> approve(@NotNull(message = "主键不能为空") @PathVariable Long reqId) {
|
||||
return toAjax(iErpPurchaseRequisitionService.approve(reqId));
|
||||
}
|
||||
|
||||
/** 驳回(审批中 → 已驳回) */
|
||||
@Log(title = "请购及采购单", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("erp:purchaseRequisition:approve")
|
||||
@PutMapping("/{reqId}/reject")
|
||||
public R<Void> reject(@NotNull(message = "主键不能为空") @PathVariable Long reqId) {
|
||||
return toAjax(iErpPurchaseRequisitionService.reject(reqId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,13 @@ public interface IErpPurchaseRequisitionService {
|
||||
|
||||
/** 校验并批量删除请购单 */
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/** 提交审批(草稿 → 审批中) */
|
||||
Boolean submitApproval(Long reqId);
|
||||
|
||||
/** 审批通过(审批中 → 已通过) */
|
||||
Boolean approve(Long reqId);
|
||||
|
||||
/** 驳回(审批中 → 已驳回) */
|
||||
Boolean reject(Long reqId);
|
||||
}
|
||||
|
||||
@@ -83,22 +83,6 @@ public class ErpPurchaseRequisitionServiceImpl implements IErpPurchaseRequisitio
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(ErpPurchaseRequisitionBo bo) {
|
||||
ErpPurchaseRequisition update = baseMapper.selectById(bo.getReqId());
|
||||
if (update == null) {
|
||||
return false;
|
||||
}
|
||||
BeanUtil.copyProperties(bo, update, "reqId", "createBy", "createTime");
|
||||
baseMapper.updateById(update);
|
||||
// 覆盖式重写明细
|
||||
itemMapper.delete(Wrappers.lambdaQuery(ErpPurchaseRequisitionItem.class)
|
||||
.eq(ErpPurchaseRequisitionItem::getReqId, bo.getReqId()));
|
||||
saveItems(bo.getReqId(), bo.getItems());
|
||||
return true;
|
||||
}
|
||||
|
||||
private void saveItems(Long reqId, List<ErpPurchaseRequisitionItemBo> items) {
|
||||
if (items == null || items.isEmpty()) {
|
||||
return;
|
||||
@@ -120,10 +104,69 @@ public class ErpPurchaseRequisitionServiceImpl implements IErpPurchaseRequisitio
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
for (Long reqId : ids) {
|
||||
ErpPurchaseRequisition entity = baseMapper.selectById(reqId);
|
||||
if (entity != null && !"0".equals(entity.getFormStatus())) {
|
||||
throw new RuntimeException("仅草稿状态的请购单可删除");
|
||||
}
|
||||
itemMapper.delete(Wrappers.lambdaQuery(ErpPurchaseRequisitionItem.class)
|
||||
.eq(ErpPurchaseRequisitionItem::getReqId, reqId));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(ErpPurchaseRequisitionBo bo) {
|
||||
ErpPurchaseRequisition update = baseMapper.selectById(bo.getReqId());
|
||||
if (update == null) {
|
||||
return false;
|
||||
}
|
||||
if (!"0".equals(update.getFormStatus())) {
|
||||
throw new RuntimeException("仅草稿状态的请购单可修改");
|
||||
}
|
||||
BeanUtil.copyProperties(bo, update, "reqId", "createBy", "createTime");
|
||||
baseMapper.updateById(update);
|
||||
// 覆盖式重写明细
|
||||
itemMapper.delete(Wrappers.lambdaQuery(ErpPurchaseRequisitionItem.class)
|
||||
.eq(ErpPurchaseRequisitionItem::getReqId, bo.getReqId()));
|
||||
saveItems(bo.getReqId(), bo.getItems());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean submitApproval(Long reqId) {
|
||||
ErpPurchaseRequisition entity = baseMapper.selectById(reqId);
|
||||
if (entity == null) return false;
|
||||
if (!"0".equals(entity.getFormStatus())) {
|
||||
throw new RuntimeException("仅草稿状态的请购单可提交审批");
|
||||
}
|
||||
entity.setFormStatus("1");
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean approve(Long reqId) {
|
||||
ErpPurchaseRequisition entity = baseMapper.selectById(reqId);
|
||||
if (entity == null) return false;
|
||||
if (!"1".equals(entity.getFormStatus())) {
|
||||
throw new RuntimeException("仅审批中状态的请购单可通过");
|
||||
}
|
||||
entity.setFormStatus("2");
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean reject(Long reqId) {
|
||||
ErpPurchaseRequisition entity = baseMapper.selectById(reqId);
|
||||
if (entity == null) return false;
|
||||
if (!"1".equals(entity.getFormStatus())) {
|
||||
throw new RuntimeException("仅审批中状态的请购单可驳回");
|
||||
}
|
||||
entity.setFormStatus("5");
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user