Commit 8d99c75b authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.6.11' into MVP1.6.11

parents db07d61f 061d8c98
......@@ -12,7 +12,6 @@ import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* 风险管控统计
......@@ -33,6 +32,12 @@ public class TRiskMonitor extends BaseEntity {
@Schema(description = "主键")
private String id;
/**
* 项目id
*/
@Schema(description ="项目id")
private String deptId;
/**
* 结算主体名称
*/
......@@ -180,7 +185,7 @@ public class TRiskMonitor extends BaseEntity {
@ExcelAttribute(name = "最后一次发薪日期", isDate = true)
@ExcelProperty("最后一次发薪日期")
@Schema(description = "最后一次发薪日期")
private Date lastSalaryTime;
private String lastSalaryTime;
/**
* 所属客户名称
......
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 风险管控比例
*
* @author huyc
* @date 2024-09-27 15:54:40
*/
@Data
@ColumnWidth(30)
public class RiskMonitorPerVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总项目数
*/
@Schema(description = "总项目数")
private String deptNum;
/**
* 存在风险项目数
*/
@Schema(description = "存在风险项目数")
private String riskDeptNum;
/**
* 存在风险项目占比
*/
@Schema(description = "存在风险项目占比")
private String riskDeptPer;
/**
* 商险漏买项目数
*/
@Schema(description = "商险漏买项目数")
private String riskInsuraceNum;
/**
* 商险漏买项目占比
*/
@Schema(description = "商险漏买占比")
private String riskInsuracePer;
}
......@@ -21,7 +21,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 风险管控统计
......@@ -32,12 +31,6 @@ import java.util.List;
@Data
public class TRiskMonitorSearchVo extends TRiskMonitor {
/**
* 多选导出或删除等操作
*/
@Schema(description = "选中ID,id数组")
private List<String> idList;
/**
* 创建时间区间 [开始时间,结束时间]
*/
......
......@@ -7,6 +7,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.service.TRiskMonitorService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
......@@ -38,7 +39,6 @@ public class TRiskMonitorController {
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('archives_triskmonitor_get')")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('archives_triskmonitor_get')")
public R<TRiskMonitor> getById(@PathVariable("id") String id) {
return R.ok(tRiskMonitorService.getById(id));
}
......@@ -92,8 +92,30 @@ public class TRiskMonitorController {
**/
@Operation(description = "导出风险管控统计 hasPermission('archives_triskmonitor-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('archives_triskmonitor-export')")
public void export(HttpServletResponse response, @RequestBody TRiskMonitorSearchVo searchVo) {
tRiskMonitorService.listExport(response, searchVo);
}
/**
* 风险管控统计 批量生成
* @author huyc
* @date 2024-09-27 14:08:58
**/
@Operation(description = "生成风险管控统计")
@Inner
@PostMapping("/inner/createRiskMonitor")
public void createRiskMonitor(){
tRiskMonitorService.createRiskMonitor();
}
/**
* 查询风险占比
* @author huyc
* @date 2024-06-17 16:08:58
**/
@Operation(description = "查询风险占比")
@PostMapping("/selectCurrentRiskMonitor")
public R selectCurrentRiskMonitor(@RequestBody TRiskMonitorSearchVo tRiskMonitor) {
return tRiskMonitorService.selectCurrentRiskMonitor(tRiskMonitor);
}
}
......@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TRiskMonitor;
import com.yifu.cloud.plus.v1.yifu.archives.vo.RiskMonitorPerVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -37,5 +39,17 @@ public interface TRiskMonitorMapper extends BaseMapper<TRiskMonitor> {
* @param tRiskMonitor 风险管控统计
* @return
*/
List<TRiskMonitor> getRiskMonitorExportList(@Param("tRiskMonitor") TRiskMonitorSearchVo tRiskMonitor);
List<TRiskMonitorVo> getRiskMonitorExportList(@Param("tRiskMonitor") TRiskMonitorSearchVo tRiskMonitor);
/**
* 风险管控统计导出查询
* @return
*/
List<TRiskMonitor> selectRiskMonitorList();
/**
* 查询风险占比
* @return
*/
RiskMonitorPerVo getTRiskMonitorPer(@Param("tRiskMonitor") TRiskMonitorSearchVo tRiskMonitor);
}
......@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TRiskMonitor;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
......@@ -46,4 +47,17 @@ public interface TRiskMonitorService extends IService<TRiskMonitor> {
*/
void listExport(HttpServletResponse response, TRiskMonitorSearchVo searchVo);
/**
* 生成管控统计
* @return
*/
void createRiskMonitor();
/**
* 查询风险占比
* @return
*/
R selectCurrentRiskMonitor(TRiskMonitorSearchVo tRiskMonitor);
}
......@@ -4,22 +4,29 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TRiskMonitor;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TRiskMonitorMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TRiskMonitorService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.RiskMonitorPerVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
......@@ -32,7 +39,11 @@ import java.util.List;
*/
@Log4j2
@Service
@RequiredArgsConstructor
public class TRiskMonitorServiceImpl extends ServiceImpl<TRiskMonitorMapper, TRiskMonitor> implements TRiskMonitorService {
private final MenuUtil menuUtil;
/**
* 风险管控统计简单分页查询
*
......@@ -41,29 +52,41 @@ public class TRiskMonitorServiceImpl extends ServiceImpl<TRiskMonitorMapper, TRi
*/
@Override
public IPage<TRiskMonitor> getTRiskMonitorPage(Page<TRiskMonitor> page, TRiskMonitorSearchVo tRiskMonitor) {
YifuUser user = SecurityUtils.getUser();
long roleId = 1839501715787390978L;
boolean isSsc = this.haveRole(user, roleId);
if (!isSsc) {
menuUtil.setAuthSql(user, tRiskMonitor);
}
return baseMapper.getTRiskMonitorPage(page, tRiskMonitor);
}
/**
* 风险管控统计批量导出
*
* @param searchVo 风险管控统计
* @return
*/
@Override
public void listExport(HttpServletResponse response, TRiskMonitorSearchVo searchVo) {
String fileName = "风险管控统计批量导出" + DateUtil.getThisTime() + ".xlsx";
YifuUser user = SecurityUtils.getUser();
long roleId = 1839501715787390978L;
boolean isSsc = this.haveRole(user, roleId);
if (!isSsc) {
menuUtil.setAuthSql(user, searchVo);
}
String fileName = "运营风险管控" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<TRiskMonitor> list = new ArrayList<>();
List<TRiskMonitorVo> list = new ArrayList<>();
//获取要导出的数量
long count = baseMapper.getTRiskMonitorExportCount(searchVo);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
try(ServletOutputStream out = response.getOutputStream()) {
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, TRiskMonitor.class).build();
ExcelWriter excelWriter = EasyExcel.write(out, TRiskMonitorVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
......@@ -71,12 +94,6 @@ public class TRiskMonitorServiceImpl extends ServiceImpl<TRiskMonitorMapper, TRi
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT);
list = baseMapper.getRiskMonitorExportList(searchVo);
if (Common.isNotNull(list)) {
ExcelUtil<TRiskMonitor> util = new ExcelUtil<>(TRiskMonitor.class);
for (TRiskMonitor vo : list) {
util.convertEntity(vo, null, null, null);
}
}
if (Common.isNotNull(list)) {
WriteSheet writeSheet = EasyExcel.writerSheet("运营风险管控" + index).build();
excelWriter.write(list, writeSheet);
......@@ -97,14 +114,49 @@ public class TRiskMonitorServiceImpl extends ServiceImpl<TRiskMonitorMapper, TRi
excelWriter.finish();
} catch (Exception e) {
log.error("执行异常", e);
} finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
/**
* 风险管控统计批量生成
* @return
*/
@Override
public void createRiskMonitor() {
//批量删除之前生成的管控统计
baseMapper.delete(Wrappers.<TRiskMonitor>query().lambda()
.eq(TRiskMonitor::getDeleteFlag, CommonConstants.ZERO_STRING));
//批量生成统计数据
List<TRiskMonitor> list = baseMapper.selectRiskMonitorList();
if (!list.isEmpty()) {
this.saveBatch(list);
}
}
/**
* 查询风险占比
* @return
*/
@Override
public R selectCurrentRiskMonitor(TRiskMonitorSearchVo tRiskMonitor) {
YifuUser user = SecurityUtils.getUser();
long roleId = 1839501715787390978L;
boolean isSsc = this.haveRole(user, roleId);
if (!isSsc) {
menuUtil.setAuthSql(user, tRiskMonitor);
}
RiskMonitorPerVo RiskMonitorPerVo = baseMapper.getTRiskMonitorPer(tRiskMonitor);
return R.ok(RiskMonitorPerVo);
}
public boolean haveRole(YifuUser user, long roleId) {
List<Long> roleList = user.getClientRoleMap().get(ClientNameConstants.CLIENT_MVP);
for (Long role : roleList) {
if (role == roleId) {
return true;
}
}
return false;
}
}
......@@ -84,4 +84,13 @@ public class ArchiveTask {
SecurityConstants.FROM_IN);
log.info("-------------每日刷新档案完整监控数据-定时任务开始------------");
}
public void everyDayCreateRiskMonitor() {
log.info("-------------每日刷新运营风险管控数据------------");
HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
"/triskmonitor/inner/createRiskMonitor", "", Object.class,
SecurityConstants.FROM_IN);
log.info("-------------每日刷新运营风险管控数据-定时任务开始------------");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment