diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/controller/ProjectBudgetDetailsController.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/controller/ProjectBudgetDetailsController.java new file mode 100644 index 0000000..27780d1 --- /dev/null +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/controller/ProjectBudgetDetailsController.java @@ -0,0 +1,104 @@ +package com.ruoyi.server.project_budget_details.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.server.project_budget_details.domain.ProjectBudgetDetails; +import com.ruoyi.server.project_budget_details.service.IProjectBudgetDetailsService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 项目预算信息Controller + * + * @author ruoyi + * @date 2024-07-02 + */ +@RestController +@RequestMapping("/system/project_budget_details") +public class ProjectBudgetDetailsController extends BaseController +{ + @Autowired + private IProjectBudgetDetailsService projectBudgetDetailsService; + + /** + * 查询项目预算信息列表 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:list')") + @GetMapping("/list") + public TableDataInfo list(ProjectBudgetDetails projectBudgetDetails) + { + startPage(); + List list = projectBudgetDetailsService.selectProjectBudgetDetailsList(projectBudgetDetails); + return getDataTable(list); + } + + /** + * 导出项目预算信息列表 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:export')") + @Log(title = "项目预算信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ProjectBudgetDetails projectBudgetDetails) + { + List list = projectBudgetDetailsService.selectProjectBudgetDetailsList(projectBudgetDetails); + ExcelUtil util = new ExcelUtil(ProjectBudgetDetails.class); + util.exportExcel(response, list, "项目预算信息数据"); + } + + /** + * 获取项目预算信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(projectBudgetDetailsService.selectProjectBudgetDetailsById(id)); + } + + /** + * 新增项目预算信息 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:add')") + @Log(title = "项目预算信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ProjectBudgetDetails projectBudgetDetails) + { + return toAjax(projectBudgetDetailsService.insertProjectBudgetDetails(projectBudgetDetails)); + } + + /** + * 修改项目预算信息 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:edit')") + @Log(title = "项目预算信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ProjectBudgetDetails projectBudgetDetails) + { + return toAjax(projectBudgetDetailsService.updateProjectBudgetDetails(projectBudgetDetails)); + } + + /** + * 删除项目预算信息 + */ + @PreAuthorize("@ss.hasPermi('system:project_budget_details:remove')") + @Log(title = "项目预算信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(projectBudgetDetailsService.deleteProjectBudgetDetailsByIds(ids)); + } +} diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/domain/ProjectBudgetDetails.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/domain/ProjectBudgetDetails.java new file mode 100644 index 0000000..4ac05f4 --- /dev/null +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/domain/ProjectBudgetDetails.java @@ -0,0 +1,117 @@ +package com.ruoyi.server.project_budget_details.domain; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.TableField; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 项目预算信息对象 project_budget_details + * + * @author ruoyi + * @date 2024-07-02 + */ +public class ProjectBudgetDetails extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 预算ID */ + //@Excel(name = "预算ID") + private Long budgetId; + + /** 预算名称 */ + @Excel(name = "预算名称") + private String budgetName; + + /** 支出类别 */ + @Excel(name = "支出类别") + private String expenseCategory; + + /** 金额 */ + @Excel(name = "金额") + private BigDecimal amount; + + @TableField(exist = false) + private BigDecimal endTotalBudget ; + @TableField(exist = false) + private BigDecimal startTotalBudget ; + + public BigDecimal getEndTotalBudget() { + return endTotalBudget; + } + + public void setEndTotalBudget(BigDecimal endTotalBudget) { + this.endTotalBudget = endTotalBudget; + } + + public BigDecimal getStartTotalBudget() { + return startTotalBudget; + } + + public void setStartTotalBudget(BigDecimal startTotalBudget) { + this.startTotalBudget = startTotalBudget; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setBudgetId(Long budgetId) + { + this.budgetId = budgetId; + } + + public Long getBudgetId() + { + return budgetId; + } + public void setBudgetName(String budgetName) + { + this.budgetName = budgetName; + } + + public String getBudgetName() + { + return budgetName; + } + public void setExpenseCategory(String expenseCategory) + { + this.expenseCategory = expenseCategory; + } + + public String getExpenseCategory() + { + return expenseCategory; + } + public void setAmount(BigDecimal amount) + { + this.amount = amount; + } + + public BigDecimal getAmount() + { + return amount; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("budgetId", getBudgetId()) + .append("budgetName", getBudgetName()) + .append("expenseCategory", getExpenseCategory()) + .append("amount", getAmount()) + .toString(); + } +} diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/mapper/ProjectBudgetDetailsMapper.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/mapper/ProjectBudgetDetailsMapper.java new file mode 100644 index 0000000..f8e9bc1 --- /dev/null +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/mapper/ProjectBudgetDetailsMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.server.project_budget_details.mapper; + +import java.util.List; +import com.ruoyi.server.project_budget_details.domain.ProjectBudgetDetails; + +/** + * 项目预算信息Mapper接口 + * + * @author ruoyi + * @date 2024-07-02 + */ +public interface ProjectBudgetDetailsMapper +{ + /** + * 查询项目预算信息 + * + * @param id 项目预算信息主键 + * @return 项目预算信息 + */ + public ProjectBudgetDetails selectProjectBudgetDetailsById(Long id); + + /** + * 查询项目预算信息列表 + * + * @param projectBudgetDetails 项目预算信息 + * @return 项目预算信息集合 + */ + public List selectProjectBudgetDetailsList(ProjectBudgetDetails projectBudgetDetails); + + /** + * 新增项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + public int insertProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails); + + /** + * 修改项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + public int updateProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails); + + /** + * 删除项目预算信息 + * + * @param id 项目预算信息主键 + * @return 结果 + */ + public int deleteProjectBudgetDetailsById(Long id); + + /** + * 批量删除项目预算信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteProjectBudgetDetailsByIds(Long[] ids); +} diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/IProjectBudgetDetailsService.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/IProjectBudgetDetailsService.java new file mode 100644 index 0000000..6e1989a --- /dev/null +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/IProjectBudgetDetailsService.java @@ -0,0 +1,61 @@ +package com.ruoyi.server.project_budget_details.service; + +import java.util.List; +import com.ruoyi.server.project_budget_details.domain.ProjectBudgetDetails; + +/** + * 项目预算信息Service接口 + * + * @author ruoyi + * @date 2024-07-02 + */ +public interface IProjectBudgetDetailsService +{ + /** + * 查询项目预算信息 + * + * @param id 项目预算信息主键 + * @return 项目预算信息 + */ + public ProjectBudgetDetails selectProjectBudgetDetailsById(Long id); + + /** + * 查询项目预算信息列表 + * + * @param projectBudgetDetails 项目预算信息 + * @return 项目预算信息集合 + */ + public List selectProjectBudgetDetailsList(ProjectBudgetDetails projectBudgetDetails); + + /** + * 新增项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + public int insertProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails); + + /** + * 修改项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + public int updateProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails); + + /** + * 批量删除项目预算信息 + * + * @param ids 需要删除的项目预算信息主键集合 + * @return 结果 + */ + public int deleteProjectBudgetDetailsByIds(Long[] ids); + + /** + * 删除项目预算信息信息 + * + * @param id 项目预算信息主键 + * @return 结果 + */ + public int deleteProjectBudgetDetailsById(Long id); +} diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/impl/ProjectBudgetDetailsServiceImpl.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/impl/ProjectBudgetDetailsServiceImpl.java new file mode 100644 index 0000000..2919de2 --- /dev/null +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budget_details/service/impl/ProjectBudgetDetailsServiceImpl.java @@ -0,0 +1,125 @@ +package com.ruoyi.server.project_budget_details.service.impl; + +import java.math.BigDecimal; +import java.util.List; + +import com.ruoyi.server.project_budgets.domain.ProjectBudgets; +import com.ruoyi.server.project_budgets.mapper.ProjectBudgetsMapper; +import com.ruoyi.server.project_proposals.domain.ProjectProposals; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.server.project_budget_details.mapper.ProjectBudgetDetailsMapper; +import com.ruoyi.server.project_budget_details.domain.ProjectBudgetDetails; +import com.ruoyi.server.project_budget_details.service.IProjectBudgetDetailsService; + +/** + * 项目预算信息Service业务层处理 + * + * @author ruoyi + * @date 2024-07-02 + */ +@Service +public class ProjectBudgetDetailsServiceImpl implements IProjectBudgetDetailsService +{ + @Autowired + private ProjectBudgetDetailsMapper projectBudgetDetailsMapper; + + @Autowired + private ProjectBudgetsMapper projectBudgetsMapper; + + /** + * 查询项目预算信息 + * + * @param id 项目预算信息主键 + * @return 项目预算信息 + */ + @Override + public ProjectBudgetDetails selectProjectBudgetDetailsById(Long id) + { + return projectBudgetDetailsMapper.selectProjectBudgetDetailsById(id); + } + + /** + * 查询项目预算信息列表 + * + * @param projectBudgetDetails 项目预算信息 + * @return 项目预算信息 + */ + @Override + public List selectProjectBudgetDetailsList(ProjectBudgetDetails projectBudgetDetails) + { + return projectBudgetDetailsMapper.selectProjectBudgetDetailsList(projectBudgetDetails); + } + + /** + * 新增项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + @Override + public int insertProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails) + { + + extracted(projectBudgetDetails); + return projectBudgetDetailsMapper.insertProjectBudgetDetails(projectBudgetDetails); + } + + private void extracted(ProjectBudgetDetails projectBudgets) { + ProjectBudgets projectBudgets1 = projectBudgetsMapper.selectProjectBudgetsById(projectBudgets.getBudgetId()); + if(projectBudgets1!=null){ + + projectBudgets.setBudgetName(projectBudgets1.getAllocation()); + ProjectBudgetDetails budgetDetails=new ProjectBudgetDetails(); + budgetDetails.setBudgetId(projectBudgets1.getId()); + + List projectBudgetDetails = projectBudgetDetailsMapper.selectProjectBudgetDetailsList(budgetDetails); + if(!projectBudgetDetails.isEmpty()){ + // 利用Stream API对amount字段进行汇总 + BigDecimal totalAmount = projectBudgetDetails.stream() + .map(ProjectBudgetDetails::getAmount) // 提取每个ProjectBudgetDetails实例中的amount值 + .reduce(BigDecimal.ZERO, BigDecimal::add); // 使用reduce操作将所有amount值累加,初始值为0 + projectBudgets1.setTotalBudget(totalAmount); + projectBudgetsMapper.updateProjectBudgets(projectBudgets1); + } + + } + + } + /** + * 修改项目预算信息 + * + * @param projectBudgetDetails 项目预算信息 + * @return 结果 + */ + @Override + public int updateProjectBudgetDetails(ProjectBudgetDetails projectBudgetDetails) + { + extracted(projectBudgetDetails); + return projectBudgetDetailsMapper.updateProjectBudgetDetails(projectBudgetDetails); + } + + /** + * 批量删除项目预算信息 + * + * @param ids 需要删除的项目预算信息主键 + * @return 结果 + */ + @Override + public int deleteProjectBudgetDetailsByIds(Long[] ids) + { + return projectBudgetDetailsMapper.deleteProjectBudgetDetailsByIds(ids); + } + + /** + * 删除项目预算信息信息 + * + * @param id 项目预算信息主键 + * @return 结果 + */ + @Override + public int deleteProjectBudgetDetailsById(Long id) + { + return projectBudgetDetailsMapper.deleteProjectBudgetDetailsById(id); + } +} diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_budgets/domain/ProjectBudgets.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_budgets/domain/ProjectBudgets.java index d0cd7dd..0b092e8 100644 --- a/ruoyi-server/src/main/java/com/ruoyi/server/project_budgets/domain/ProjectBudgets.java +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_budgets/domain/ProjectBudgets.java @@ -1,6 +1,8 @@ package com.ruoyi.server.project_budgets.domain; import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.TableField; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -17,11 +19,11 @@ public class ProjectBudgets extends BaseEntity private static final long serialVersionUID = 1L; /** */ - @Excel(name = "") + ///@Excel(name = "") private Long id; /** 项目id */ - @Excel(name = "项目id") + // @Excel(name = "项目id") private Long projectId; /** 项目名称 */ @@ -36,7 +38,30 @@ public class ProjectBudgets extends BaseEntity @Excel(name = "预算分配") private String allocation; - public void setId(Long id) + @TableField(exist = false) + private BigDecimal endTotalBudget ; + @TableField(exist = false) + private BigDecimal startTotalBudget ; + + public BigDecimal getEndTotalBudget() { + return endTotalBudget; + } + + public void setEndTotalBudget(BigDecimal endTotalBudget) { + this.endTotalBudget = endTotalBudget; + } + + public BigDecimal getStartTotalBudget() { + return startTotalBudget; + } + + public void setStartTotalBudget(BigDecimal startTotalBudget) { + this.startTotalBudget = startTotalBudget; + } + + + + public void setId(Long id) { this.id = id; } diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/controller/ProjectProposalDetailsController.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/controller/ProjectProposalDetailsController.java index 2ac4223..a0e6f3d 100644 --- a/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/controller/ProjectProposalDetailsController.java +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/controller/ProjectProposalDetailsController.java @@ -55,6 +55,7 @@ public class ProjectProposalDetailsController extends BaseController public void export(HttpServletResponse response, ProjectProposalDetails projectProposalDetails) { List list = projectProposalDetailsService.selectProjectProposalDetailsList(projectProposalDetails); + ExcelUtil util = new ExcelUtil(ProjectProposalDetails.class); util.exportExcel(response, list, "项目立项信息数据"); } diff --git a/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/domain/ProjectProposalDetails.java b/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/domain/ProjectProposalDetails.java index ee70a37..1759f4c 100644 --- a/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/domain/ProjectProposalDetails.java +++ b/ruoyi-server/src/main/java/com/ruoyi/server/project_proposal_details/domain/ProjectProposalDetails.java @@ -17,11 +17,11 @@ public class ProjectProposalDetails extends BaseEntity private static final long serialVersionUID = 1L; /** $column.columnComment */ - @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + // @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private Long id; /** 立项ID */ - @Excel(name = "立项ID") + // @Excel(name = "立项ID") private Long proposalId; @Excel(name = "立项名称") diff --git a/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetDetailsMapper.xml b/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetDetailsMapper.xml new file mode 100644 index 0000000..b5c09a2 --- /dev/null +++ b/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetDetailsMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + select id, budget_id, budget_name, expense_category, amount from project_budget_details + + + + + + + + insert into project_budget_details + + budget_id, + budget_name, + expense_category, + amount, + + + #{budgetId}, + #{budgetName}, + #{expenseCategory}, + #{amount}, + + + + + update project_budget_details + + budget_id = #{budgetId}, + budget_name = #{budgetName}, + expense_category = #{expenseCategory}, + amount = #{amount}, + + where id = #{id} + + + + delete from project_budget_details where id = #{id} + + + + delete from project_budget_details where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetsMapper.xml b/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetsMapper.xml index 2f99c92..49062e4 100644 --- a/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetsMapper.xml +++ b/ruoyi-server/src/main/resources/mapper/system/ProjectBudgetsMapper.xml @@ -20,9 +20,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and project_id = #{projectId} - and project_name like concat('%', #{projectName}, '%') - and total_budget between #{params.beginTotalBudget} and #{params.endTotalBudget} - and allocation = #{allocation} + + and project_name like concat('%', #{projectName}, '%') + + + + and allocation like concat('%', #{allocation}, '%') + + + AND total_budget=]]> #{startTotalBudget} + + + AND total_budget #{endTotalBudget} + diff --git a/ruoyi-ui/src/api/system/project_budget_details.js b/ruoyi-ui/src/api/system/project_budget_details.js new file mode 100644 index 0000000..60b0478 --- /dev/null +++ b/ruoyi-ui/src/api/system/project_budget_details.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询项目预算信息列表 +export function listProject_budget_details(query) { + return request({ + url: '/system/project_budget_details/list', + method: 'get', + params: query + }) +} + +// 查询项目预算信息详细 +export function getProject_budget_details(id) { + return request({ + url: '/system/project_budget_details/' + id, + method: 'get' + }) +} + +// 新增项目预算信息 +export function addProject_budget_details(data) { + return request({ + url: '/system/project_budget_details', + method: 'post', + data: data + }) +} + +// 修改项目预算信息 +export function updateProject_budget_details(data) { + return request({ + url: '/system/project_budget_details', + method: 'put', + data: data + }) +} + +// 删除项目预算信息 +export function delProject_budget_details(id) { + return request({ + url: '/system/project_budget_details/' + id, + method: 'delete' + }) +} diff --git a/ruoyi-ui/src/views/system/project_budget_details/index.vue b/ruoyi-ui/src/views/system/project_budget_details/index.vue new file mode 100644 index 0000000..3402ac5 --- /dev/null +++ b/ruoyi-ui/src/views/system/project_budget_details/index.vue @@ -0,0 +1,393 @@ + + + diff --git a/ruoyi-ui/src/views/system/project_budgets/index.vue b/ruoyi-ui/src/views/system/project_budgets/index.vue index 54bd287..cb4124e 100644 --- a/ruoyi-ui/src/views/system/project_budgets/index.vue +++ b/ruoyi-ui/src/views/system/project_budgets/index.vue @@ -17,13 +17,39 @@ @keyup.enter.native="handleQuery" /> - + + + + + + + + + + + 搜索 @@ -42,7 +68,7 @@ v-hasPermi="['system:project_budgets:add']" >新增 - + - + +