|
@@ -1,38 +1,39 @@
|
|
|
package com.ruoyi.web.controller.cost;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
import com.ruoyi.anpin.domain.CostManagementDetailExcel;
|
|
|
import com.ruoyi.anpin.domain.CostManagementExcel;
|
|
|
import com.ruoyi.anpin.domain.TCostManagement;
|
|
|
import com.ruoyi.anpin.service.ITCostManagementService;
|
|
|
+import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
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.security.access.prepost.PreAuthorize;
|
|
|
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;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 费用管理Controller
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2023-03-13
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/anpin/management")
|
|
|
-public class TCostManagementController extends BaseController
|
|
|
-{
|
|
|
+public class TCostManagementController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITCostManagementService tCostManagementService;
|
|
|
|
|
@@ -41,8 +42,18 @@ public class TCostManagementController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TCostManagement tCostManagement)
|
|
|
- {
|
|
|
+ public TableDataInfo list(TCostManagement tCostManagement) {
|
|
|
+ // 获取当前的用户
|
|
|
+ LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
|
|
|
+ List<SysRole> sysRoleList = loginUser.getUser().getRoles();
|
|
|
+ if (sysRoleList.size() > 0) {
|
|
|
+ List<String> key = sysRoleList.stream().map(SysRole::getRoleKey).collect(Collectors.toList());
|
|
|
+ if (!key.contains("admin") && !key.contains("2")) {
|
|
|
+ tCostManagement.setCreateById(loginUser.getUser().getUserId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tCostManagement.setCreateById(loginUser.getUser().getUserId());
|
|
|
+ }
|
|
|
startPage();
|
|
|
List<TCostManagement> list = tCostManagementService.selectTCostManagementList(tCostManagement);
|
|
|
return getDataTable(list);
|
|
@@ -54,8 +65,7 @@ public class TCostManagementController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:export')")
|
|
|
@Log(title = "费用管理", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(TCostManagement tCostManagement)
|
|
|
- {
|
|
|
+ public AjaxResult export(TCostManagement tCostManagement) {
|
|
|
List<TCostManagement> list = tCostManagementService.selectTCostManagementList(tCostManagement);
|
|
|
ExcelUtil<TCostManagement> util = new ExcelUtil<TCostManagement>(TCostManagement.class);
|
|
|
return util.exportExcel(list, "费用管理");
|
|
@@ -91,8 +101,7 @@ public class TCostManagementController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:query')")
|
|
|
@GetMapping(value = "/{fId}")
|
|
|
- public AjaxResult getInfo(@PathVariable("fId") Long fId)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("fId") Long fId) {
|
|
|
return AjaxResult.success(tCostManagementService.selectTCostManagementById(fId));
|
|
|
}
|
|
|
|
|
@@ -105,14 +114,13 @@ public class TCostManagementController extends BaseController
|
|
|
@RepeatSubmit
|
|
|
public AjaxResult managementAdd(@RequestParam("tCostManagement") String tCostManagement,
|
|
|
@RequestParam("tCostManagementItem") String tCostManagementItem,
|
|
|
- @RequestParam("tEnclosure") String tEnclosure)
|
|
|
- {
|
|
|
+ @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);
|
|
|
+ return tCostManagementService.insertTCostManagement(tCostManagement, tCostManagementItem, tEnclosure, loginUser);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -121,8 +129,7 @@ public class TCostManagementController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:edit')")
|
|
|
@Log(title = "费用管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TCostManagement tCostManagement)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody TCostManagement tCostManagement) {
|
|
|
return toAjax(tCostManagementService.updateTCostManagement(tCostManagement));
|
|
|
}
|
|
|
|
|
@@ -131,14 +138,14 @@ public class TCostManagementController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:remove')")
|
|
|
@Log(title = "费用管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{fIds}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] fIds)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{fIds}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] fIds) {
|
|
|
return toAjax(tCostManagementService.deleteTCostManagementByIds(fIds));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 费用管理提交审批
|
|
|
+ *
|
|
|
* @param tCostManagement
|
|
|
* @param tCostManagementItem
|
|
|
* @param tEnclosure
|
|
@@ -147,67 +154,67 @@ public class TCostManagementController extends BaseController
|
|
|
@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)){
|
|
|
+ @RequestParam("tCostManagementItem") String tCostManagementItem,
|
|
|
+ @RequestParam("tEnclosure") String tEnclosure) {
|
|
|
+ if (StringUtils.isEmpty(tCostManagement) || "{}".equals(tCostManagement)) {
|
|
|
return AjaxResult.error("主表数据不能为空");
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(tCostManagementItem)|| "[]".equals(tCostManagementItem)){
|
|
|
+ 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);
|
|
|
+ return tCostManagementService.submitCostManagement(tCostManagement, tCostManagementItem, tEnclosure, loginUser, billType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取费用管理环比分析数据
|
|
|
- * @param expenseIds 费用名称
|
|
|
- * @param year 年份
|
|
|
+ *
|
|
|
+ * @param expenseIds 费用名称
|
|
|
+ * @param year 年份
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:costLinkAnalysis')")
|
|
|
@GetMapping(value = "/costLinkAnalysis")
|
|
|
- public AjaxResult costLinkAnalysis(String expenseIds,String year)
|
|
|
- {
|
|
|
+ public AjaxResult costLinkAnalysis(String expenseIds, String year) {
|
|
|
return tCostManagementService.costLinkAnalysis(expenseIds, year);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取费用管理同比分析数据
|
|
|
- * @param expenseIds 费用名称
|
|
|
- * @param currentDate 当前日期
|
|
|
- * @param comparisonDate 对比日期
|
|
|
+ *
|
|
|
+ * @param expenseIds 费用名称
|
|
|
+ * @param currentDate 当前日期
|
|
|
+ * @param comparisonDate 对比日期
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:costYOYAnalysis')")
|
|
|
@GetMapping(value = "/costYOYAnalysis")
|
|
|
- public AjaxResult costYOYAnalysis(@RequestParam(value = "expenseIds",required = false) String expenseIds,
|
|
|
+ public AjaxResult costYOYAnalysis(@RequestParam(value = "expenseIds", required = false) String expenseIds,
|
|
|
@RequestParam(value = "currentDate") String currentDate,
|
|
|
- @RequestParam(value = "comparisonDate") String comparisonDate)
|
|
|
- {
|
|
|
+ @RequestParam(value = "comparisonDate") String comparisonDate) {
|
|
|
return tCostManagementService.costYOYAnalysis(expenseIds, currentDate, comparisonDate);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取利润分析环比数据
|
|
|
- * @param corpId 项目名称
|
|
|
- * @param year 年
|
|
|
+ *
|
|
|
+ * @param corpId 项目名称
|
|
|
+ * @param year 年
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('anpin:management:profitAnalysis')")
|
|
|
@GetMapping(value = "/profitAnalysis")
|
|
|
- public AjaxResult profitAnalysis(String corpId,String year)
|
|
|
- {
|
|
|
+ public AjaxResult profitAnalysis(String corpId, String year) {
|
|
|
return tCostManagementService.profitAnalysis(corpId, year);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 修改打印次数
|
|
|
+ *
|
|
|
* @param data 主键
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/printTimes")
|
|
|
- public AjaxResult setPrintTimes(@RequestBody()Map<String, String> data) {
|
|
|
+ public AjaxResult setPrintTimes(@RequestBody() Map<String, String> data) {
|
|
|
String id = data.get("id");
|
|
|
Long fId = Long.valueOf(id);
|
|
|
String printDate = data.get("printDate");
|