feat(project-budget): 优化成本详情模板

- 为 ProjectBudgetCostDetailTemp 类添加 Lombok 的 @Data 注解,简化代码
- 新增 categoryStr 字段用于存储采购类别字符串
- 修改 ProjectBudgetService 中的成本详情保存逻辑,更新类别信息
- 修复类型判断逻辑,将"施工"改为"工程"
dev_2.0.2
chenhao 2024-12-20 11:00:27 +08:00
parent c202756962
commit f011584e57
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package cn.palmte.work.model;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -9,7 +11,9 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "project_budget_cost_detail_temp")
@Data
public class ProjectBudgetCostDetailTemp extends ProjectBudgetCostDetailBase{
private String categoryStr;
public ProjectBudgetCostDetail toProjectBudgetCostDetail(){
ProjectBudgetCostDetail detail = new ProjectBudgetCostDetail();
detail.setProjectId(getProjectId());

View File

@ -1282,6 +1282,7 @@ public class ProjectBudgetService {
// }
// projectBudgetCostDetailRepository.save(CostDetailList);
final ResponseMsg msg = ResponseMsg.buildSuccessMsg(String.format("成功:%d, 失败:%d", successCount, errorCount));
costDetailTempList.forEach(item->item.setCategory(item.getCategoryStr()));
msg.setData(new HashMap<String,List>(){{put("errorList",errorList);put("successList",costDetailTempList);}});
return msg;
}
@ -1296,7 +1297,7 @@ public class ProjectBudgetService {
String type = (String) o1;
if ("设备".equals(type)) {
temp.setType(1);
} else if ("工".equals(type)) {
} else if ("".equals(type)) {
temp.setType(2);
} else if ("服务".equals(type)) {
temp.setType(3);
@ -1311,6 +1312,7 @@ public class ProjectBudgetService {
ProcurementType procurementType = procurementTypeRepository.findByName(category);
if (procurementType != null && (procurementType.getType() == temp.getType() && temp.getType()!=4)) {
temp.setCategory(procurementType.getId().toString());
temp.setCategoryStr(category);
} else {
throw new Exception("该采购类别不存在或者与采购成本项目不匹配");
}