流量不足提醒

This commit is contained in:
钱涛 2023-08-28 15:19:57 +08:00
parent b5f9477c90
commit 1b4c9ce7a7
9 changed files with 452 additions and 11 deletions

View File

@ -0,0 +1,13 @@
package com.api.salary.web;
import javax.ws.rs.Path;
/**
* 智能算薪-计费
*
* @author chengliming
* @date 2022-11-15 16:05:40
*/
@Path("/bs/hrmsalary/taxdeclaration/apiflow/statistics")
public class TaxDeclarationApiFlowStatisticController extends com.engine.salary.web.TaxDeclarationApiFlowStatisticController {
}

View File

@ -0,0 +1,13 @@
package com.api.salary.web;
import javax.ws.rs.Path;
/**
* 智能算薪-流量不足提醒
*
* @author chengliming
* @date 2022-11-15 16:05:40
*/
@Path("/bs/hrmsalary/taxdeclaration/apiflow/warn")
public class TaxDeclarationApiFlowWarnController extends com.engine.salary.web.TaxDeclarationApiFlowWarnController {
}

View File

@ -23,10 +23,9 @@ public interface TaxDeclarationApiFlowWarnService {
/**
* 获取流量不足提醒设置
*
* @param currentTenantKey
* @return
*/
TaxDeclarationApiFlowWarnConfigPO getWarnConfig(String currentTenantKey);
TaxDeclarationApiFlowWarnConfigPO getWarnConfig();
/**
* 获取流量不足提醒对象列表
@ -76,10 +75,9 @@ public interface TaxDeclarationApiFlowWarnService {
/**
* 获取推送规则的业务ID
*
* @param currentTenantKey
* @return
*/
Long getRuleBusinessId(String currentTenantKey);
Long getRuleBusinessId();
/**
* 发送提醒

View File

@ -61,7 +61,7 @@ public class TaxDeclarationApiFlowWarnServiceImpl extends Service implements Tax
}
@Override
public TaxDeclarationApiFlowWarnConfigPO getWarnConfig(String currentTenantKey) {
public TaxDeclarationApiFlowWarnConfigPO getWarnConfig() {
return getTaxDeclarationApiFlowWarnConfigMapper().getOne();
}
@ -206,14 +206,14 @@ public class TaxDeclarationApiFlowWarnServiceImpl extends Service implements Tax
}
@Override
public Long getRuleBusinessId(String currentTenantKey) {
TaxDeclarationApiFlowWarnConfigPO warnConfig = this.getWarnConfig(currentTenantKey);
public Long getRuleBusinessId() {
TaxDeclarationApiFlowWarnConfigPO warnConfig = this.getWarnConfig();
return warnConfig == null ? IdGenerator.generate() : warnConfig.getBusinessId();
}
@Override
public void sendFlowWarnMessage(TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper updateWrapper) {
TaxDeclarationApiFlowWarnConfigPO warnConfig = getWarnConfig(updateWrapper.getTenantKey());
TaxDeclarationApiFlowWarnConfigPO warnConfig = getWarnConfig();
// 未配置或开关关闭
if (Objects.isNull(warnConfig) || SalaryOnOffEnum.OFF.getValue().equals(warnConfig.getEnableWarn())) {
return;

View File

@ -0,0 +1,101 @@
package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticDetailListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticListDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.TaxDeclarationApiFlowStatisticWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* 智能算薪-计费
*
* @author chengliming
* @date 2022-11-15 16:05:40
*/
public class TaxDeclarationApiFlowStatisticController {
private TaxDeclarationApiFlowStatisticWrapper getTaxDeclarationApiFlowStatisticWrapper(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowStatisticWrapper.class, user);
}
// /**
// * 接口流量统计
// *
// * @return WeaResult 返回结果
// */
// @Path
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public WeaResult<TaxDeclarationApiFlowTotalDTO> getFlowStatistics() {
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.getFlowStatistics(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId()));
// }
/**
* 接口流量使用明细
*
* @param queryParam 查询条件
* @return WeaResult 返回结果
*/
@POST
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String getFlowStatisticsList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody BaseQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<BaseQueryParam, PageInfo<TaxDeclarationApiFlowStatisticListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsList, queryParam);
}
// /**
// * 导出接口流量使用明细
// *
// * @return WeaResult 返回结果
// */
// @Path("/export")
// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public String exportFlowStatistics(@Context HttpServletRequest request, @Context HttpServletResponse response) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<BaseQueryParam, PageInfo<TaxDeclarationApiFlowStatisticListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsList, queryParam);
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.exportFlowStatistics(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
/**
* 接口流量月度使用明细
*
* @param queryParam 查询条件
* @return WeaResult 返回结果
*/
@POST
@Path("/detail/list")
@Produces(MediaType.APPLICATION_JSON)
public String getFlowStatisticsDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowMonthQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxDeclarationApiFlowMonthQueryParam, PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsDetail, queryParam);
}
// /**
// * 导出接口流量使用明细
// *
// * @param queryParam 查询条件
// * @return WeaResult 返回结果
// */
// @Path("/detail/export")
// @ApiOperation("导出接口流量使用明细")
// @Produces(MediaType.APPLICATION_JSON)
// public WeaResult<?> exportFlowStatisticsDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowMonthQueryParam queryParam) {
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.exportFlowStatisticsDetail(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
}

