| | |
| | | import com.ycl.platform.domain.query.CalculateReportQuery; |
| | | import com.ycl.platform.domain.vo.CalculateReportDetailVO; |
| | | import com.ycl.platform.domain.vo.CalculateReportVO; |
| | | import com.ycl.platform.domain.vo.ContractResultVO; |
| | | import com.ycl.platform.mapper.CalculateRecordMapper; |
| | | import com.ycl.platform.mapper.CalculateReportMapper; |
| | | import com.ycl.platform.service.CalculateReportService; |
| | | import com.ycl.platform.service.ICalculateRuleService; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.entity.SysRole; |
| | | import com.ycl.system.entity.SysUser; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import enumeration.general.CalculateReportStatusEnum; |
| | | import enumeration.general.PublishType; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Date; |
| | |
| | | @Override |
| | | public Result page(CalculateReportQuery query) { |
| | | IPage<CalculateReportVO> page = PageUtil.getPage(query, CalculateReportVO.class); |
| | | //只能看自己单位 |
| | | query.setUnitId(SecurityUtils.getUnitId()); |
| | | //只能看已发布 |
| | | roleControl(query); |
| | | baseMapper.page(query, page); |
| | | page.getRecords().stream().forEach(item -> { |
| | | if (Objects.isNull(item)) { |
| | |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @param |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(CalculateReportQuery query) { |
| | | roleControl(query); |
| | | // 明细列表 |
| | | CalculateReportDetailVO detail = baseMapper.getById(query); |
| | | if (Objects.nonNull(detail) && ! CollectionUtils.isEmpty(detail.getRecordList())) { |
| | | if (CalculateReportStatusEnum.NOT_PUBLISH.equals(detail.getStatus())) { |
| | | detail.getRecordList().get(0).setLatest(Boolean.TRUE); |
| | | } else { |
| | | detail.getRecordList().get(0).setLatest(Boolean.FALSE); |
| | | } |
| | | } |
| | | return Result.ok().data(detail); |
| | | } |
| | | |
| | | private void roleControl(CalculateReportQuery query) { |
| | | List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles(); |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | if (!user.isAdmin()) { |
| | | for (SysRole role : roles) { |
| | | //菜单的地方增加了一个按钮,角色权限编辑如果勾上了说明只能查看已发布 |
| | | if (role.getPermissions().contains("check:contract:role:publish")) { |
| | | query.setStatus(PublishType.PUBLISHED.getCode()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 列表 |
| | | * @return |
| | |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public void export(Integer contractId, HttpServletResponse response) { |
| | | public void export(Integer calculateId,Integer contractId, HttpServletResponse response) { |
| | | // 获取数据 |
| | | List<CalculateExport> list = baseMapper.exportData(contractId); |
| | | List<CalculateExport> list = baseMapper.exportData(calculateId); |
| | | CalculateExport calculateExport = new CalculateExport(); |
| | | calculateExport.setRuleName("合计"); |
| | | calculateExport.setNum(list.stream().mapToInt(CalculateExport::getNum).sum()); |
| | | calculateExport.setScore(100 + list.stream().mapToInt(CalculateExport::getScore).sum()); |
| | | |
| | | calculateExport.setScore(list.stream() |
| | | .map(CalculateExport::getScore) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) // 计算总和 |
| | | .add(BigDecimal.valueOf(100)) // 加上100 |
| | | .setScale(1, RoundingMode.HALF_UP)); |
| | | list.add(calculateExport); |
| | | // 获取规则 |
| | | List<CalculateRule> ruleList = calculateRuleService.list(new LambdaQueryWrapper<CalculateRule>().eq(CalculateRule::getContractId, contractId)); |