当前位置: 首页 > article >正文

java+postgresql+swagger-多表关联insert操作(九)

入参为json,然后根据需要对多张表进行操作:

入参格式:

{"username": "车主01","usertel": "11111111111","useridtype": "2","useridcard": null,"proname": "天津市","cityname": "天津市市辖区","vinnumber": "2222222222","platenumber": "","cartype": "1","renttype": null,"totalperiods": null,"risklevel": null,"riskcontrolscore": null,"contractno": "","userclasstype": "6","overdueperiods": null,"loandate": null,"endrenttime": null,"inputtime": "2025-04-17T11:33:35","jsonreport": null,"createdbyid": "00000000-0000-0000-0000-000000000000","custstoreName":"swagger-测试经销商01","customerName":"swagger-测试客户01","applyid": "1111111111","credittype": null,"projectprocess": null,"yuqiperiod": null,"settledstatus": null,"startoffline": null,"endoffline": null,"offlineduration": null,"carmodel": "宝马8座 手动 1.5","carseries": "冷藏车老司e","carbrand": "澳柯玛增福改一下22","enginenumber": "","cooperativeunit": null,"lendtime": null,"devicenumber": "987654321","devicemodel": "ZRA5N-8-2","simnumber": "123456789","iswireless": "有线","installposition": "后备箱右侧","installtime": "2025-04-17 13:15:31","supplierid": "测试供应商01","suppliercode": "00001","displaystatus": 2,"simkinds": 1,"installproname": "新疆维吾尔自治区","installcityname": "阿克苏地区","installdistname": "温宿县","installlat": null,"installlng": null,"installperson": "XX000000","simservicecycle": null,"isdisplay": 0,"hosttype": null}

分别往下面表进行写数:

tb_custstoreinfo、tb_supplierinfo、tb_caruserinfo、tb_carusersecondaryinfo、tb_deviceinfo

1、实体:

1.1、表实体:

省略

1.2、入参实体:

package com.example.springbootmybatisplus.dto;import lombok.Data;import java.math.BigDecimal;
import java.util.Date;@Data
public class CarUserDto {private String userName;private String userTel;private String userIdType;private String userIdCard;private String proName;private String cityName;private String vinNumber;private String plateNumber;private String carType;private String rentType;private Integer totalPeriods;private Integer riskLevel;private BigDecimal riskControlScore;private String contractNo;private String userClassType;private String overduePeriods;private Date loanDate;private Date endRentTime;private Date inputTime;private String jsonReport;private String createdById;private String custStoreName;private String customerName;private String applyId;private Integer creditType;private String projectProcess;private String yuqiPeriod;private String settledStatus;private String startOffline;private String endOffline;private BigDecimal offlineDuration;private String carModel;private String carSeries;private String carBrand;private String engineNumber;private String cooperativeUnit;private Date lendTime;private String deviceNumber;private String deviceModel;private String simNumber;private String isWireless;private String installPosition;private Date installTime;private String supplierId;private Short displayStatus;private Short simKinds;private String installProName;private String installCityName;private String installDistName;private BigDecimal installLat;private BigDecimal installLng;private String installPerson;private Short simServiceCycle;private Integer isDisplay;private Integer hostType;private String supplierCode;
}

1.3、其他中间实体:

package com.example.springbootmybatisplus.dto;import lombok.Data;@Data
public class DistrictDto {private String proCode;private String proName;private String cityCode;private String cityName;private String lat;private String lng;
}
package com.example.springbootmybatisplus.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;import java.io.Serializable;
@Data
public class TbCustStore implements Serializable {/*** 主键(DL)*/@TableId(value = "id", type = IdType.INPUT)private String id;/*** 客户Id*/@TableField(value = "customerid")private String customerId;/*** 上级经销商Id*/@TableField(value = "parentId")private String parentId;/*** 经销商编号*/@TableField(value = "code")private String code;/*** 经销商名称*/@TableField(value = "\"name\"")private String name;/*** 经销商等级*/@TableField(value = "levelCode")private Short levelCode;
}

2、Mapper:

