|
@@ -4,18 +4,29 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseinfo.vo.ExpenseInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseinfo.vo.ExpenseInfoRespVO;
|
|
|
import cn.iocoder.yudao.module.expense.controller.admin.expenseinfo.vo.ExpenseInfoSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.expense.dal.dataobject.expenseinfo.ExpenseInfoDO;
|
|
|
import cn.iocoder.yudao.module.expense.dal.dataobject.expenseinfo.ExpenseInfoObjDO;
|
|
|
+import cn.iocoder.yudao.module.expense.dal.dataobject.expenseitem.ExpenseItemDO;
|
|
|
+import cn.iocoder.yudao.module.expense.dal.dataobject.expensetype.ExpenseTypeDO;
|
|
|
import cn.iocoder.yudao.module.expense.service.expenseinfo.ExpenseInfoService;
|
|
|
+import cn.iocoder.yudao.module.expense.service.expenseitem.ExpenseItemService;
|
|
|
+import cn.iocoder.yudao.module.expense.service.expensetype.ExpenseTypeService;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springdoc.api.annotations.ParameterObject;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -24,6 +35,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -37,17 +51,34 @@ public class ExpenseInfoController {
|
|
|
@Resource
|
|
|
private ExpenseInfoService infoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ExpenseTypeService expenseTypeService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ExpenseItemService expenseItemService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PostApi postApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建报销信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:create')")
|
|
|
+
|
|
|
public CommonResult<Long> createInfo(@Valid @RequestBody ExpenseInfoSaveReqVO createReqVO) {
|
|
|
+ createReqVO.setInfoSource("1");
|
|
|
return success(infoService.createInfo(createReqVO));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新报销信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:update')")
|
|
|
+
|
|
|
public CommonResult<Boolean> updateInfo(@Valid @RequestBody ExpenseInfoSaveReqVO updateReqVO) {
|
|
|
+ updateReqVO.setInfoSource("1");
|
|
|
infoService.updateInfo(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
@@ -55,7 +86,7 @@ public class ExpenseInfoController {
|
|
|
@DeleteMapping("/delete")
|
|
|
@Operation(summary = "删除报销信息")
|
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:delete')")
|
|
|
+
|
|
|
public CommonResult<Boolean> deleteInfo(@RequestParam("id") Long id) {
|
|
|
infoService.deleteInfo(id);
|
|
|
return success(true);
|
|
@@ -63,32 +94,106 @@ public class ExpenseInfoController {
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
@Operation(summary = "获得报销信息")
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:query')")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1")
|
|
|
+
|
|
|
public CommonResult<ExpenseInfoRespVO> getInfo(@RequestParam("id") Long id) {
|
|
|
+
|
|
|
ExpenseInfoDO info = infoService.getInfo(id);
|
|
|
- return success(BeanUtils.toBean(info, ExpenseInfoRespVO.class));
|
|
|
+
|
|
|
+ ExpenseInfoRespVO expenseInfoRespVO = BeanUtils.toBean(info, ExpenseInfoRespVO.class);
|
|
|
+
|
|
|
+
|
|
|
+ Long employeeId = info.getEmployeeId();
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(employeeId);
|
|
|
+ if (Objects.nonNull(employee)) {
|
|
|
+ expenseInfoRespVO.setEmployeeName(employee.getName());
|
|
|
+ expenseInfoRespVO.setEmployeePhone(employee.getPhone());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Long deptId = info.getDeptId();
|
|
|
+ DeptRespDTO dept = deptApi.getDept(deptId);
|
|
|
+ if (Objects.nonNull(dept)) {
|
|
|
+ expenseInfoRespVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Long postId = info.getPostId();
|
|
|
+ PostRespDTO post = postApi.getPost(postId);
|
|
|
+ if (Objects.nonNull(post)) {
|
|
|
+ expenseInfoRespVO.setPosition(post.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Long expenseTypeId = info.getExpenseTypeId();
|
|
|
+ ExpenseTypeDO expenseTypeDO = expenseTypeService.getType(expenseTypeId);
|
|
|
+ if (expenseTypeDO != null) {
|
|
|
+ expenseInfoRespVO.setExpenseTypeName(expenseTypeDO.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String status = info.getStatus();
|
|
|
+ if (Objects.equals(status, "0")) {
|
|
|
+ expenseInfoRespVO.setStatusDesc("已完成");
|
|
|
+ } else if (Objects.equals(status, "1")) {
|
|
|
+ expenseInfoRespVO.setStatusDesc("已作废");
|
|
|
+ } else {
|
|
|
+ expenseInfoRespVO.setStatusDesc("未知");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String infoSource = info.getInfoSource();
|
|
|
+ if (Objects.equals(infoSource, "0")) {
|
|
|
+ expenseInfoRespVO.setInfoSourceDesc("流程添加");
|
|
|
+ } else if (Objects.equals(infoSource, "1")) {
|
|
|
+ expenseInfoRespVO.setInfoSourceDesc("手动添加");
|
|
|
+ } else {
|
|
|
+ expenseInfoRespVO.setInfoSourceDesc("未知来源");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Long createEmployeeId = info.getCreateEmployeeId();
|
|
|
+ EmployeeRespDTO createEmployee = employeeApi.getEmployeeById(createEmployeeId);
|
|
|
+ if (Objects.nonNull(createEmployee)) {
|
|
|
+ expenseInfoRespVO.setCreateEmployeeName(createEmployee.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ExpenseInfoObjDO> expenseInfoObjDOs = infoService.getExpenseInfoObjListByExpenseId(info.getId());
|
|
|
+ List<Long> expenseItemIdList = expenseInfoObjDOs.stream().map(ExpenseInfoObjDO::getExpenseItemId).collect(Collectors.toList());
|
|
|
+ List<ExpenseItemDO> expenseItemDOList = expenseItemService.getExpenseItemList(expenseItemIdList);
|
|
|
+ Map<Long, ExpenseItemDO> longExpenseItemDOMap = CollectionUtils.convertMap(expenseItemDOList, ExpenseItemDO::getId);
|
|
|
+ for (ExpenseInfoObjDO expenseInfoObjDO : expenseInfoObjDOs) {
|
|
|
+ ExpenseItemDO expenseItemDO = longExpenseItemDOMap.get(expenseInfoObjDO.getExpenseItemId());
|
|
|
+ if (Objects.nonNull(expenseItemDO)) {
|
|
|
+ expenseInfoObjDO.setExpenseItemName(expenseItemDO.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ expenseInfoRespVO.setExpenseInfoObjs(expenseInfoObjDOs);
|
|
|
+
|
|
|
+
|
|
|
+ return success(expenseInfoRespVO);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
@Operation(summary = "获得报销信息分页")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:query')")
|
|
|
- public CommonResult<PageResult<ExpenseInfoRespVO>> getInfoPage(@Valid ExpenseInfoPageReqVO pageReqVO) {
|
|
|
- PageResult<ExpenseInfoDO> pageResult = infoService.getInfoPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, ExpenseInfoRespVO.class));
|
|
|
+
|
|
|
+ public CommonResult<PageResult<ExpenseInfoRespVO>> getInfoPage(@Valid @ParameterObject ExpenseInfoPageReqVO pageReqVO) {
|
|
|
+ PageResult<ExpenseInfoRespVO> infoPage = infoService.getInfoPage(pageReqVO);
|
|
|
+ return success(infoPage);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出报销信息 Excel")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:export')")
|
|
|
+
|
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
|
public void exportInfoExcel(@Valid ExpenseInfoPageReqVO pageReqVO,
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
- List<ExpenseInfoDO> list = infoService.getInfoPage(pageReqVO).getList();
|
|
|
+ List<ExpenseInfoRespVO> list = infoService.getInfoPage(pageReqVO).getList();
|
|
|
|
|
|
ExcelUtils.write(response, "报销信息.xls", "数据", ExpenseInfoRespVO.class,
|
|
|
- BeanUtils.toBean(list, ExpenseInfoRespVO.class));
|
|
|
+ list);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -96,7 +201,7 @@ public class ExpenseInfoController {
|
|
|
@GetMapping("/expense-info-obj/list-by-expense-id")
|
|
|
@Operation(summary = "获得报销信息子列表")
|
|
|
@Parameter(name = "expenseId", description = "报销主表主键id")
|
|
|
- @PreAuthorize("@ss.hasPermission('expense:info:query')")
|
|
|
+
|
|
|
public CommonResult<List<ExpenseInfoObjDO>> getExpenseInfoObjListByExpenseId(@RequestParam("expenseId") Long expenseId) {
|
|
|
return success(infoService.getExpenseInfoObjListByExpenseId(expenseId));
|
|
|
}
|