@@ -0,0 +1,205 @@ | |||
package com.qtzl.alterSales.dao.entity.second.logs; | |||
import cn.com.taiji.common.entity.StringUUIDEntity; | |||
import com.qtzl.alterSales.manager.enums.HandleStatus; | |||
import javax.persistence.*; | |||
import java.time.LocalDateTime; | |||
@Entity | |||
@Table(name="AFL_INTERFACE_LOG") | |||
public class AflInterfaceLog extends StringUUIDEntity { | |||
//员工编号 | |||
private String staffId; | |||
//发行方编号 | |||
private String agencyId; | |||
//网点编号 | |||
private String channelId; | |||
//渠道类型 | |||
private Integer channelType; | |||
//网点编号 | |||
private String submitTime; | |||
//访问ipR | |||
private String fileName; | |||
//访问ipR | |||
private String ip; | |||
//服务器ip | |||
private String serverIp; | |||
//接口类型 | |||
private String serviceType; | |||
//处理日期 | |||
private String handleDate; | |||
private String handleTime; | |||
private String requestStr; | |||
//处理结果 | |||
private HandleStatus handleStatus; | |||
//描述 | |||
private String responseStr; | |||
//录入时间 | |||
private LocalDateTime createTime; | |||
//录入时间 | |||
private LocalDateTime updateTime; | |||
// 程序异常 | |||
private String exceptionTrace; | |||
//分区字段 | |||
private Integer pdd; | |||
@Column(name = "STAFF_ID") | |||
public String getStaffId() { | |||
return staffId; | |||
} | |||
public void setStaffId(String staffId) { | |||
this.staffId = staffId; | |||
} | |||
@Column(name = "AGENCY_ID") | |||
public String getAgencyId() { | |||
return agencyId; | |||
} | |||
public void setAgencyId(String agencyId) { | |||
this.agencyId = agencyId; | |||
} | |||
@Column(name = "CHANNEL_ID") | |||
public String getChannelId() { | |||
return channelId; | |||
} | |||
public void setChannelId(String channelId) { | |||
this.channelId = channelId; | |||
} | |||
@Column(name = "CHANNEL_TYPE") | |||
public Integer getChannelType() { | |||
return channelType; | |||
} | |||
public void setChannelType(Integer channelType) { | |||
this.channelType = channelType; | |||
} | |||
@Column(name = "SUBMIT_TIME") | |||
public String getSubmitTime() { | |||
return submitTime; | |||
} | |||
public void setSubmitTime(String submitTime) { | |||
this.submitTime = submitTime; | |||
} | |||
public String getIp() { | |||
return ip; | |||
} | |||
public void setIp(String ip) { | |||
this.ip = ip; | |||
} | |||
@Column(name = "REQUEST_STR") | |||
public String getRequestStr() { | |||
return requestStr; | |||
} | |||
public void setRequestStr(String requestStr) { | |||
this.requestStr = requestStr; | |||
} | |||
@Column(name = "RESPONSE_STR") | |||
public String getResponseStr() { | |||
return responseStr; | |||
} | |||
public void setResponseStr(String responseStr) { | |||
this.responseStr = responseStr; | |||
} | |||
@Column(name = "FILE_NAME") | |||
public String getFileName() { | |||
return fileName; | |||
} | |||
public void setFileName(String fileName) { | |||
this.fileName = fileName; | |||
} | |||
@Column(name = "UPDATE_TIME") | |||
public LocalDateTime getUpdateTime() { | |||
return updateTime; | |||
} | |||
public void setUpdateTime(LocalDateTime updateTime) { | |||
this.updateTime = updateTime; | |||
} | |||
@Column(name = "SERVICE_TYPE") | |||
public String getServiceType() { | |||
return serviceType; | |||
} | |||
public void setServiceType(String serviceType) { | |||
this.serviceType = serviceType; | |||
} | |||
@Enumerated(EnumType.STRING) | |||
@Column(name = "HANDLE_STATUS") | |||
public HandleStatus getHandleStatus() { | |||
return handleStatus; | |||
} | |||
public void setHandleStatus(HandleStatus handleStatus) { | |||
this.handleStatus = handleStatus; | |||
} | |||
@Column(name = "HANDLE_TIME") | |||
public String getHandleTime() { | |||
return handleTime; | |||
} | |||
public void setHandleTime(String handleTime) { | |||
this.handleTime = handleTime; | |||
} | |||
@Column(name = "HANDLE_DATE") | |||
public String getHandleDate() { | |||
return handleDate; | |||
} | |||
public void setHandleDate(String handleDate) { | |||
this.handleDate = handleDate; | |||
} | |||
@Column(name = "CREATE_TIME") | |||
public LocalDateTime getCreateTime() { | |||
return createTime; | |||
} | |||
public void setCreateTime(LocalDateTime createTime) { | |||
this.createTime = createTime; | |||
} | |||
@Column(name = "P_DD") | |||
public Integer getPdd() { | |||
return pdd; | |||
} | |||
public void setPdd(Integer pdd) { | |||
this.pdd = pdd; | |||
} | |||
@Column(name = "EXCEPTION_TRACE") | |||
public String getExceptionTrace() { | |||
return exceptionTrace; | |||
} | |||
public void setExceptionTrace(String exceptionTrace) { | |||
this.exceptionTrace = exceptionTrace; | |||
} | |||
@Column(name = "SERVER_IP") | |||
public String getServerIp() { | |||
return serverIp; | |||
} | |||
public void setServerIp(String serverIp) { | |||
this.serverIp = serverIp; | |||
} | |||
} | |||
@@ -2,6 +2,7 @@ package com.qtzl.alterSales.dao.repo.jpa.primary.page; | |||
import com.qtzl.alterSales.dao.entity.primary.FssPaccountRefund; | |||
import com.qtzl.alterSales.dao.entity.primary.RefundConfig; | |||
import com.qtzl.alterSales.dao.entity.second.logs.AflInterfaceLog; | |||
import com.qtzl.alterSales.dao.entity.second.refund.RefundStats; | |||
import org.springframework.data.jpa.domain.Specification; | |||
import org.springframework.util.ObjectUtils; | |||
@@ -137,4 +138,33 @@ public class FssPaccountRefundSpecifications { | |||
public static Specification<RefundStats> withRefundStatsTime(LocalDateTime beginTime, LocalDateTime endTime) { | |||
return (root, query, criteriaBuilder) -> criteriaBuilder.between(root.get("insertTime"), beginTime, endTime); | |||
} | |||
// 退款统计渠道编号 | |||
public static Specification<AflInterfaceLog> withStaffId(String staffId) { | |||
if (ObjectUtils.isEmpty(staffId)) { | |||
return null; | |||
} | |||
return (root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("staffId"), staffId); | |||
} | |||
public static Specification<AflInterfaceLog> withServiceType(String serviceType) { | |||
if (ObjectUtils.isEmpty(serviceType)) { | |||
return null; | |||
} | |||
return (root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("serviceType"), serviceType); | |||
} | |||
public static Specification<AflInterfaceLog> withHandleStatus(String handleStatus) { | |||
if (ObjectUtils.isEmpty(handleStatus)) { | |||
return null; | |||
} | |||
return (root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("handleStatus"), handleStatus); | |||
} | |||
// 退款约束时间范围 | |||
public static Specification<AflInterfaceLog> withCreateTime(LocalDateTime beginTime, LocalDateTime endTime) { | |||
return (root, query, criteriaBuilder) -> criteriaBuilder.between(root.get("createTime"), beginTime, endTime); | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
package com.qtzl.alterSales.dao.repo.jpa.second.logs; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import com.qtzl.alterSales.dao.entity.second.logs.AflInterfaceLog; | |||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | |||
/** | |||
* @author lihao | |||
*/ | |||
public interface AflInterfaceLogRepo extends AbstractJpaRepo<AflInterfaceLog, String> , JpaSpecificationExecutor<AflInterfaceLog> { | |||
} | |||
@@ -0,0 +1,128 @@ | |||
package com.qtzl.alterSales.manager.enums; | |||
import org.springframework.util.ObjectUtils; | |||
/** | |||
* eclipse_afl 接口 如后续afl服务有新增接口 请更新 | |||
* lh | |||
*/ | |||
public enum AflServiceType { | |||
/** | |||
* 发送短信验证码 | |||
*/ | |||
SENDMSGBYLOGIN("发送短信验证码", "SENDMSGBYLOGIN"), | |||
SSOLOGIN("手机号加短信验证码登录", "SSOLOGIN"), | |||
UNITLOGIN("网点业务员登录", "UNITLOGIN"), | |||
CREITUSER("个人证件开户", "CREITUSER"), | |||
PSSISSUECPULOADAPPLY("OBE-IC 圈存", "PSSISSUECPULOADAPPLY"), | |||
PSSISSUECPUISSUERESULT("OBE-IC 卡发行成功", "PSSISSUECPUISSUERESULT"), | |||
PSSAFTERSALEVEHICLELOST("ETC 挂失", "PSSAFTERSALEVEHICLELOST"), | |||
PSSAFTERSALEVEHICLEFIND("ETC 解挂", "PSSAFTERSALEVEHICLEFIND"), | |||
PSSAFTERSALEOBUACTIVE("标签激活", "PSSAFTERSALEOBUACTIVE"), | |||
PSSAFTERSALEOBUCHANGE("标签更换", "PSSAFTERSALEOBUCHANGE"), | |||
PSSAFTERSALEVEHICLE("车辆报废", "PSSAFTERSALEVEHICLE"), | |||
PSSAFTERSALETRANSFER("过户", "PSSAFTERSALETRANSFER"), | |||
PSSAFTERSALESTOPUSE("停用", "PSSAFTERSALESTOPUSE"), | |||
PSSAFTERSALEENABLEUSE("启用", "PSSAFTERSALEENABLEUSE"), | |||
PSSISSUEMODIFYUSERINFO("个人用户信息变更", "PSSISSUEMODIFYUSERINFO"), | |||
PSSISSUEMODIFYCOMPANYINFO("单位用户信息变更", "PSSISSUEMODIFYCOMPANYINFO"), | |||
PSSISSUEMODIFYVEHICLEINFO("车辆信息变更", "PSSISSUEMODIFYVEHICLEINFO"), | |||
PSSCERTIFYPERSONALUSER("身份信息认证", "PSSCERTIFYPERSONALUSER"), | |||
PSSCERTIFYCOMPANYUSER("企业信息认证", "PSSCERTIFYCOMPANYUSER"), | |||
PSSSSOREFRESH("刷新接口调用凭证", "PSSSSOREFRESH"), | |||
PSSUSERINFO("获取基本信息", "PSSUSERINFO"), | |||
PSSUSERACCOUNTLIST("获取用户列表", "PSSUSERACCOUNTLIST"), | |||
PSSUSERVEHICLEPAGE("获取车辆列表", "PSSUSERVEHICLEPAGE"), | |||
PSSUSERQUERY("获取车辆信息", "PSSUSERQUERY"), | |||
PSSUSEROBU("获取OBU信息", "PSSUSEROBU"), | |||
PSSUSERCARD("获取卡信息", "PSSUSERCARD"), | |||
PSSUSERTRAFFICRECORD("通行记录查询", "PSSUSERTRAFFICRECORD"), | |||
CERTIFYVEHICLELICENSE("行驶证认证", "CERTIFYVEHICLELICENSE"), | |||
CERTIFYCREITCOMPANY("企业证件开户申请", "CERTIFYCREITCOMPANY"), | |||
ISSUEDRIVERNUM("车主身份证信息上传", "ISSUEDRIVERNUM"), | |||
CERTIFYAGENTMATERIAL("经办人证件信息上传", "CERTIFYAGENTMATERIAL"), | |||
CERTIFYVEHICLEMATERIAL("车辆证件信息上传", "CERTIFYVEHICLEMATERIAL"), | |||
CERTIFYVERIFYLIST("车户审核列表查询", "CERTIFYVERIFYLIST"), | |||
ACCOUNTCHANNELLIST("获取可签约渠道列表", "ACCOUNTCHANNELLIST"), | |||
ACCOUNTSIGNCHANNEL("签约", "ACCOUNTSIGNCHANNEL"), | |||
ACCOUNTSIGNCHANNELLIST("获取已签约渠道列表", "ACCOUNTSIGNCHANNELLIST"), | |||
ACCOUNTCHANNELREL("车辆支付渠道关联", "ACCOUNTCHANNELREL"), | |||
ACCOUNTRELLIST("车辆支付渠道关联记录", "ACCOUNTRELLIST"), | |||
OCRIDCARD("身份证信息识别", "OCRIDCARD"), | |||
OCRVEHICLELICENSE("行驶证信息识别", "OCRVEHICLELICENSE"), | |||
PSSISSUEPLATECHECK("车牌发行验证", "PSSISSUEPLATECHECK"), | |||
PSSISSUESTATUS("车辆发行状态查询", "PSSISSUESTATUS"), | |||
PSSISSUEPRODUCT("获取发行服务机构产品列表", "PSSISSUEPRODUCT"), | |||
PSSISSUECARACTIVEINFO("获取车型激活指导列表", "PSSISSUECARACTIVEINFO"), | |||
PSSISSUEOBUISSUE("OBE-SAM 发行前校验", "PSSISSUEOBUISSUE"), | |||
PSSISSUEOBUISSUEMFEF01("OBE-SAM 写系统信息", "PSSISSUEOBUISSUEMFEF01"), | |||
PSSISSUEOBUISSUEDFEF01("OBE-SAM 写车辆信息", "PSSISSUEOBUISSUEDFEF01"), | |||
PSSISSUEOBUPLATEDATA("OBE-SAM 车辆信息解密", "PSSISSUEOBUPLATEDATA"), | |||
PSSISSUEOBUISSUERESULT("OBE-SAM 激活成功", "PSSISSUEOBUISSUERESULT"), | |||
PSSISSUECPUISSUED("OBE-IC 卡发行前校验", "PSSISSUECPUISSUED"), | |||
PSSISSUEWRITE0015("OBE-IC 卡写 0015 文件", "PSSISSUEWRITE0015"), | |||
PSSISSUEWRITE0016("OBE-IC 卡写 0016 文件", "PSSISSUEWRITE0016"), | |||
CERTIFYVEHICLELICENSEV2("行驶证认证前参数校验", "CERTIFYVEHICLELICENSEV2"), | |||
REFRESHTOKENTEST("刷新TOKEN测试", "REFRESHTOKENTEST"), | |||
AFLCARDINFOQUERY("根据车辆ID或卡号查询 etc卡信息", "AFLCARDINFOQUERY"), | |||
PSSUNITDICTSELECTCHANNEL("获取 ETC 取消原因枚举", "PSSUNITDICTSELECTCHANNEL"), | |||
PSSUSERUSERETCCANCELADD("取消 ETC 订单提交", "PSSUSERUSERETCCANCELADD"), | |||
WECHATQUERTUSERSTATE("查询用户状态。 直接调用微信车主服务-用户状态查询", "WECHATQUERTUSERSTATE"), | |||
USERAGREEMENTQUERY("用户协议查询-通过车型", "USERAGREEMENTQUERY"), | |||
USERLOGININFOBYMOBILE("用户登录日志-根据手机号查询", "USERLOGININFOBYMOBILE"), | |||
CLICKLOG("点击事件日志", "CLICKLOG"), | |||
STAYLOG("页面停留事件日志", "STAYLOG"), | |||
CALCULATETYPEKIND("车型计算服务", "CALCULATETYPEKIND"), | |||
PSSISSUECMDAPPLY("发行指令申请", "PSSISSUECMDAPPLY"), | |||
PSSISSUECMDCALLBACK("发行指令回传", "PSSISSUECMDCALLBACK"), | |||
DEVICEINFO("根据车辆编号查询卡签信息", "DEVICEINFO"), | |||
DEVICEPRIVIEW("设备预检", "DEVICEPRIVIEW"), | |||
SSOREFRESH("刷新接口调用凭证", "SSOREFRESH"), | |||
OCRBUSINESSLICENSE("营业执照信息识别", "OCRBUSINESSLICENSE"), | |||
PSSUSERUSERETCCANCELLIST("取消ETC信息列表", "PSSUSERUSERETCCANCELLIST"), | |||
PSSUSERUSERETCCANCELQUERY("取消ETC信息查询", "PSSUSERUSERETCCANCELQUERY"), | |||
VEHICLETYPECALCULATE("计算车型", "VEHICLETYPECALCULATE"), | |||
DEVICEACTIVATIONSAVE("二发激活指令日志-新增", "DEVICEACTIVATIONSAVE"), | |||
PLATECHANGE("车牌变更", "PLATECHANGE"), | |||
BYDEXCEPTIONQUERY("BYD车辆ETC异常状态查询", "BYDEXCEPTIONQUERY"), | |||
AFLISSUEAUDIT("行驶证认证审核", "AFLISSUEAUDIT"), | |||
AFLISSUEAUDITLIST("行驶证认证复审列表查询", "AFLISSUEAUDITLIST"); | |||
// 枚举构造函数 | |||
private final String value; | |||
private final String type; | |||
AflServiceType(String value, String type) { | |||
this.value = value; | |||
this.type = type; | |||
} | |||
// value 的 getter 方法 | |||
public String getValue() { | |||
return value; | |||
} | |||
// type 的 getter 方法 | |||
public String getType() { | |||
return type; | |||
} | |||
/** | |||
* 根据 type 查找对应枚举的方法 | |||
* | |||
* @param type 接口标识 | |||
* @return 根据 type 查找对应枚举的方法 | |||
*/ | |||
public static String fromType(String type) { | |||
if (ObjectUtils.isEmpty(type)) { | |||
return ""; | |||
} | |||
for (AflServiceType serviceType : values()) { | |||
if (serviceType.getType().equals(type)) { | |||
return serviceType.getValue(); | |||
} | |||
} | |||
// 如果没有找到,返回 null | |||
return ""; | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.qtzl.alterSales.manager.enums; | |||
public enum HandleStatus { | |||
/** | |||
* 文件生成 | |||
*/ | |||
FILE_CREATE("文件生成",1){}, | |||
FILE_REQUEST("文件接收",2){}, | |||
FILE_SEND("文件发送",3){}, | |||
FILE_RESPONSE("发送成功",4){}, | |||
SEND_FAILED("发送失败",5){}, | |||
NET_ERROR("网络异常",6){}, | |||
FILE_RESOLVE("文件解析",7){}, | |||
RESOLVE_FAILED("解析失败",8){}, | |||
INTERFACE_REQUSET("发行接口响应",11){}, | |||
INTERFACE_RESPONSE("发行接口正常返回",12){}, | |||
INTERFACE_EXCEPATION("发行接口异常返回",13){}, | |||
; | |||
private final String value; | |||
private final int code; | |||
public String getValue() { | |||
return value; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
private HandleStatus(String value, int code) { | |||
this.value = value; | |||
this.code = code; | |||
} | |||
} |
@@ -0,0 +1,231 @@ | |||
package com.qtzl.alterSales.manager.handler.logs; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import com.qtzl.alterSales.dao.entity.second.logs.AflInterfaceLog; | |||
import com.qtzl.alterSales.dao.repo.jpa.primary.page.FssPaccountRefundSpecifications; | |||
import com.qtzl.alterSales.dao.repo.jpa.second.logs.AflInterfaceLogRepo; | |||
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager; | |||
import com.qtzl.alterSales.manager.enums.AflServiceType; | |||
import com.qtzl.alterSales.manager.enums.FunctionalityConfigExportOrQuery; | |||
import com.qtzl.alterSales.manager.enums.HandleStatus; | |||
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; | |||
import com.qtzl.alterSales.manager.model.protocol.logs.AflInterfaceLogCmd; | |||
import com.qtzl.alterSales.manager.model.protocol.logs.AflInterfaceLogPageRequest; | |||
import com.qtzl.alterSales.manager.model.protocol.logs.AflInterfaceLogPageResponse; | |||
import com.qtzl.alterSales.manager.model.protocol.logs.mode.AflInterfaceLogVo; | |||
import com.qtzl.alterSales.manager.service.third.ConstantConfig; | |||
import com.qtzl.alterSales.manager.service.third.FmsService; | |||
import com.qtzl.alterSales.manager.tools.ExcelUtils; | |||
import com.qtzl.alterSales.manager.tools.LocalDateTimeCopyUtil; | |||
import com.txffp.api.core.manager.comm.annotation.ApiHandler; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.jetbrains.annotations.NotNull; | |||
import org.springframework.data.domain.Page; | |||
import org.springframework.data.domain.PageRequest; | |||
import org.springframework.data.domain.Pageable; | |||
import org.springframework.data.jpa.domain.Specification; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.ObjectUtils; | |||
import javax.annotation.Resource; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Optional; | |||
/** | |||
* eclipse_afl 服务接口日志 | |||
* | |||
* @author lihao | |||
* @date 2024/06/24 | |||
*/ | |||
@Service | |||
@ApiHandler | |||
public class AflInterfaceLogPageHandler extends AbstractAfterSalesManager<AflInterfaceLogPageRequest> { | |||
@Resource | |||
private AflInterfaceLogRepo aflInterfaceLogRepo; | |||
@Resource | |||
private ConstantConfig constantConfig; | |||
@Resource | |||
private FmsService fmsService; | |||
public AflInterfaceLogPageHandler() { | |||
super(AflInterfaceLogCmd.PAGEOREXPORT, AflInterfaceLogPageRequest.class); | |||
} | |||
@Override | |||
public String handleInternal(String filename, AflInterfaceLogPageRequest request) throws ServiceHandleException { | |||
try { | |||
logger.info("选装-接口日志-分页_导出,请求参数: {}", request.toJson(true)); | |||
// 1 本轮操作类型合法值校验 | |||
boolean is = paramsCheck(request); | |||
AflInterfaceLogPageResponse response = customerPageResponse(request); | |||
if (is) { | |||
// 2 查询数据 并返回 | |||
return response.toJson(); | |||
} | |||
// 导出 | |||
return export(response); | |||
} catch (Exception e) { | |||
if (e instanceof ServiceHandleException) { | |||
throw e; | |||
} | |||
logger.error("选装-接口日志-分页_导出: {}", e.getMessage()); | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("操作失败"); | |||
} | |||
} | |||
/** | |||
* 导出退费数据 | |||
* | |||
* @param response 分页数据 | |||
* @return 导出退费数据 | |||
*/ | |||
@NotNull | |||
private String export(AflInterfaceLogPageResponse response) throws ServiceHandleException { | |||
// 1 导出导本地 | |||
String fileName = "操作日志_" + new SimpleDateFormat("yyyyMMdd").format(new Date()); | |||
String pathFile = ExcelUtils.export(null, fileName, constantConfig.getFilePath(), response.getData(), AflInterfaceLogVo.class); | |||
if (StringUtils.isEmpty(pathFile)) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导出操作日志数据失败"); | |||
} | |||
// 2 上传至文件服务器 | |||
try { | |||
String uploadResult = fmsService.uploadFile(constantConfig.getUploadFile(), pathFile, 90000); | |||
if (StringUtils.isEmpty(uploadResult)) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("导出退费数据失败"); | |||
} | |||
return uploadResult; | |||
} catch (Exception e) { | |||
if (e instanceof ServiceHandleException) { | |||
throw e; | |||
} | |||
logger.error("选装-导出操作日志失败:{}", e.getMessage()); | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage()); | |||
} | |||
} | |||
/** | |||
* @param request 分页参数 | |||
* @Describe 分页查询 | |||
*/ | |||
private AflInterfaceLogPageResponse customerPageResponse(AflInterfaceLogPageRequest request) { | |||
int pageNo = request.getPageNo(); | |||
// 创建分页对象 | |||
Pageable pageable = PageRequest.of(request.getPageNo() - 1, request.getPageSize()); | |||
// 创建 Specification 条件 | |||
Specification<AflInterfaceLog> spec = createSpecification(request); | |||
// 执行查询 | |||
Page<AflInterfaceLog> pagn = aflInterfaceLogRepo.findAll(spec, pageable); | |||
// 记录数 | |||
List<AflInterfaceLog> refund = pagn.getContent(); | |||
// 需要返回的类型对象 | |||
List<AflInterfaceLogVo> resModel = new ArrayList<>(); | |||
if (pageNo <= pagn.getTotalPages() && !ObjectUtils.isEmpty(refund) && refund.size() > 0) { | |||
for (AflInterfaceLog fss : refund) { | |||
AflInterfaceLogVo model = new AflInterfaceLogVo(); | |||
BeanUtil.copyProperties(fss, model); | |||
// 时间字段格式化 | |||
LocalDateTimeCopyUtil.copyAndFormatDateTimeProperties(fss, model); | |||
HandleStatus handleStatus = fss.getHandleStatus(); | |||
if (!ObjectUtils.isEmpty(handleStatus)) { | |||
model.setHandleStatus(handleStatus.getValue()); | |||
} | |||
String serviceType = fss.getServiceType(); | |||
if(!ObjectUtils.isEmpty(serviceType)){ | |||
model.setServiceTypeName(AflServiceType.fromType(serviceType)); | |||
} | |||
resModel.add(model); | |||
} | |||
} | |||
// 响应对象 | |||
AflInterfaceLogPageResponse res = new AflInterfaceLogPageResponse(); | |||
// 当前页 | |||
res.setCurrentPage(pagn.getPageable().getPageNumber()); | |||
// 页面大小 | |||
res.setPageCount(pagn.getTotalPages()); | |||
// 页面数量 | |||
res.setPageSize(pagn.getPageable().getPageSize()); | |||
// 总数 | |||
res.setTotalCount(pagn.getTotalElements()); | |||
// 是否存在数据 | |||
res.setHasData(resModel.size() > 0); | |||
// 每页数据 | |||
res.setData(resModel); | |||
// 返回 json | |||
return res; | |||
} | |||
/** | |||
* 枚举值校验 | |||
* | |||
* @param request 请求参数 | |||
*/ | |||
private boolean paramsCheck(AflInterfaceLogPageRequest request) throws ServiceHandleException { | |||
String exportOrQuery = request.getExportOrQuery(); | |||
FunctionalityConfigExportOrQuery type = FunctionalityConfigExportOrQuery.find(exportOrQuery); | |||
if (ObjectUtils.isEmpty(type)) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(String.format("操作失败,操作范围[%s]不合法", exportOrQuery)); | |||
} | |||
boolean is = FunctionalityConfigExportOrQuery.QUERY.equals(type); | |||
// 强制时间范围条件必填 | |||
if (ObjectUtils.isEmpty(request.getBeginTime()) || ObjectUtils.isEmpty(request.getEndTime())) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("为了您更好的使用体验,请选择时间范围!"); | |||
} | |||
if (ObjectUtils.isEmpty(request.getStaffId()) && ObjectUtils.isEmpty(request.getServiceType())) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("为了您更好的使用体验,请填写对应的查询工号或者接口类型!"); | |||
} | |||
// 根据操作类型 决定数据大小 3.1 每页查找数据不得大于100 | |||
if (is && request.getPageSize() > 100) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(String.format("请求每页数量过大[%d]", request.getPageSize())); | |||
} | |||
return is; | |||
} | |||
/** | |||
* @param request 请求参数 | |||
* @return 构建好的分页对象 | |||
*/ | |||
private Specification<AflInterfaceLog> createSpecification(AflInterfaceLogPageRequest request) { | |||
List<Specification<AflInterfaceLog>> specs = new ArrayList<>(); | |||
// 员工编号 | |||
specs.add(Optional.ofNullable(request.getStaffId()) | |||
.map(FssPaccountRefundSpecifications::withStaffId) | |||
.orElse(Specification.where(null))); | |||
// 接口类型 | |||
specs.add(Optional.ofNullable(request.getServiceType()) | |||
.map(FssPaccountRefundSpecifications::withServiceType) | |||
.orElse(Specification.where(null))); | |||
// 操作状态 | |||
specs.add(Optional.ofNullable(request.getHandleStatus()) | |||
.map(FssPaccountRefundSpecifications::withHandleStatus) | |||
.orElse(Specification.where(null))); | |||
// 时间范围条件 | |||
specs.add(Optional.ofNullable(request.getBeginTime()) | |||
// 确保结束时间不为空 | |||
.filter(beginTime -> !ObjectUtils.isEmpty(request.getEndTime())) | |||
.map(beginTime -> FssPaccountRefundSpecifications.withCreateTime(beginTime, request.getEndTime())) | |||
.orElse(Specification.where(null))); | |||
// 组合所有Specification条件 | |||
return specs.stream() | |||
.reduce(Specification::and) | |||
// 如果没有条件,返回始终为真的Specification | |||
.orElse(Specification.where(null)); | |||
} | |||
} |
@@ -8,12 +8,19 @@ import java.util.regex.Pattern; | |||
public enum UcServiceType implements ServiceSys | |||
{ | |||
/** | |||
* 操作日志 | |||
*/ | |||
SAMPLE("示例", "^SAMPLE_\\S+_\\S+\\.(json|xml)$") {}, | |||
AFTERSALES("售后相关", "^AFTERSALES_\\S+_\\S+\\.(json|xml)$") {}, | |||
FUNCTIONALITY("功能管理", "^FUNCTIONALITY_\\S+_\\S+\\.(json|xml)$") {}, | |||
REFUND("退费管理", "^REFUND_\\S+_\\S+\\.(json|xml)$") {}, | |||
/** | |||
* 操作日志 | |||
*/ | |||
LOGS("日志管理", "^LOGS_\\S+_\\S+\\.(json|xml)$") {}, | |||
; | |||
private static Logger logger = LoggerFactory.getLogger(UcServiceType.class); | |||
private static final Logger logger = LoggerFactory.getLogger(UcServiceType.class); | |||
private final String value; | |||
private final Pattern reqNamePattern; | |||
@@ -0,0 +1,63 @@ | |||
package com.qtzl.alterSales.manager.model.protocol.logs; | |||
import com.qtzl.alterSales.manager.model.protocol.UcServiceType; | |||
import com.txffp.api.core.manager.comm.ApiCmd; | |||
public enum AflInterfaceLogCmd implements ApiCmd{ | |||
/** | |||
* 分页 || 导出 | |||
*/ | |||
PAGEOREXPORT("分页_or_导出", UcServiceType.LOGS) | |||
; | |||
private final String value; | |||
private final UcServiceType type; | |||
private AflInterfaceLogCmd(String value, UcServiceType type) | |||
{ | |||
this.value = value; | |||
this.type = type; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
public UcServiceType getType() { | |||
return type; | |||
} | |||
@Override | |||
public String getCmd() { | |||
return this.name(); | |||
} | |||
@Override | |||
public String getSystemId() { | |||
return getType().systemId(); | |||
} | |||
@Override | |||
public String getSystemName() { | |||
return getType().systemName(); | |||
} | |||
@Override | |||
public String getCmdName() { | |||
return this.value; | |||
} | |||
@Override | |||
public String getSerivceType() { | |||
return this.type.name(); | |||
} | |||
@Override | |||
public String getSerivceTypeName() { | |||
return this.type.getValue(); | |||
} | |||
} |
@@ -0,0 +1,113 @@ | |||
package com.qtzl.alterSales.manager.model.protocol.logs; | |||
import com.qtzl.alterSales.manager.model.protocol.AbstractAfterSalesPageRequest; | |||
import com.txffp.api.core.manager.comm.annotation.Api; | |||
import org.springframework.util.ObjectUtils; | |||
import javax.validation.constraints.NotBlank; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
/** | |||
* 分页 | |||
* @author lihao | |||
*/ | |||
@Api(cmdClazz = AflInterfaceLogCmd.class, cmd = "PAGEOREXPORT") | |||
public class AflInterfaceLogPageRequest extends AbstractAfterSalesPageRequest<AflInterfaceLogPageResponse> { | |||
/** 开始时间 */ | |||
private String startDate; | |||
/** 结束时间 */ | |||
private String endDate; | |||
private LocalDateTime beginTime; | |||
private LocalDateTime endTime; | |||
/** 导出或查询 EXPORT("EXPORT", "导出") QUERY("QUERY", "查询") */ | |||
@NotBlank(message = "导入或查询_操作不能为空,可选值(EXPORT/QUERY)") | |||
private String exportOrQuery; | |||
/** 员工编号 **/ | |||
private String staffId; | |||
/** 接口类型 */ | |||
private String serviceType; | |||
//处理结果 | |||
private String handleStatus; | |||
private LocalDateTime dateFormat(String strTime) { | |||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |||
return LocalDateTime.parse(strTime, df); | |||
} | |||
public String getStartDate() { | |||
return startDate; | |||
} | |||
public void setStartDate(String startDate) { | |||
if (!ObjectUtils.isEmpty(startDate)) { | |||
this.beginTime = dateFormat(startDate + " 00:00:00"); | |||
} | |||
} | |||
public String getEndDate() { | |||
return endDate; | |||
} | |||
public void setEndDate(String endDate) { | |||
if (!ObjectUtils.isEmpty(endDate)) { | |||
this.endTime = dateFormat(endDate + " 23:59:59"); | |||
} | |||
} | |||
public LocalDateTime getBeginTime() { | |||
return beginTime; | |||
} | |||
public LocalDateTime getEndTime() { | |||
return endTime; | |||
} | |||
public void setBeginTime(LocalDateTime beginTime) { | |||
this.beginTime = beginTime; | |||
} | |||
public void setEndTime(LocalDateTime endTime) { | |||
this.endTime = endTime; | |||
} | |||
public String getExportOrQuery() { | |||
return exportOrQuery; | |||
} | |||
public void setExportOrQuery(String exportOrQuery) { | |||
this.exportOrQuery = exportOrQuery; | |||
} | |||
public String getStaffId() { | |||
return staffId; | |||
} | |||
public void setStaffId(String staffId) { | |||
this.staffId = staffId; | |||
} | |||
public String getServiceType() { | |||
return serviceType; | |||
} | |||
public void setServiceType(String serviceType) { | |||
this.serviceType = serviceType; | |||
} | |||
public String getHandleStatus() { | |||
return handleStatus; | |||
} | |||
public void setHandleStatus(String handleStatus) { | |||
this.handleStatus = handleStatus; | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.qtzl.alterSales.manager.model.protocol.logs; | |||
import com.qtzl.alterSales.manager.model.protocol.AbstractAfterSalesPageResponse; | |||
import com.qtzl.alterSales.manager.model.protocol.logs.mode.AflInterfaceLogVo; | |||
/** | |||
* 分页 | |||
* @author lihao | |||
* @date 2023/12/13 | |||
*/ | |||
public class AflInterfaceLogPageResponse extends AbstractAfterSalesPageResponse<AflInterfaceLogVo> { | |||
private boolean hasData; | |||
public boolean isHasData() { | |||
return hasData; | |||
} | |||
public void setHasData(boolean hasData) { | |||
this.hasData = hasData; | |||
} | |||
} |
@@ -0,0 +1,223 @@ | |||
package com.qtzl.alterSales.manager.model.protocol.logs.mode; | |||
import cn.com.taiji.common.entity.BaseEntity; | |||
import com.qtzl.alterSales.dao.entity.second.refund.RefundStats; | |||
import com.qtzl.alterSales.manager.enums.HandleStatus; | |||
import com.qtzl.alterSales.manager.model.protocol.center.excel.ExcelExport; | |||
import com.qtzl.alterSales.manager.tools.LocalDateTimeCopyUtil; | |||
import java.time.LocalDateTime; | |||
/** | |||
* 接口日志 | |||
*/ | |||
public class AflInterfaceLogVo extends BaseEntity { | |||
private String id; | |||
//员工编号 | |||
@ExcelExport(value = "员工编号") | |||
private String staffId; | |||
//发行方编号 | |||
@ExcelExport(value = "发行方编号") | |||
private String agencyId; | |||
//网点编号 | |||
@ExcelExport(value = "网点编号") | |||
private String channelId; | |||
//渠道类型 | |||
@ExcelExport(value = "渠道类型") | |||
private String channelType; | |||
//网点编号 | |||
@ExcelExport(value = "网点编号") | |||
private String submitTime; | |||
//访问ipR | |||
@ExcelExport(value = "访问ipR") | |||
private String fileName; | |||
//访问ipR | |||
@ExcelExport(value = "访问ipR") | |||
private String ip; | |||
//服务器ip | |||
@ExcelExport(value = "服务器ip") | |||
private String serverIp; | |||
//接口类型 | |||
@ExcelExport(value = "接口类型") | |||
private String serviceType; | |||
//接口名称 | |||
@ExcelExport(value = "接口名称") | |||
private String serviceTypeName; | |||
//处理日期 | |||
@ExcelExport(value = "处理日期") | |||
private String handleDate; | |||
@ExcelExport(value = "处理日期") | |||
private String handleTime; | |||
@ExcelExport(value = "请求参数") | |||
private String requestStr; | |||
//处理结果状态 | |||
@ExcelExport(value = "处理结果") | |||
private String handleStatus; | |||
//描述 | |||
@ExcelExport(value = "描述") | |||
private String responseStr; | |||
//录入时间 | |||
@ExcelExport(value = "录入时间") | |||
private String createTime; | |||
//录入时间 | |||
@ExcelExport(value = "更新时间") | |||
private String updateTime; | |||
// 程序异常 | |||
@ExcelExport(value = "程序异常") | |||
private String exceptionTrace; | |||
public String getId() { | |||
return id; | |||
} | |||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
public String getStaffId() { | |||
return staffId; | |||
} | |||
public void setStaffId(String staffId) { | |||
this.staffId = staffId; | |||
} | |||
public String getAgencyId() { | |||
return agencyId; | |||
} | |||
public void setAgencyId(String agencyId) { | |||
this.agencyId = agencyId; | |||
} | |||
public String getChannelId() { | |||
return channelId; | |||
} | |||
public void setChannelId(String channelId) { | |||
this.channelId = channelId; | |||
} | |||
public String getChannelType() { | |||
return channelType; | |||
} | |||
public void setChannelType(String channelType) { | |||
this.channelType = channelType; | |||
} | |||
public String getSubmitTime() { | |||
return submitTime; | |||
} | |||
public void setSubmitTime(String submitTime) { | |||
this.submitTime = submitTime; | |||
} | |||
public String getFileName() { | |||
return fileName; | |||
} | |||
public void setFileName(String fileName) { | |||
this.fileName = fileName; | |||
} | |||
public String getIp() { | |||
return ip; | |||
} | |||
public void setIp(String ip) { | |||
this.ip = ip; | |||
} | |||
public String getServerIp() { | |||
return serverIp; | |||
} | |||
public void setServerIp(String serverIp) { | |||
this.serverIp = serverIp; | |||
} | |||
public String getServiceType() { | |||
return serviceType; | |||
} | |||
public void setServiceType(String serviceType) { | |||
this.serviceType = serviceType; | |||
} | |||
public String getServiceTypeName() { | |||
return serviceTypeName; | |||
} | |||
public void setServiceTypeName(String serviceTypeName) { | |||
this.serviceTypeName = serviceTypeName; | |||
} | |||
public String getHandleDate() { | |||
return handleDate; | |||
} | |||
public void setHandleDate(String handleDate) { | |||
this.handleDate = handleDate; | |||
} | |||
public String getHandleTime() { | |||
return handleTime; | |||
} | |||
public void setHandleTime(String handleTime) { | |||
this.handleTime = handleTime; | |||
} | |||
public String getRequestStr() { | |||
return requestStr; | |||
} | |||
public void setRequestStr(String requestStr) { | |||
this.requestStr = requestStr; | |||
} | |||
public String getHandleStatus() { | |||
return handleStatus; | |||
} | |||
public void setHandleStatus(String handleStatus) { | |||
this.handleStatus = handleStatus; | |||
} | |||
public String getResponseStr() { | |||
return responseStr; | |||
} | |||
public void setResponseStr(String responseStr) { | |||
this.responseStr = responseStr; | |||
} | |||
public String getCreateTime() { | |||
return createTime; | |||
} | |||
public void setCreateTime(String createTime) { | |||
this.createTime = createTime; | |||
} | |||
public String getUpdateTime() { | |||
return updateTime; | |||
} | |||
public void setUpdateTime(String updateTime) { | |||
this.updateTime = updateTime; | |||
} | |||
public String getExceptionTrace() { | |||
return exceptionTrace; | |||
} | |||
public void setExceptionTrace(String exceptionTrace) { | |||
this.exceptionTrace = exceptionTrace; | |||
} | |||
} |