|
|
|
|
@ -19,6 +19,7 @@ import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpProjectPurchase;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpProjectPurchaseMaterial;
|
|
|
|
|
import org.dromara.oa.erp.domain.bo.ErpProjectPurchaseBo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpProjectMaterialsSourceVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpProjectPurchaseVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpProjectPurchaseMaterialVo;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpProjectPurchaseMapper;
|
|
|
|
|
@ -290,6 +291,42 @@ public class ErpProjectPurchaseServiceImpl implements IErpProjectPurchaseService
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ErpProjectMaterialsSourceVo getProjectMaterialsSourceByProjectId(Long projectId, String spareFlag, Long contractId) {
|
|
|
|
|
if (projectId == null || StringUtils.isBlank(spareFlag)) {
|
|
|
|
|
ErpProjectMaterialsSourceVo empty = new ErpProjectMaterialsSourceVo();
|
|
|
|
|
empty.setRelationId(null);
|
|
|
|
|
empty.setMaterialList(Collections.emptyList());
|
|
|
|
|
return empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ErpProjectMaterialsSourceVo result = new ErpProjectMaterialsSourceVo();
|
|
|
|
|
if ("0".equals(spareFlag)) {
|
|
|
|
|
// 非备件-预算物料:relationId 为预算ID
|
|
|
|
|
Set<Long> budgetIds = purchaseMaterialMapper.selectBudgetIdsByProjectId(projectId);
|
|
|
|
|
Long budgetId = (budgetIds == null || budgetIds.isEmpty()) ? null : budgetIds.iterator().next();
|
|
|
|
|
result.setRelationId(budgetId);
|
|
|
|
|
result.setMaterialList(purchaseMaterialMapper.selectBudgetMaterialsByProjectId(projectId, spareFlag));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("1".equals(spareFlag)) {
|
|
|
|
|
// 备件-合同物料:relationId 为合同ID(优先使用传入的 contractId)
|
|
|
|
|
Long relationId = contractId;
|
|
|
|
|
if (relationId == null) {
|
|
|
|
|
Set<Long> contractIds = purchaseMaterialMapper.selectContractIdsByProjectId(projectId);
|
|
|
|
|
relationId = (contractIds == null || contractIds.isEmpty()) ? null : contractIds.iterator().next();
|
|
|
|
|
}
|
|
|
|
|
result.setRelationId(relationId);
|
|
|
|
|
result.setMaterialList(purchaseMaterialMapper.selectContractMaterialsByProjectId(projectId, spareFlag));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.setRelationId(null);
|
|
|
|
|
result.setMaterialList(Collections.emptyList());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 项目采购流程事件监听
|
|
|
|
|
*
|
|
|
|
|
|