View File

@ -0,0 +1,146 @@
package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnConfigFormDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverListDTO;
import com.engine.salary.entity.taxapiflow.param.CreateMessageRuleParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnConfigSaveParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.wrapper.TaxDeclarationApiFlowWarnWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* 智能算薪-流量不足提醒
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class TaxDeclarationApiFlowWarnController {
private TaxDeclarationApiFlowWarnWrapper getTaxDeclarationApiFlowWarnWrapper(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowWarnWrapper.class, user);
}
/**
* 流量不足提醒表单
*
* @return WeaResult 返回结果
*/
@GET
@Path("/config/getForm")
@Produces(MediaType.APPLICATION_JSON)
public String getWarnConfigForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<BaseQueryParam, TaxDeclarationApiFlowWarnConfigFormDTO>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::getWarnConfigForm);
}
/**
* 流量不足提醒编辑或保存
*
* @param param 保存参数
* @return WeaResult 返回结果
*/
@POST
@Path("/config/save")
@Produces(MediaType.APPLICATION_JSON)
public String saveWarnConfig(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowWarnConfigSaveParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxDeclarationApiFlowWarnConfigSaveParam, String>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::saveWarnConfig, param);
}
/**
* 流量不足提醒对象编辑表单
*
* @param param 前端参数
* @return WeaResult 返回结果
*/
@POST
@Path("/receiver/getForm")
@Produces(MediaType.APPLICATION_JSON)
public String getWarnReceiverForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowWarnReceiverSaveParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxDeclarationApiFlowWarnReceiverSaveParam, String>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::getWarnReceiverForm, param);
}
/**
* 编辑保存流量不足提醒对象
*
* @param param 保存参数
* @return WeaResult 返回结果
*/
@POST
@Path("/receiver/save")
@Produces(MediaType.APPLICATION_JSON)
public String saveWarnReceiver(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowWarnReceiverSaveParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxDeclarationApiFlowWarnReceiverSaveParam, String>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::saveWarnReceiver, param);
}
/**
* 流量不足提醒对象列表
*
* @param warnConfigId 主键id
* @return WeaResult 返回结果
*/
@GET
@Path("/receiver/list")
@Produces(MediaType.APPLICATION_JSON)
public String getWarnReceiverList(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "warnConfigId") Long warnConfigId) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, List<TaxDeclarationApiFlowWarnReceiverListDTO>>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::getWarnReceiverList, warnConfigId);
}
/**
* 流量不足提醒对象-删除
*
* @param id 主键id
* @return WeaResult 返回结果
*/
@GET
@Path("/receiver/delete")
@Produces(MediaType.APPLICATION_JSON)
public String deleteReceiver(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, String>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::deleteReceiver, id);
}
/**
* 获取创建规则参数
* @param request
* @param response
* @return
*/
@GET
@Path("/rule/params")
@Produces(MediaType.APPLICATION_JSON)
public String getMessageRuleParams(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, Long>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::getRuleBusinessId);
}
/**
* 创建规则
*
* @param param 前端参数
* @return WeaResult 返回结果
*/
@POST
@Path("/rule/create")
@Produces(MediaType.APPLICATION_JSON)
public String createMessageRule(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CreateMessageRuleParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<CreateMessageRuleParam, Long>(user).run(getTaxDeclarationApiFlowWarnWrapper(user)::createMessageRule, param);
}
}

View File

@ -53,9 +53,8 @@ public class TaxDeclarationApiFlowBillingWrapper extends Service {
}
public PageInfo<TaxDeclarationApiFlowRecordListDTO> getFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
// PageInfo<TaxDeclarationApiFlowRecordListDTO> page = getTaxDeclarationApiBillingService(user).pageFlowRecord(queryParam);
// return page;
return null;
PageInfo<TaxDeclarationApiFlowRecordListDTO> page = getTaxDeclarationApiBillingService(user).pageFlowRecord(queryParam);
return page;
}
// public Map<String, Object> exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Long employeeId, String tenantKey) {

View File

