| | |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | 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; |
| | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(ServiceFund serviceFund) { |
| | | startPage(); |
| | | //List<ServiceFund> list = serviceFundService.queryList(serviceFund); |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | serviceFund.setUsername(user.getNickName()); |
| | | // 2026-11-10:按角色划分可见范围(原实现一律只查"申请人=本人",管理员/组长看不到别人的单据) |
| | | applyFundDataScope(serviceFund, user); |
| | | List<ServiceFund> list = serviceFundService.selectServiceFundList(serviceFund); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 报销单列表数据范围: |
| | | * 超管(user_id=1 或 role_id=1)→ 全部; |
| | | * 业务组长(role_id=13)→ 本组(DeptmentNo = 登录人所属部门); |
| | | * 其他(专职人员等)→ 本人(UserName = 登录人昵称)。 |
| | | */ |
| | | private void applyFundDataScope(ServiceFund serviceFund, SysUser user) { |
| | | if (user == null) { |
| | | return; |
| | | } |
| | | if (Long.valueOf(1L).equals(user.getUserId()) || hasRole(user, 1L)) { |
| | | // 超管:不加任何过滤,看全部 |
| | | return; |
| | | } |
| | | if (hasRole(user, 13L) && user.getDeptId() != null) { |
| | | // 业务组长:看本组 |
| | | serviceFund.setDeptmentno(String.valueOf(user.getDeptId())); |
| | | return; |
| | | } |
| | | // 默认:只看本人 |
| | | serviceFund.setUsername(user.getNickName()); |
| | | } |
| | | |
| | | /** 判断登录人是否拥有指定角色 */ |
| | | private boolean hasRole(SysUser user, Long roleId) { |
| | | if (user == null || user.getRoles() == null) { |
| | | return false; |
| | | } |
| | | for (SysRole role : user.getRoles()) { |
| | | if (role != null && roleId.equals(role.getRoleId())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @GetMapping("/listnew") |
| | |
| | | @RepeatSubmit |
| | | @Options(useGeneratedKeys = true, keyProperty = "id") |
| | | public AjaxResult addOrUpdateNew(@RequestBody ServiceFundVO serviceFundVO) { |
| | | // 2026-11-23:剔除 blob:/data: 这类浏览器临时附件地址,避免落库后无法预览 |
| | | int droppedAttach = sanitizeAttachments(serviceFundVO); |
| | | AjaxResult result = AjaxResult.success(serviceFundService.addOrUpdateNew(serviceFundVO)); |
| | | if (droppedAttach > 0) { |
| | | result.put("attachWarn", |
| | | "检测到 " + droppedAttach + " 个附件地址无效(浏览器临时地址),已自动剔除,请重新上传这些附件后再保存。"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | return AjaxResult.success(serviceFundService.addOrUpdateNew(serviceFundVO)); |
| | | /** |
| | | * 2026-11-23:清洗整单明细里的临时附件地址(blob:/data:/file:)。 |
| | | * |
| | | * @return 被剔除的附件条数 |
| | | */ |
| | | private int sanitizeAttachments(ServiceFundVO serviceFundVO) { |
| | | if (serviceFundVO == null || CollectionUtils.isEmpty(serviceFundVO.getServiceFunddetails())) { |
| | | return 0; |
| | | } |
| | | int dropped = 0; |
| | | for (ServiceFunddetailVO detail : serviceFundVO.getServiceFunddetails()) { |
| | | if (detail == null) { |
| | | continue; |
| | | } |
| | | dropped += com.ruoyi.project.common.AttachmentUrlSanitizer.sanitize(detail.getAnnexfilesList()); |
| | | dropped += com.ruoyi.project.common.AttachmentUrlSanitizer.sanitize(detail.getInvoicefilesList()); |
| | | } |
| | | if (dropped > 0) { |
| | | log.warn("报销单保存:剔除 {} 个临时附件地址(blob:/data:),单据 fundid={}", dropped, serviceFundVO.getId()); |
| | | } |
| | | return dropped; |
| | | } |
| | | |
| | | /** |
| | |
| | | List<ServiceFund> infoByInfoIdList = serviceFundService.queryInfoById(serviceFund); |
| | | log.info("修改费用申请,通过入参查询 serviceFundService.queryInfoById数据为空,入参:{}", infoByInfoIdList.size()); |
| | | if (CollectionUtils.isEmpty(infoByInfoIdList)) { |
| | | // 2026-11-23:同样剔除临时附件地址(blob:/data:),避免落库后无法预览 |
| | | sanitizeAttachments(serviceFundVO); |
| | | Long id = serviceFundService.addOrUpdateNew(serviceFundVO); |
| | | serviceFund.setId(id); |
| | | } |