package com.ruoyi.web.controller.cost; import java.util.List; import com.ruoyi.anpin.domain.TCostManagement; import com.ruoyi.anpin.service.ITCostManagementService; import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.framework.web.service.TokenService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; 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.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 费用管理Controller * * @author ruoyi * @date 2023-03-13 */ @RestController @RequestMapping("/anpin/management") public class TCostManagementController extends BaseController { @Autowired private ITCostManagementService tCostManagementService; /** * 查询费用管理列表 */ @PreAuthorize("@ss.hasPermi('anpin:management:list')") @GetMapping("/list") public TableDataInfo list(TCostManagement tCostManagement) { startPage(); List list = tCostManagementService.selectTCostManagementList(tCostManagement); return getDataTable(list); } /** * 导出费用管理列表 */ @PreAuthorize("@ss.hasPermi('anpin:management:export')") @Log(title = "费用管理", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(TCostManagement tCostManagement) { List list = tCostManagementService.selectTCostManagementList(tCostManagement); ExcelUtil util = new ExcelUtil(TCostManagement.class); return util.exportExcel(list, "费用管理"); } /** * 获取费用管理详细信息 */ @PreAuthorize("@ss.hasPermi('anpin:management:query')") @GetMapping(value = "/{fId}") public AjaxResult getInfo(@PathVariable("fId") Long fId) { return AjaxResult.success(tCostManagementService.selectTCostManagementById(fId)); } /** * 新增费用管理 */ @PreAuthorize("@ss.hasPermi('anpin:management:add')") @Log(title = "费用管理", businessType = BusinessType.INSERT) @PostMapping(value = "/managementAdd") @RepeatSubmit public AjaxResult managementAdd(@RequestParam("tCostManagement") String tCostManagement, @RequestParam("tCostManagementItem") String tCostManagementItem, @RequestParam("tEnclosure") String tEnclosure) { if (StringUtils.isNull(tCostManagement) || "{}".equals(tCostManagement)) { return AjaxResult.error("未找到主表数据,请确认"); } // 获取当前的用户 LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); return tCostManagementService.insertTCostManagement(tCostManagement,tCostManagementItem,tEnclosure,loginUser); } /** * 修改费用管理 */ @PreAuthorize("@ss.hasPermi('anpin:management:edit')") @Log(title = "费用管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TCostManagement tCostManagement) { return toAjax(tCostManagementService.updateTCostManagement(tCostManagement)); } /** * 删除费用管理 */ @PreAuthorize("@ss.hasPermi('anpin:management:remove')") @Log(title = "费用管理", businessType = BusinessType.DELETE) @DeleteMapping("/{fIds}") public AjaxResult remove(@PathVariable Long[] fIds) { return toAjax(tCostManagementService.deleteTCostManagementByIds(fIds)); } /** * 费用管理提交审批 * @param tCostManagement * @param tCostManagementItem * @param tEnclosure * @return */ @PreAuthorize("@ss.hasPermi('anpin:management:submitCostManagement')") @Log(title = "费用管理审批", businessType = BusinessType.INSERT) @PostMapping("/submitCostManagement") public AjaxResult submitCostManagement(@RequestParam("tCostManagement") String tCostManagement, @RequestParam("tCostManagementItem") String tCostManagementItem, @RequestParam("tEnclosure") String tEnclosure) { if (StringUtils.isEmpty(tCostManagement) || "{}".equals(tCostManagement)){ return AjaxResult.error("主表数据不能为空"); } if (StringUtils.isEmpty(tCostManagementItem)|| "[]".equals(tCostManagementItem)){ return AjaxResult.error("明细表数据不能为空"); } String billType = "FYGL"; LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); return tCostManagementService.submitCostManagement(tCostManagement,tCostManagementItem,tEnclosure,loginUser,billType); } }