@ -0,0 +1,85 @@
package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticDetailListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowTotalDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.service.TaxDeclarationApiFlowStatisticService;
import com.engine.salary.service.impl.TaxDeclarationApiFlowStatisticServiceImpl;
import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
/**
* 个税申报计费
*
* @author chengliming
* @date 2022-11-11 15:16:22
*/
@Slf4j
public class TaxDeclarationApiFlowStatisticWrapper extends Service {
public TaxDeclarationApiFlowStatisticService getTaxDeclarationApiFlowStatisticService(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowStatisticServiceImpl.class, user);
}
public TaxDeclarationApiFlowTotalDTO getFlowStatistics() {
return getTaxDeclarationApiFlowStatisticService(user).getFlowStatistics();
}
public PageInfo<TaxDeclarationApiFlowStatisticListDTO> getFlowStatisticsList(BaseQueryParam queryParam) {
PageInfo<TaxDeclarationApiFlowStatisticListDTO> page = getTaxDeclarationApiFlowStatisticService(user).pageFlowStatistics(queryParam);
return page;
}
public PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO> getFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) {
PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO> page = getTaxDeclarationApiFlowStatisticService(user).pageFlowStatisticsDetail(queryParam);
return page;
}
// public Map<String, Object> exportFlowStatistics(Long employeeId, String tenantKey) {
// List<TaxDeclarationApiFlowStatisticListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatistic(tenantKey, employeeId);
// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportFlowStatistics");
// map.put("sheetName", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 184066, "接口流量统计数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getTaxDeclarationApiFlowStatisticService(user).exportFlowStatistics(map, dtoList, employeeId, tenantKey);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
//
// public Map<String, Object> exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Long employeeId, String tenantKey) {
// List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatisticDetail(queryParam, employeeId, tenantKey);
// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportFlowStatisticsDetail");
// map.put("sheetName", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 184067, "接口流量月统计数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getTaxDeclarationApiFlowStatisticService(user).exportFlowStatisticsDetail(queryParam, map, dtoList, employeeId, tenantKey);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
}

View File

@ -0,0 +1,86 @@
package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnConfigFormDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverFormDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowWarnReceiverListDTO;
import com.engine.salary.entity.taxapiflow.param.CreateMessageRuleParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnConfigSaveParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowWarnReceiverSaveParam;
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowWarnConfigPO;
import com.engine.salary.enums.SalaryOnOffEnum;
import com.engine.salary.service.TaxDeclarationApiFlowWarnService;
import com.engine.salary.service.impl.TaxDeclarationApiFlowWarnServiceImpl;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
import java.util.List;
/**
* 流量不足提醒
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Slf4j
public class TaxDeclarationApiFlowWarnWrapper extends Service {
public TaxDeclarationApiFlowWarnService getTaxDeclarationApiFlowWarnService(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowWarnServiceImpl.class, user);
}
public TaxDeclarationApiFlowWarnConfigFormDTO getWarnConfigForm() {
Long businessId = getTaxDeclarationApiFlowWarnService(user).getRuleBusinessId();
TaxDeclarationApiFlowWarnConfigFormDTO warnFormDTO = TaxDeclarationApiFlowWarnConfigFormDTO.builder()
.enable(false)
.moduleId("hrsa")
.businessId(businessId)
.build();
TaxDeclarationApiFlowWarnConfigPO warnConfigPO = getTaxDeclarationApiFlowWarnService(user).getWarnConfig();
if (warnConfigPO != null) {
warnFormDTO.setId(warnConfigPO.getId());
warnFormDTO.setEnable(SalaryOnOffEnum.ON.getValue().equals(warnConfigPO.getEnableWarn()));
warnFormDTO.setThreshold(warnConfigPO.getThreshold().intValue());
warnFormDTO.setBusinessId(warnConfigPO.getBusinessId());
warnFormDTO.setConfig(null);
}
return warnFormDTO;
}
public String saveWarnConfig(TaxDeclarationApiFlowWarnConfigSaveParam param) {
return getTaxDeclarationApiFlowWarnService(user).saveWarnConfig(param);
}
public List<TaxDeclarationApiFlowWarnReceiverListDTO> getWarnReceiverList(Long warnConfigId) {
List<TaxDeclarationApiFlowWarnReceiverListDTO> receiverListDTOS = getTaxDeclarationApiFlowWarnService(user).getWarnReceiverList(warnConfigId);
return receiverListDTOS;
}
public void deleteReceiver(Long id) {
getTaxDeclarationApiFlowWarnService(user).deleteReceiver(id);
}
public TaxDeclarationApiFlowWarnReceiverFormDTO getWarnReceiverForm(TaxDeclarationApiFlowWarnReceiverSaveParam param) {
TaxDeclarationApiFlowWarnReceiverFormDTO formDTO = TaxDeclarationApiFlowWarnReceiverFormDTO.builder().build();
if (param.getId() != null) {
formDTO = getTaxDeclarationApiFlowWarnService(user).getWarnReceiverFormById(param.getId());
}
return formDTO;
}
public void saveWarnReceiver(TaxDeclarationApiFlowWarnReceiverSaveParam param) {
getTaxDeclarationApiFlowWarnService(user).saveWarnReceiver(param);
}
public void createMessageRule(CreateMessageRuleParam param) {
getTaxDeclarationApiFlowWarnService(user).createMessageRule(param);
}
public Long getRuleBusinessId() {
return getTaxDeclarationApiFlowWarnService(user).getRuleBusinessId();
}
}