package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbCarUserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbCarUserInfoMapper extends BaseMapper<TbCarUserInfo> {@Select("select Id as carid from tb_caruserinfo where vinnumber = #{vinNumber} and deleted=false limit 1")String getCarId(@Param("vinNumber") String vinNumber);@Select("select 'TC'||nextval('tc')")String getCarUserInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbCarUserSecondaryInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbCarUserSecondaryInfoMapper extends BaseMapper<TbCarUserSecondaryInfo> {@Select("select 'CD'||nextval('cd')")String getCarUserSecondaryInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbDeviceInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbDeviceInfoMapper extends BaseMapper<TbDeviceInfo> {@Select("select id as DeviceId from tb_deviceinfo where devicenumber = #{deviceNumber} and deleted=false ")String getDeviceId(@Param("deviceNumber") String deviceNumber);@Select("select 'DI'||nextval('di')")String getDeviceInfoId();
}
package com.example.springbootmybatisplus.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springbootmybatisplus.entity.TbSupplierinfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;@Mapper
public interface TbSupplierinfoMapper extends BaseMapper<TbSupplierinfo> {@Select("select * from tb_supplierinfo where name = #{name} and deleted=false limit 1")TbSupplierinfo getSupplierId(@Param("name") String name);@Select("select 'SU'||nextval('su')")String getSupplierinfoId();
}

3、Service:

3.1、对经销商信息进行处理的Service:

package com.example.springbootmybatisplus.service.impl;import com.example.springbootmybatisplus.entity.TbCustStore;
import com.example.springbootmybatisplus.entity.TbCustStoreInfo;
import com.example.springbootmybatisplus.mapper.TbCustStoreInfoMapper;
import com.example.springbootmybatisplus.service.TbPropertyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;
import java.util.UUID;@Service
public class StoreInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate TbCustStoreInfoMapper tbCustStoreInfoMapper;public void addCustSore(String inCustName, String inCustStoreName, Integer num) {try {if (inCustName == null && inCustStoreName == null) {log.info("输入的经销商或客户名称为空");} else {if (num == 1) {TbCustStore existCustomerId = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustName);if (Objects.isNull(existCustomerId)) {log.info("该客户在库中不存在,需要新建");TbCustStoreInfo tbCustStoreInfo = insertTbCustomerInfo(inCustName, 1);tbCustStoreInfoMapper.insert(tbCustStoreInfo);} else {log.info("该客户:{}在库中已存在", inCustName);}}if (num == 2) {TbCustStore existCustStoreId = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustStoreName);if (Objects.isNull(existCustStoreId)) {log.info("该经销商在库中不存在,需要新建");TbCustStoreInfo cc = new TbCustStoreInfo();TbCustStore tbCustStore = tbCustStoreInfoMapper.selectTbCustStoreInfo3(inCustName);cc.setId(UUID.randomUUID().toString());cc.setCustomerId((tbCustStore.getCustomerId()));cc.setParentId(tbCustStore.getId());cc.setCustomerdealerid(tbCustStore.getId());cc.setCode(tbCustStoreInfoMapper.getCustStoreCode(tbCustStore.getId()));cc.setLevelCode((short) (tbCustStore.getLevelCode() + 1));cc.setName(inCustStoreName);cc.setType(2);cc.setInsertTime(new Date());tbCustStoreInfoMapper.insert(cc);} else {log.info("该经销商:{}在库中已存在", inCustStoreName);}}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbCustStoreInfo insertTbCustomerInfo(String inCustName, Integer num) {TbCustStoreInfo bb = new TbCustStoreInfo();String inId = UUID.randomUUID().toString();bb.setId(inId);bb.setCustomerId(inId);bb.setParentId("DL9999999997");bb.setCustomerdealerid(inId);bb.setCode(tbCustStoreInfoMapper.getCustStoreCode("DL9999999997"));bb.setLevelCode(Short.parseShort("2"));bb.setName(inCustName);bb.setType(2);bb.setInsertTime(new Date());return bb;}}

3.2、对供应商进行处理的Service:

package com.example.springbootmybatisplus.service.impl;import com.example.springbootmybatisplus.entity.TbSupplierinfo;
import com.example.springbootmybatisplus.mapper.TbSupplierinfoMapper;
import com.example.springbootmybatisplus.service.TbPropertyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;@Service
public class SupplierInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate TbSupplierinfoMapper tbSupplierinfoMapper;public void addSupplier(String msg, String code) {try {if (msg == null) {log.info("输入的供应商为空");} else {TbSupplierinfo existsTbSupplierinfo = tbSupplierinfoMapper.getSupplierId(msg);if (Objects.isNull(existsTbSupplierinfo)) {log.info("该供应商在库中不存在,需要新建");TbSupplierinfo tbSupplierinfo = insertTbSupplierinfo(msg, code);tbSupplierinfoMapper.insert(tbSupplierinfo);} else {log.info("该供应商:{}在库中已存在", msg);}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbSupplierinfo insertTbSupplierinfo(String name, String code) {TbSupplierinfo tbSupplierinfo = new TbSupplierinfo();tbSupplierinfo.setId(tbSupplierinfoMapper.getSupplierinfoId());tbSupplierinfo.setName(name);tbSupplierinfo.setCode(code);tbSupplierinfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbSupplierinfo.setCreatedAt(new Date());tbSupplierinfo.setDeleted(false);return tbSupplierinfo;}}

3.3、实现功能的Service:

package com.example.springbootmybatisplus.service;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.springbootmybatisplus.dto.CarUserDto;
import com.example.springbootmybatisplus.dto.DistrictDto;
import com.example.springbootmybatisplus.entity.*;
import com.example.springbootmybatisplus.mapper.*;
import com.example.springbootmybatisplus.service.impl.StoreInfoService;
import com.example.springbootmybatisplus.service.impl.SupplierInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;
import java.util.Objects;@Service
public class TbCarUserInfoService {private static final Logger log = LoggerFactory.getLogger(TbPropertyService.class);@Autowiredprivate CarUserMapper carUserMapper;@Autowiredprivate TbCarUserInfoMapper tbCarUserInfoMapper;@Autowiredprivate TbCarUserSecondaryInfoMapper tbCarUserSecondaryInfoMapper;@Autowiredprivate TbDeviceInfoMapper tbDeviceInfoMapper;@Autowiredprivate TbCustStoreInfoMapper tbCustStoreInfoMapper;@Autowiredprivate StoreInfoService storeInfoService;@Autowiredprivate TbDistrictMapper tbDistrictMapper;@Autowiredprivate TbSupplierinfoMapper tbSupplierinfoMapper;@Autowiredprivate SupplierInfoService supplierInfoService;public void addCarUser(String msg) {try {CarUserDto carUserDto = JSON.parseObject(msg, CarUserDto.class);if (Objects.isNull(carUserDto)) {log.info("车辆信息为空");return;}storeInfoService.addCustSore(carUserDto.getCustomerName(), carUserDto.getCustStoreName(), 1);storeInfoService.addCustSore(carUserDto.getCustomerName(), carUserDto.getCustStoreName(), 2);supplierInfoService.addSupplier(carUserDto.getSupplierId(), carUserDto.getSupplierCode());if (Objects.isNull(carUserDto.getVinNumber())) {log.error("输入的车架号为空,车架号为非空字段");} else {String existsCarId = tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber());if (Objects.isNull(existsCarId)) {log.info("该车架号不存在系统中,需增加此车架号:{}的信息", carUserDto.getVinNumber());TbCarUserInfo tbCarUserInfo = insertTbCarUserInfo(carUserDto);tbCarUserInfoMapper.insert(tbCarUserInfo);TbCarUserSecondaryInfo tbCarUserSecondaryInfo = insertTbCarUserSecondaryInfo(carUserDto);tbCarUserSecondaryInfoMapper.insert(tbCarUserSecondaryInfo);} else {log.warn("输入的车架号:{}信息已在库中存在,不做任何处理!", carUserDto.getVinNumber());}String existsDeviceId = tbDeviceInfoMapper.getDeviceId(carUserDto.getDeviceNumber());if (Objects.isNull(existsDeviceId)) {log.info("该设备号不存在系统中,需增加此设备号:{}的信息", carUserDto.getDeviceNumber());TbDeviceInfo tbDeviceInfo = insertTbDeviceInfo(carUserDto);tbDeviceInfoMapper.insert(tbDeviceInfo);} else {log.warn("输入的设备号:{}信息已在库中存在,不做任何处理!", carUserDto.getDeviceNumber());}}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}public TbCarUserInfo insertTbCarUserInfo(CarUserDto carUserDto) {TbCarUserInfo tbCarUserInfo = new TbCarUserInfo();DistrictDto districtDto = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getProName(), carUserDto.getCityName());TbCustStore tbCustStore=tbCustStoreInfoMapper.selectTbCustStoreInfo3(carUserDto.getCustStoreName());tbCarUserInfo.setId(tbCarUserInfoMapper.getCarUserInfoId());tbCarUserInfo.setUserName(carUserDto.getUserName());tbCarUserInfo.setUserTel(carUserDto.getUserTel());tbCarUserInfo.setUserIdType(carUserDto.getUserIdType());tbCarUserInfo.setUserIdCard(carUserDto.getUserIdCard());tbCarUserInfo.setProName(carUserDto.getProName());tbCarUserInfo.setProCode(districtDto.getProCode());tbCarUserInfo.setCityName(carUserDto.getCityName());tbCarUserInfo.setCityCode(districtDto.getCityCode());tbCarUserInfo.setVinNumber(carUserDto.getVinNumber());tbCarUserInfo.setPlateNumber(carUserDto.getPlateNumber());tbCarUserInfo.setCarType(carUserDto.getCarType());tbCarUserInfo.setRentType(carUserDto.getRentType());tbCarUserInfo.setTotalPeriods(carUserDto.getTotalPeriods());tbCarUserInfo.setRiskLevel(carUserDto.getRiskLevel());tbCarUserInfo.setRiskControlScore(carUserDto.getRiskControlScore());tbCarUserInfo.setContractNo(carUserDto.getContractNo());tbCarUserInfo.setUserClassType(carUserDto.getUserClassType());tbCarUserInfo.setOverduePeriods(carUserDto.getOverduePeriods());tbCarUserInfo.setLoanDate(carUserDto.getLoanDate() != null ? carUserDto.getLoanDate() : new Date());tbCarUserInfo.setEndRentTime(carUserDto.getEndRentTime());tbCarUserInfo.setInputTime(carUserDto.getInputTime() != null ? carUserDto.getInputTime() : new Date());tbCarUserInfo.setJsonReport(carUserDto.getJsonReport());tbCarUserInfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbCarUserInfo.setCustomerId(tbCustStore.getCustomerId());tbCarUserInfo.setCuststoreId(tbCustStore.getId());tbCarUserInfo.setApplyId(carUserDto.getApplyId());tbCarUserInfo.setCreditType(carUserDto.getCreditType());tbCarUserInfo.setProjectProcess(carUserDto.getProjectProcess());tbCarUserInfo.setJsonString(JSONObject.toJSONString(carUserDto));tbCarUserInfo.setCreatedAt(new Date());tbCarUserInfo.setDeleted(false);return tbCarUserInfo;}public TbCarUserSecondaryInfo insertTbCarUserSecondaryInfo(CarUserDto carUserDto) {TbCarUserSecondaryInfo tbCarUserSecondaryInfo = new TbCarUserSecondaryInfo();tbCarUserSecondaryInfo.setId(tbCarUserSecondaryInfoMapper.getCarUserSecondaryInfoId());tbCarUserSecondaryInfo.setCarId(tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber()));tbCarUserSecondaryInfo.setYuqiPeriod(carUserDto.getYuqiPeriod());tbCarUserSecondaryInfo.setSettledStatus(carUserDto.getSettledStatus());tbCarUserSecondaryInfo.setStartOffline(carUserDto.getStartOffline());tbCarUserSecondaryInfo.setEndOffline(carUserDto.getEndOffline());tbCarUserSecondaryInfo.setOfflineDuration(carUserDto.getOfflineDuration());tbCarUserSecondaryInfo.setCarModel(carUserDto.getCarModel());tbCarUserSecondaryInfo.setCarSeries(carUserDto.getCarSeries());tbCarUserSecondaryInfo.setCarBrand(carUserDto.getCarBrand());tbCarUserSecondaryInfo.setEngineNumber(carUserDto.getEngineNumber());tbCarUserSecondaryInfo.setCooperativeUnit(carUserDto.getCooperativeUnit());tbCarUserSecondaryInfo.setLendTime(carUserDto.getLendTime() != null ? carUserDto.getLendTime() : new Date());tbCarUserSecondaryInfo.setCreatedById("00000000-0000-0000-0000-000000000000");tbCarUserSecondaryInfo.setCreatedAt(new Date());tbCarUserSecondaryInfo.setDeleted(false);return tbCarUserSecondaryInfo;}public TbDeviceInfo insertTbDeviceInfo(CarUserDto carUserDto) {TbDeviceInfo tbDeviceInfo = new TbDeviceInfo();tbDeviceInfo.setId(tbDeviceInfoMapper.getDeviceInfoId());tbDeviceInfo.setCarId(tbCarUserInfoMapper.getCarId(carUserDto.getVinNumber()));tbDeviceInfo.setDeviceNumber(carUserDto.getDeviceNumber());tbDeviceInfo.setDeviceModel(carUserDto.getDeviceModel());tbDeviceInfo.setSimNumber(carUserDto.getSimNumber());String isWireless = carUserDto.getIsWireless();if ("有线".equals(isWireless)) {tbDeviceInfo.setIsWireless(Short.parseShort("0"));} else if ("无线".equals(isWireless)) {tbDeviceInfo.setIsWireless(Short.parseShort("1"));} else {tbDeviceInfo.setIsWireless(Short.parseShort("2"));}tbDeviceInfo.setInstallPosition(carUserDto.getInstallPosition());tbDeviceInfo.setInstallTime(carUserDto.getInstallTime());tbDeviceInfo.setSupplierid(tbSupplierinfoMapper.getSupplierId(carUserDto.getSupplierId()).getId());tbDeviceInfo.setDisplaystatus(carUserDto.getDisplayStatus());tbDeviceInfo.setSimkinds(carUserDto.getSimKinds());DistrictDto districtDto = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getInstallProName(), carUserDto.getInstallCityName());if (Objects.isNull(districtDto)){log.warn("未找到对应的省:{}和市:{}的code",carUserDto.getInstallProName(),carUserDto.getInstallCityName());}else {tbDeviceInfo.setInstallProCode(districtDto.getProCode());tbDeviceInfo.setInstallCityCode(districtDto.getCityCode());}tbDeviceInfo.setInstallProName(carUserDto.getInstallProName());tbDeviceInfo.setInstallCityName(carUserDto.getInstallCityName());DistrictDto districtDto1 = tbDistrictMapper.selectProCodeAndCityCode(carUserDto.getInstallCityName(), carUserDto.getInstallDistName());if (Objects.isNull(districtDto1)){log.warn("未找到对应的市:{}和区县:{}的code",carUserDto.getInstallCityName(),carUserDto.getInstallDistName());}else {tbDeviceInfo.setInstallDistCode(districtDto1.getCityCode());}tbDeviceInfo.setInstallDistName(carUserDto.getInstallDistName());tbDeviceInfo.setInstallLat(carUserDto.getInstallLat());tbDeviceInfo.setInstallLng(carUserDto.getInstallLng());tbDeviceInfo.setInstallPerson(carUserDto.getInstallPerson());tbDeviceInfo.setSimServiceCycle(carUserDto.getSimServiceCycle());tbDeviceInfo.setIsDisplay(carUserDto.getDisplayStatus());tbDeviceInfo.setHostType(carUserDto.getHostType());tbDeviceInfo.setCreatedByid("00000000-0000-0000-0000-000000000000");tbDeviceInfo.setCreatedAt(new Date());tbDeviceInfo.setDeleted(false);return tbDeviceInfo;}}

4、Controller:

package com.example.springbootmybatisplus.contronller;import com.example.springbootmybatisplus.service.TbCarUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;@Controller
public class TbCarUserInfoController {@Autowiredprivate TbCarUserInfoService tbCarUserInfoService;@PostMapping("/insert1")public ResponseEntity<String> insert1(@RequestBody String msg) {try {tbCarUserInfoService.addCarUser(msg);return ResponseEntity.status(HttpStatus.CREATED).body("Success");} catch (Exception e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed");}}
}

相关文章:

java+postgresql+swagger-多表关联insert操作(九)

入参为json&#xff0c;然后根据需要对多张表进行操作&#xff1a; 入参格式&#xff1a; {"username": "车主01","usertel": "11111111111","useridtype": "2","useridcard": null,"proname&qu…...

[密码学基础]国密算法深度解析:中国密码标准的自主化之路

国密算法深度解析&#xff1a;中国密码标准的自主化之路 国密算法&#xff08;SM系列算法&#xff09;是中国自主研发的密码技术标准体系&#xff0c;旨在打破国际密码技术垄断&#xff0c;保障国家信息安全。本文将从技术原理、应用场景和生态发展三个维度&#xff0c;全面解…...

Flink-01学习 介绍Flink及上手小项目之词频统计

flink简介 官网 概述&#xff1a; 学习Flink具体包括四个关键概念&#xff1a;流数据的持续处理&#xff0c;事件时间&#xff0c;有状态流处理和状态快照。 Apache Flink 是一个开源的流处理框架&#xff0c;旨在处理批处理和实时数据处理&#xff0c;具有高吞吐量和低延迟的…...

自注意力机制、多头自注意力机制、填充掩码 Python实现

原理讲解 【Transformer系列&#xff08;2&#xff09;】注意力机制、自注意力机制、多头注意力机制、通道注意力机制、空间注意力机制超详细讲解 自注意力机制 import torch import torch.nn as nn# 自注意力机制 class SelfAttention(nn.Module):def __init__(self, input…...

目标检测篇---R-CNN梳理

目标检测系列文章 第一章 R-CNN 目录 目标检测系列文章&#x1f4c4; 论文标题&#x1f9e0; 论文逻辑梳理1. 引言部分梳理 (动机与思想) &#x1f4dd; 三句话总结&#x1f50d; 方法逻辑梳理&#x1f680; 关键创新点&#x1f517; 方法流程图补充边界框回归 (BBR)1. BBR 的…...

C#处理网络传输中不完整的数据流

1、背景 在读取byte数组的场景&#xff08;例如&#xff1a;读取文件、网络传输数据&#xff09;中&#xff0c;特别是网络传输的场景中&#xff0c;非常有可能接收了不完整的byte数组&#xff0c;在将byte数组转换时&#xff0c;因字符的缺失/增多&#xff0c;转为乱码。如下…...

HTML 初识

段落标签 <p><!-- 段落标签 -->Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugiat, voluptate iure. Obcaecati explicabo sint ipsum impedit! Dolorum omnis voluptas sint unde sed, ipsa molestiae quo sapiente quos et ad reprehenderit.&l…...

MATLAB 训练CNN模型 yolo v4

学生对小车控制提出了更好的要求&#xff0c;能否加入深度学习模型。 考虑到小车用matlab来做&#xff0c;yolo v5及以上版本都需要在pytorch下训练&#xff0c;还是用早期版本来演示。 1 yolov4 调用 参考 trainYOLOv4ObjectDetector (mathworks.com) name "tiny-yo…...

【前端】跟着maxkb学习logicflow流程图画法

文章目录 背景1. 选定学习对象-maxkb应用逻辑编排2. 确定实现框架3. 关键逻辑&#xff1a;查看app-node.js4. 学习开始节点绘制流程数据形式 5. 给节点增加表单输入框遇到过的问题 背景 看看前端如何绘制流程图&#xff0c;界面好看点。 "logicflow/core": "1.…...

数据结构-C语言版本(八)字符串

数据结构中的字符串&#xff1a;概念、操作与实战 第一部分 字符串的分类及常见形式 字符串是由零个或多个字符组成的有限序列&#xff0c;是编程中最基础也最重要的数据结构之一。 1. C语言中的字符串表示 字符数组形式 char str1[10] {H, e, l, l, o, \0};字符串字面量…...

Arduino示例代码讲解:Project 07 - Keyboard 键盘

Arduino示例代码讲解:Project 07 - Keyboard 键盘 Project 07 - Keyboard 键盘程序功能概述功能:硬件要求:输出:代码结构全局变量`setup()` 函数`loop()` 函数读取电位器值:打印电位器值:播放音调:运行过程注意事项Project 07 - Keyboard 键盘 /*Arduino Starter Kit e…...

oracle expdp/impdp 用法详解

oracle expdp/impdp 用法详解 创建逻辑目录&#xff0c;该命令不会在操作系统创建真正的目录&#xff0c;最好以system等管理员创建。 create directory db_bak as d:\test\dump; 查看管理理员目录&#xff08;同时查看操作系统是否存在&#xff0c;因为Oracle并不关心该目录是…...

【漏洞复现】CVE-2024-38856(ApacheOfbiz RCE)

【漏洞复现】CVE-2024-38856&#xff08;ApacheOfbiz RCE&#xff09; 1. 漏洞描述 Apache OFBiz 是一个开源的企业资源规划&#xff08;ERP&#xff09;系统。它提供了一套企业应用程序&#xff0c;用于集成和自动化企业的许多业务流程。 这个漏洞是由于对 CVE-2023-51467 的…...

超详细VMware虚拟机扩容磁盘容量-无坑版

1.环境&#xff1a; 虚拟机&#xff1a;VMware Workstation 17 Pro-17.5.2 Linux系统&#xff1a;Ubuntu 22.04 LTS 2.硬盘容量 虚拟机当前硬盘容量180G -> 扩展至 300G 3.操作步骤 &#xff08;1&#xff09;在虚拟机关机的状态下&#xff0c;虚拟机硬盘扩容之前必…...

每日一题算法——移除链表元素、反转链表

移除链表元素 力扣题目链接 我的解法&#xff1a; 注意细节&#xff1a;要删掉移除的元素。 class Solution { public:ListNode* removeElements(ListNode* head, int val) {while(head!nullptr){if(head->valval){headhead->next;}}ListNode* nowhead head;while(n…...

全面理解Linux 系统日志:核心文件与查看方法

全文目录 1 Linux 系统日志分类及功能1.1 通用日志1.1.1 ‌/var/log/messages1.1.2 ‌/var/log/syslog 1.2 安全相关日志1.2.1 ‌/var/log/auth.log‌&#xff08;Debian/Ubuntu&#xff09;或 ‌/var/log/secure‌&#xff08;RHEL/CentOS&#xff09;1.2.2 /var/log/audit/au…...

机器学习-08-关联规则更新

总结 本系列是机器学习课程的系列课程&#xff0c;主要介绍机器学习中关联规则和协同过滤。 参考 机器学习&#xff08;三&#xff09;&#xff1a;Apriori算法&#xff08;算法精讲&#xff09; Apriori 算法 理论 重点 【手撕算法】【Apriori】关联规则Apriori原理、代码…...

Flutter与FastAPI的OSS系统实现

作者&#xff1a;孙嘉成 目录 一、对象存储 二、FastAPI与对象存储 2.1 缤纷云S4服务API对接与鉴权实现 2.2 RESTful接口设计与异步路由优化 三、Flutter界面与数据交互开发 3.1 应用的创建 3.2页面的搭建 3.3 文件的上传 关键词&#xff1a;对象存储、FastAPI、Flutte…...

Kubernetes控制平面组件:API Server详解(二)

云原生学习路线导航页&#xff08;持续更新中&#xff09; kubernetes学习系列快捷链接 Kubernetes架构原则和对象设计&#xff08;一&#xff09;Kubernetes架构原则和对象设计&#xff08;二&#xff09;Kubernetes架构原则和对象设计&#xff08;三&#xff09;Kubernetes控…...

MySQL-锁机制3-意向共享锁与意向排它锁、死锁

文章目录 一、意向锁二、死锁应该如何避免死锁问题&#xff1f; 总结 一、意向锁 在表获取共享锁或者排它锁时&#xff0c;需要先检查该表有没有被其它事务获取过X锁&#xff0c;通过意向锁可以避免大量的行锁扫描&#xff0c;提升表获取锁的效率。意向锁是一种表级锁&#xf…...

报告系统状态的连续日期 mysql + pandas(连续值判断)

本题用到知识点&#xff1a;row_number(), union, date_sub(), to_timedelta()…… 目录 思路 pandas Mysql 思路 链接&#xff1a;报告系统状态的连续日期 思路&#xff1a; 判断连续性常用的一个方法&#xff0c;增量相同的两个列的差值是固定的。 让日期与行号 * 天数…...

pytest自动化中关于使用fixture是否影响用例的独立性

第一个问题&#xff1a;难道使用fixture 会影响用例独立吗&#xff1f; ✅ 简单回答&#xff1a; 使用 fixture ≠ 不独立。 只要你的 fixture 是每次测试都能自己运行、自己产生数据的&#xff0c;那么测试用例依然是“逻辑独立”的。 ✅ 怎么判断 fixture 是否影响独立性&a…...

Token与axios拦截器

目录 一、Token 详解 1. Token 的定义与作用 2. Token 的工作流程 3. Token 的优势 4. Token 的安全实践 5. JWT 结构示例 二、Axios 拦截器详解 1. 拦截器的作用 2. 请求拦截器 3. 响应拦截器 4. 拦截器常见场景 5. 移除拦截器 三、完整代码示例 四、总结 五、…...

unity3d实现物体闪烁

unity3d实现物体闪烁&#xff0c;代码如下: using UnityEngine;public class Test : MonoBehaviour {//创建一个常量&#xff0c;用来接收时间的变化值private float shake;//通过控制物体的MeshRenderer组件的开关来实现物体闪烁的效果private MeshRenderer BoxColliderClick…...

C#—Lazy<T> 类型(延迟初始化/懒加载模式)

C# 的 Lazy<T> 类型 Lazy<T> 是 C# 中的一个类&#xff0c;用于实现延迟初始化&#xff08;懒加载&#xff09;模式。它提供了一种线程安全的方式来延迟创建大型或资源密集型对象&#xff0c;直到第一次实际需要时才进行初始化。 主要特点 延迟初始化&#xff1a…...

Spring Boot 项目启动命令解析

Spring Boot 项目启动命令参数 一、启动命令基础格式 java [JVM参数] [Spring Boot参数] -jar your-project.jar必选部分&#xff1a;java -jar your-project.jar 启动可执行 JAR 包。 可选部分&#xff1a; JVM 参数&#xff1a;控制 Java 虚拟机行为&#xff08;如内存、垃…...

为什么 Docker 容器中有额外的目录(如 `/dev`、`/proc`、`/sys`)?及 `docker run` 详细执行过程

、当你使用 docker run 启动一个基于极简镜像&#xff08;如 scratch 或手动构建的镜像&#xff09;的容器时&#xff0c;发现容器内出现了 /dev、/proc、/sys 等目录&#xff0c;即使你的镜像中并未包含这些目录。这是因为 Docker 在启动容器时&#xff0c;会自动挂载一些必要…...

Tailwind 武林奇谈:bg-blue-400 失效,如何重拾蓝衣神功?

前言 江湖有云,Tailwind CSS,乃前端武林中的轻功秘籍。习得此技,排版如行云流水,配色似御风随形,收放自如,随心所欲。 某日,小侠你奋笔敲码,正欲施展“蓝衣神功”(bg-blue-400),让按钮怒气冲冠、蓝光满面,怎料一招使出,画面竟一片白茫茫大地真干净,毫无半点杀气…...

【Docker 运维】Java 应用在 Docker 容器中启动报错:`unable to allocate file descriptor table`

文章目录 一、根本原因二、判断与排查方法三、解决方法1、限制 Docker 容器的文件描述符上限2、在执行脚本中动态设置ulimit的值3、升级至 Java 11 四、总结 容器内执行脚本时报错如下&#xff0c;Java 进程异常退出&#xff1a; library initialization failed - unable to a…...

开始放飞之先搞个VSCode

文章目录 开始放飞之先搞个VSCode重要提醒安装VSCode下载MinGW-w64回到VSCode中去VSCode原生调试键盘问题遗留问题参考文献 开始放飞之先搞个VSCode 突然发现自己的新台式机上面连个像样的编程环境都没有&#xff0c;全是游戏了&#xff01;&#xff01;&#xff01;&#xff…...