| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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<TCostManagement> 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<TCostManagement> list = tCostManagementService.selectTCostManagementList(tCostManagement);
- ExcelUtil<TCostManagement> util = new ExcelUtil<TCostManagement>(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);
- }
- }
|