AOP操作日志记录

AOP操作日志记录
1.创建注解

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PassportLog {String operatePage();String operateType();ClassTypEnum classType();}

2.创建切面
对于字典,可以通过注解属性去转换,枚举也可以注解属性去转换,但是需要if else判断;对于数组类型的传值,需要if else特殊处理;另外需注意反射获取不到子类的属性private

@Slf4j
@Aspect
@Component
@AllArgsConstructor
public class PassportLogAop {/*** 修改记录-字段的分割符号*/private static final String SEPARATOR = ";";@Resourceprivate PassportMapper passportMapper;@Resourceprivate PassportCardFillMapper passportCardFillMapper;@Resourceprivate PassportFamilyMembersMapper passportFamilyMembersMapper;@Resourceprivate PassportEmergencyContactMapper passportEmergencyContactMapper;@Resourceprivate PassportOperateRecordService passportOperateRecordService;@Resourceprivate SysFeign sysFeign;@Resourceprivate SystemDictService systemDictService;@Before("@annotation(passportLog)")public void before(JoinPoint point, PassportLog passportLog) {try {saveLog(point, passportLog);} catch (Exception e) {log.error(e.getMessage());}}/*** 操作日志记录** @param point* @param passportLog* @throws IntrospectionException* @throws InvocationTargetException* @throws IllegalAccessException*/public void saveLog(JoinPoint point, PassportLog passportLog) throws IntrospectionException, InvocationTargetException, IllegalAccessException {ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();if (requestAttributes == null) {return;}PassportOperateRecord record = new PassportOperateRecord();record.setDelFlag(PassportCommonConstant.NOT_DELETE);HttpServletRequest request = Objects.requireNonNull(requestAttributes).getRequest();if (ObjUtil.isNotNull(request)) {record.setOperateIp(IpUtil.getIp(request));record.setUrl(StrUtil.sub(URLUtil.getPath(request.getRequestURI()), 0, 255));record.setMethod(StrUtil.sub(point.getTarget().getClass().getName() + "." + point.getSignature().getName() + "()", 0, 255));record.setRequestMethod(request.getMethod());}record.setOperateTime(LocalDateTime.now());record.setOperatePerson(BaseUserEntity.getName());record.setOperateOffice(BaseUserEntity.getDeptName());record.setOperateRole(sysFeign.queryRoleName(new ArrayList<>(BaseUserEntity.getRoleCode())).getData());record.setOperatePage(passportLog.operatePage());record.setOperateType(passportLog.operateType());Object[] args = point.getArgs();String s = JSONUtil.toJsonStr(args[0]);ClassTypEnum classType = passportLog.classType();String prefix = "";String content = "";if (classType.equals(ClassTypEnum.PASSPORT_ACCEPT_INFO)) {//预约办理PassportAcceptInfoDTO newObj = JSONObject.parseObject(s, PassportAcceptInfoDTO.class);String requestNo = newObj.getRequestNo();record.setRequestNo(requestNo);PassportAcceptInfoDTO oldObj = new PassportAcceptInfoDTO();BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);content = this.compare(oldObj, newObj, requestNo, prefix, content);record.setOperateContent(content);//操作类型Integer status = newObj.getStatus();if (ApplyStatusEnum.UN_ACCEPTED.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.QXSL);} else if (ApplyStatusEnum.PENDING_AUDITING.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.SLBDY);}passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.PASSPORT_ACCEPT_INFO_DRAFT)) {//预约办理草稿箱PassportAcceptInfoDraftDTO newObj = JSONObject.parseObject(s, PassportAcceptInfoDraftDTO.class);String requestNo = newObj.getRequestNo();record.setRequestNo(requestNo);PassportAcceptInfoDraftDTO oldObj = new PassportAcceptInfoDraftDTO();BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);record.setOperateContent(this.compare(oldObj, newObj, requestNo, prefix, content));passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.TODAY_APPLY)) {//申请今日受理TodayApplyDTO newObj = JSONObject.parseObject(s, TodayApplyDTO.class);String requestNo = newObj.getRequestNo();record.setRequestNo(requestNo);record.setOperateContent("申请说明:" + newObj.getReason());passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.PASSPORT_SIDE_HANDLE)) {//现场办理PassportSiteHandleDTO newObj = JSONObject.parseObject(s, PassportSiteHandleDTO.class);record.setRequestNo(newObj.getRequestNo());PassportSiteHandleDTO oldObj = new PassportSiteHandleDTO();if (Objects.isNull(oldObj.getId())) {prefix = "新增:";} else {BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);}record.setOperateContent(this.compare(oldObj, newObj, newObj.getRequestNo(), prefix, content));//操作类型Integer status = newObj.getStatus();if (ApplyStatusEnum.UN_ACCEPTED.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.QXSL);} else if (ApplyStatusEnum.PENDING_AUDITING.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.SLBDY);}passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.PASSPORT_SIDE_HANDLE_DRAFT)) {//现场办理草稿箱PassportSiteHandleDraftDTO newObj = JSONObject.parseObject(s, PassportSiteHandleDraftDTO.class);String requestNo = newObj.getRequestNo();record.setRequestNo(requestNo);PassportSiteHandleDraftDTO oldObj = new PassportSiteHandleDraftDTO();if (Objects.isNull(oldObj.getId())) {prefix = "新增:";} else {BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);}content = this.compare(oldObj, newObj, requestNo, prefix, content);record.setOperateContent(content);passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.PASSPORT_CHECK)) {//护照情况核查、退回修改、保存、生成传真并提交审核PassportCheckDTO newObj = JSONObject.parseObject(s, PassportCheckDTO.class);record.setRequestNo(newObj.getRequestNo());PassportCheckDTO oldObj = new PassportCheckDTO();BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);record.setOperateContent(this.compare(oldObj, newObj, newObj.getRequestNo(), prefix, content));//操作类型Integer status = newObj.getStatus();Integer problemStatus = newObj.getProblemStatus();if (ApplyStatusEnum.NOT_VERIFIED.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.BC);}if (PassportProblemEnum.THXG.getCode().equals(problemStatus)) {record.setOperateType(PassportOperateTypeConstant.THXG);} else if (ApplyStatusEnum.PENDING_AUDITING.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.SCCZBTJSH);}passportOperateRecordService.save(record);} else if (classType.equals(ClassTypEnum.PASSPORT_CHECK_BATCH)) {//批量核查List ids = JSONObject.parseObject(s, List.class);for (Object id : ids) {Passport passport = passportMapper.selectById(Long.parseLong(id.toString()));record.setRequestNo(passport.getRequestNo());record.setOperateContent("批量生成传真并提交审核");passportOperateRecordService.save(record);}} else if (classType.equals(ClassTypEnum.PASSPORT_EXAMINE_BATCH)) {//批量审核List ids = JSONObject.parseObject(s, List.class);for (Object id : ids) {Passport passport = passportMapper.selectById(Long.parseLong(id.toString()));record.setRequestNo(passport.getRequestNo());record.setOperateContent("批量审核通过");passportOperateRecordService.save(record);}} else if (classType.equals(ClassTypEnum.PASSPORT_EXAMINE)) {//审核PassportExamineDTO newObj = JSONObject.parseObject(s, PassportExamineDTO.class);record.setRequestNo(newObj.getRequestNo());PassportExamineDTO oldObj = new PassportExamineDTO();BeanUtil.copyProperties(passportMapper.selectById(newObj.getId()), oldObj);//如果老状态是复核则页面应设置为复核页面if (ApplyStatusEnum.PENDING_REVIEW.getCode().equals(oldObj.getStatus())) {record.setOperatePage(PassportOperatePageConstant.HZBL_HZFH_ZHFX);}record.setOperateContent(this.compare(oldObj, newObj, newObj.getRequestNo(), prefix, content));//操作类型Integer status = newObj.getStatus();Integer problemStatus = newObj.getProblemStatus();if (ApplyStatusEnum.PENDING_REVIEW.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.TJFH);} else if (ApplyStatusEnum.RETURNED_ITEMS.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.TJ);} else if (ApplyStatusEnum.PENDING_CERTIFICATION.getCode().equals(status)) {record.setOperateType(PassportOperateTypeConstant.TG);}if (PassportProblemEnum.THXG.getCode().equals(problemStatus)) {record.setOperateType(PassportOperateTypeConstant.THXG);} else if (PassportProblemEnum.GQ.getCode().equals(problemStatus)) {record.setOperateType(PassportOperateTypeConstant.GQ);}passportOperateRecordService.save(record);}}/*** 比较两个对象,并且返回不一致的信息** @param newObj* @param oldObj* @param requestNo* @param prefix* @return*/private String compare(Object oldObj, Object newObj, String requestNo, String prefix, String str) throws IntrospectionException, InvocationTargetException, IllegalAccessException {str += prefix;//1:获取到对象的classClass<?> oldClass = oldObj.getClass();Class<?> newClass = newObj.getClass();//2:获取到对象的属性列表Field[] oldFields = oldClass.getDeclaredFields();Field[] newFields = newClass.getDeclaredFields();for (int i = 0; i < oldFields.length; i++) {if ("serialVersionUID".equals(oldFields[i].getName())) {continue;}//将此对象的 accessible 标志设置为指示的布尔值。// 值为 true 则指示反射的对象在使用时应该取消 Java 语言访问检查。// 值为 false 则指示反射的对象应该实施 Java 语言访问检查;// 实际上setAccessible是启用和禁用访问安全检查的开关,// 并不是为true就能访问为false就不能访问 ;oldFields[i].setAccessible(true);newFields[i].setAccessible(true);//获取到字段上的注解PassportField annotation = oldFields[i].getAnnotation(PassportField.class);//当没有注解的时候跳过本次循环if (annotation == null) {continue;}//获取注解中的字段名String name = annotation.name();ListTypEnum listTypEnum = annotation.listType();SysDictTypeEnum code = annotation.code();TypeEnum typeEnum = annotation.typeEnum();PropertyDescriptor oldPd = new PropertyDescriptor(oldFields[i].getName(), oldClass);PropertyDescriptor newPd = new PropertyDescriptor(newFields[i].getName(), newClass);//调用成员方法Method oldReadMethod = oldPd.getReadMethod();Method newReadMethod = newPd.getReadMethod();//3:获取到参数数值Object oldValue = oldReadMethod.invoke(oldObj);Object newValue = newReadMethod.invoke(newObj);if (StrUtil.isBlank(name)) {//处理listif (listTypEnum.equals(ListTypEnum.CARD_FILL)) {str = this.cardFill(newValue, requestNo, str);continue;} else if (listTypEnum.equals(ListTypEnum.EMERGENCY_CONTACT)) {str = this.emergencyContact(newValue, requestNo, str);continue;} else if (listTypEnum.equals(ListTypEnum.FAMILY_MEMBERS)) {str = this.familyMember(newValue, requestNo, str);continue;}} else {//处理系统字典if (ObjUtil.isNotNull(code) && !SysDictTypeEnum.NULL.equals(code)) {if (ObjUtil.isNotNull(oldValue)) {oldValue = systemDictService.queryDictName(code, oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = systemDictService.queryDictName(code, newValue.toString());}}if (ObjUtil.isNotNull(typeEnum) && !TypeEnum.NULL.equals(typeEnum)) {if (TypeEnum.STATUS.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = ApplyStatusEnum.getMessage(Integer.parseInt(oldValue.toString()));}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = ApplyStatusEnum.getMessage(Integer.parseInt(newValue.toString()));}} else if (TypeEnum.SF.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportFlagEnum.getMessage(Integer.parseInt(oldValue.toString()));}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportFlagEnum.getMessage(Integer.parseInt(newValue.toString()));}} else if (TypeEnum.BIRTHPLACE.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = systemDictService.birthdayPlace(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = systemDictService.birthdayPlace(newValue.toString());}} else if (TypeEnum.CARD_VALID_UNIT.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = CardValidUnitEnum.getMessage(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = CardValidUnitEnum.getMessage(newValue.toString());}} else if (TypeEnum.ISSUE_PLACE.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = systemDictService.issuePlace(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = systemDictService.issuePlace(newValue.toString());}} else if (TypeEnum.ISSUE_CHECK.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportDictIssueEnum.getDiceLabel(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportDictIssueEnum.getDiceLabel(newValue.toString());}} else if (TypeEnum.EVIDENCE_WAY.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportEvidenceWayEnum.getMessage(Integer.parseInt(oldValue.toString()));}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportEvidenceWayEnum.getMessage(Integer.parseInt(newValue.toString()));}} else if (TypeEnum.DECLARATION_RELATION.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportDictRelationEnum.getDiceLabel(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportDictRelationEnum.getDiceLabel(newValue.toString());}} else if (TypeEnum.CHECK_OFFICE.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {String[] split = oldValue.toString().split(",");StringBuilder oldValueContent = new StringBuilder();for (String s : split) {oldValueContent.append(systemDictService.queryDictName(SysDictTypeEnum.VERIFICATION_AND_SUBMISSION_AUTHORITY, s));}oldValue = oldValueContent.toString();}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {String[] split = newValue.toString().split(",");StringBuilder newValueContent = new StringBuilder();for (String s : split) {newValueContent.append(systemDictService.queryDictName(SysDictTypeEnum.VERIFICATION_AND_SUBMISSION_AUTHORITY, s));}newValue = newValueContent.toString();}} else if (TypeEnum.EMERGENCY_RELATION.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportDictEmergencyContactEnum.getDiceLabel(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportDictEmergencyContactEnum.getDiceLabel(newValue.toString());}} else if (TypeEnum.FAMILY_RELATION.equals(typeEnum)) {if (ObjUtil.isNotNull(oldValue) && StrUtil.isNotBlank(oldValue.toString())) {oldValue = PassportDictFamilyEnum.getDiceLabel(oldValue.toString());}if (ObjUtil.isNotNull(newValue) && StrUtil.isNotBlank(newValue.toString())) {newValue = PassportDictFamilyEnum.getDiceLabel(newValue.toString());}}}//获取差异字段str = getDifferenceFieldStr(str, name, oldValue, newValue);}}return str;}/*** 获取差异字段新旧值** @param str* @param fieldName* @param oldValue* @param newValue* @return*/private static String getDifferenceFieldStr(String str, String fieldName, Object oldValue, Object newValue) {if (null == oldValue || StringUtils.isBlank(oldValue.toString())) {oldValue = "无";}if (null == newValue || StringUtils.isBlank(newValue.toString())) {newValue = "无";}if (!oldValue.equals(newValue)) {str += fieldName + "从 " + oldValue + ",修改为 " + newValue + SEPARATOR;}return str;}/*** 处理加注** @param newValue* @param requestNo* @throws IntrospectionException* @throws InvocationTargetException* @throws IllegalAccessException*/private String cardFill(Object newValue, String requestNo, String str) throws IntrospectionException, InvocationTargetException, IllegalAccessException {List<PassportCardFillDTO> newObjects = (List<PassportCardFillDTO>) newValue;List<PassportCardFillDTO> oldObjects = passportCardFillMapper.queryCardFillByRequestNo(requestNo);if (CollectionUtils.isEmpty(newObjects)) {if (!CollectionUtils.isEmpty(oldObjects)) {for (PassportCardFillDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportCardFillDTO(), requestNo, "删除加注:", str);}}} else {if (CollectionUtils.isEmpty(oldObjects)) {for (PassportCardFillDTO newObject : newObjects) {str = this.compare(new PassportCardFillDTO(), newObject, requestNo, "新增加注:", str);}} else {for (PassportCardFillDTO newObject : newObjects) {if (Objects.isNull(newObject.getId())) {str = this.compare(new PassportCardFillDTO(), newObject, requestNo, "新增加注:", str);} else {List<PassportCardFillDTO> removeFills = new ArrayList<>();for (PassportCardFillDTO oldObject : oldObjects) {if (oldObject.getId().equals(newObject.getId())) {if (!oldObject.equals(newObject)) {str = this.compare(oldObject, newObject, requestNo, "", str);}removeFills.add(oldObject);}}oldObjects.removeAll(removeFills);for (PassportCardFillDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportCardFillDTO(), requestNo, "删除加注:", str);}}}}}return str;}/*** 处理紧急联系人** @param newValue* @param requestNo* @throws IntrospectionException* @throws InvocationTargetException* @throws IllegalAccessException*/private String emergencyContact(Object newValue, String requestNo, String str) throws IntrospectionException, InvocationTargetException, IllegalAccessException {List<PassportEmergencyContactAddDTO> newObjects = (List<PassportEmergencyContactAddDTO>) newValue;List<PassportEmergencyContactAddDTO> oldObjects = passportEmergencyContactMapper.queryEmergencyContactByRequestNo(requestNo);if (CollectionUtils.isEmpty(newObjects)) {if (CollUtil.isNotEmpty(oldObjects)) {for (PassportEmergencyContactAddDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportEmergencyContactAddDTO(), requestNo, "删除紧急联系人:", str);}}} else {if (CollUtil.isEmpty(oldObjects)) {for (PassportEmergencyContactAddDTO newObject : newObjects) {str = this.compare(new PassportEmergencyContactAddDTO(), newObject, requestNo, "新增紧急联系人:", str);}} else {for (PassportEmergencyContactAddDTO newObject : newObjects) {if (ObjUtil.isNull(newObject.getId())) {str = this.compare(new PassportEmergencyContactAddDTO(), newObject, requestNo, "新增紧急联系人:", str);} else {for (PassportEmergencyContactAddDTO oldObject : oldObjects) {if (oldObject.getId().equals(newObject.getId())) {if (!oldObject.equals(newObject)) {str = this.compare(oldObject, newObject, requestNo, "", str);}oldObjects.remove(oldObject);}}if (CollUtil.isNotEmpty(oldObjects)) {for (PassportEmergencyContactAddDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportEmergencyContactAddDTO(), requestNo, "删除紧急联系人:", str);}}}}}}return str;}/*** 处理家庭成员** @param newValue* @param requestNo* @throws IntrospectionException* @throws InvocationTargetException* @throws IllegalAccessException*/private String familyMember(Object newValue, String requestNo, String str) throws IntrospectionException, InvocationTargetException, IllegalAccessException {List<PassportFamilyMembersAddDTO> newObjects = (List<PassportFamilyMembersAddDTO>) newValue;List<PassportFamilyMembersAddDTO> oldObjects = passportFamilyMembersMapper.queryFamilyMemberByRequest(requestNo);if (CollectionUtils.isEmpty(newObjects)) {if (ObjUtil.isNotEmpty(oldObjects)) {for (PassportFamilyMembersAddDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportFamilyMembersAddDTO(), requestNo, "删除家庭成员:", str);}}} else {if (CollUtil.isEmpty(oldObjects)) {for (PassportFamilyMembersAddDTO newObject : newObjects) {str = this.compare(new PassportFamilyMembersAddDTO(), newObject, requestNo, "新增家庭成员:", str);}} else {for (PassportFamilyMembersAddDTO newObject : newObjects) {if (ObjUtil.isNull(newObject.getId())) {str = this.compare(new PassportFamilyMembersAddDTO(), newObject, requestNo, "新增家庭成员:", str);} else {for (PassportFamilyMembersAddDTO oldObject : oldObjects) {if (oldObject.getId().equals(newObject.getId())) {if (!oldObject.equals(newObject)) {str = this.compare(oldObject, newObject, requestNo, "", str);}oldObjects.remove(oldObject);}}if (CollUtil.isNotEmpty(oldObjects)) {for (PassportFamilyMembersAddDTO oldObject : oldObjects) {str = this.compare(oldObject, new PassportFamilyMembersAddDTO(), requestNo, "删除家庭成员:", str);}}}}}}return str;}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/203033.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

车联网架构设计(二)_消息缓存

在上一篇博客车联网架构设计(一)_消息平台的搭建-CSDN博客中&#xff0c;我介绍了车联网平台需要实现的一些功能&#xff0c;并介绍了如何用EMQXHAPROXY来搭建一个MQTT消息平台。车联网平台的应用需要消费车辆发布的消息&#xff0c;同时也会下发消息给车辆&#xff0c;以实现车…

SpringBoot 属性配置解析

属性配置介绍 spring官方提供的17中属性配置的方式 Devtools全局配置测试环境TestPropertySource注解测试环境properties属性命令行参数SPRING_APPLICATION_JSON属性ServletConfig初始化参数ServletContext初始化参数JNDI属性JAVA系统属性操作系统环境变量RandomValueProperty…

解释区块链技术的应用场景和优势。

区块链技术的应用场景&#xff1a; 金融行业&#xff1a;区块链可用于加强支付、结算、借贷和保险等金融业务的安全性和效率。 物流行业&#xff1a;区块链可用于追踪物流信息&#xff0c;保证货物的安全、可靠和透明。 版权保护&#xff1a;区块链可用于储存数字资产和版权信…

Nacos和Eureka冲突问题原因分析

目录 一、问题现象二、解决办法三、原因分析 一、问题现象 Description:Field autoServiceRegistration in org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration required a single bean, but 2 were found:- eurekaAutoServiceRegis…

单例模式【C#】

只能生一个儿子。 文件操作只能一个单例去操作。 1static&#xff1a; static的特点是&#xff0c;不需要new就能使用。即使派生了&#xff0c;也是使用静态的对象。 public class SingleObject {//创建 SingleObject 的一个对象private static SingleObject instance new…

基于OpenCV+CNN+IOT+微信小程序智能果实采摘指导系统——深度学习算法应用(含pytho、JS工程源码)+数据集+模型(二)

目录 前言总体设计系统整体结构图系统流程图 运行环境Python环境TensorFlow 环境Jupyter Notebook环境Pycharm 环境微信开发者工具OneNET云平台 相关其它博客工程源代码下载其它资料下载 前言 本项目基于Keras框架&#xff0c;引入CNN进行模型训练&#xff0c;采用Dropout梯度…

spark log4j日志配置

1.spark启动参数 先把log4j配置文件放到hdfs&#xff1a;hdfs://R2/projects/log4j-debug.properties --conf spark.yarn.dist.fileshdfs://R2/projects/log4j-debug.properties#log4j-first.properties \ --conf "spark.driver.extraJavaOptions-Dlog4j.configurationf…

【前端设计模式】之单例模式

在前端开发中&#xff0c;单例模式是一种常见的设计模式&#xff0c;用于确保一个类只有一个实例&#xff0c;并提供全局访问点。在实现单例模式时&#xff0c;有一些最佳实践和高级技巧可以帮助我们编写更优雅和可维护的代码。 1. 使用闭包 使用闭包是实现单例模式的一种常见…

uni-app 设置tabBar的setTabBarBadge购物车/消息等角标

目录 一、效果二、代码实现二、全部代码1.index.vue2.cart.vue 三、真实案例参考最后 一、效果 二、代码实现 只要使用uni.setTabBarBadge和uni.removeTabBarBadge来进行对红点的设置和移除。 主要代码&#xff1a; //设置红点 uni.setTabBarBadge({index: 1, // 底部菜单栏…

大数据可视化项目——基于Python豆瓣电影数据可视化分析系统的设计与实现

大数据可视化项目——基于Python豆瓣电影数据可视化分析系统的设计与实现 本项目旨在通过对豆瓣电影数据进行综合分析与可视化展示&#xff0c;构建一个基于Python的大数据可视化系统。通过数据爬取收集、清洗、分析豆瓣电影数据&#xff0c;我们提供了一个全面的电影信息平台…

Python自动化——driver.execute_script的用法

用法引入 当您使用Selenium时&#xff0c;您可以指定chrome驱动程序的路径。以下是一个完整的示例&#xff0c;包括指定Chrome驱动程序的路径&#xff1a; from selenium import webdriver# 指定Chrome驱动程序的路径 chrome_driver_path C:/path/to/your/chromedriver.exe …

2-Django、Flask和Tornado三大主流框架对比

在Python的web开发框架中&#xff0c;目前使用量最高的几个是Django、Flask和Tornado&#xff0c; 经常会有人拿这几个对比&#xff0c;相信大家的初步印象应该是 Django大而全、Flask小而精、Tornado性能高。 了解常用框架 Django 主要特点是大而全,集成了很多组件,例如: Mo…

instanceof原理解析

instanceof 运算符用于检测构造函数的 prototype 属性是否出现在某个实例对象的原型链上。 ​ 语法 object instanceof Constructorobject //某个实例对象 Constructor //某个构造函数实例验证 验证的过程中会使用Object.getPrototypeOf(Object)&#xff0c;Object.getProtot…

论文阅读[2023ICME]Edge-FVV: Free Viewpoint Video Streaming by Learning at the Edge

Edge-FVV: Free Viewpoint Video Streaming by Learning at the Edge 会议信息&#xff1a; Published in: 2023 IEEE International Conference on Multimedia and Expo (ICME) 作者&#xff1a; 1 背景 FVV允许观众从多个角度观看视频&#xff0c;但是如果所选视点的视频…

机器学习-逻辑回归

一、引言 逻辑回归&#xff08;Logistic Regression&#xff09;是一种广泛应用于分类问题的监督学习算法。尽管名字中含有“回归”二字&#xff0c;但这并不意味着它用于解决回归问题。相反&#xff0c;逻辑回归专注于解决二元或多元分类问题&#xff0c;如邮件是垃圾邮件还是…

vue2+typescript使用高德地图2.0版本

高德地图 webjs api 2.0官网教程 AMap.Driving使用说明 <div class"mmp"><div id"map" ref"mapcontainer"></div></div><script lang"ts"> //安全密钥 window._AMapSecurityConfig{securityJsCode: &qu…

ExoPlayer架构详解与源码分析(10)——H264Reader

系列文章目录 ExoPlayer架构详解与源码分析&#xff08;1&#xff09;——前言 ExoPlayer架构详解与源码分析&#xff08;2&#xff09;——Player ExoPlayer架构详解与源码分析&#xff08;3&#xff09;——Timeline ExoPlayer架构详解与源码分析&#xff08;4&#xff09;—…

数据结构初阶之二叉树性质练习与代码练习

个人主页&#xff1a;点我进入主页 专栏分类&#xff1a;C语言初阶 C语言程序设计————KTV C语言小游戏 C语言进阶 C语言刷题 数据结构初阶 Linux 欢迎大家点赞&#xff0c;评论&#xff0c;收藏。 一起努力,共赴大厂。 目录 1.前言 2.性质练习 3…

基于深度学习的热红外图像超分辨率

基于深度学习的热红外图像超分辨率&#xff08;Infrared Image Super-Resolution&#xff09;是一种利用深度学习技术提高热红外图像空间分辨率的方法。在超分辨率任务中&#xff0c;模型的目标是从低分辨率输入图像生成高分辨率的图像&#xff0c;以提供更多细节和更清晰的图像…

Python中的匿名函数是什么

匿名函数 lambda x , y : xy 1.匿名的目的就是要没有名字&#xff0c;给匿名函数赋给一个名字是没有意义的。 2.匿名函数的参数规则、作用域关系与有名函数是一样的。 3.匿名函数的函数体通常应该是 一个表达式,该表达式必须要有一个返回值。 flambda x,n:x ** n print(f…