ard-work/src/main/java/com/ard/tianyu/controller/uav/UavBoxController.java
@@ -4,7 +4,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.ard.tianyu.domain.entity.UavBox; import com.ard.tianyu.domain.entity.UavBoxEntity; import com.ard.tianyu.service.IUavBoxService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -44,10 +44,10 @@ @ApiOperation("查询无人机盒子列表") @PreAuthorize("@ss.hasPermi('uav:box:list')") @GetMapping("/list") public TableDataInfo list(UavBox uavBox) public TableDataInfo list(UavBoxEntity uavBoxEntity) { startPage(); List<UavBox> list = uavBoxService.selectUavBoxList(uavBox); List<UavBoxEntity> list = uavBoxService.selectUavBoxList(uavBoxEntity); return getDataTable(list); } @@ -57,10 +57,10 @@ @PreAuthorize("@ss.hasPermi('uav:box:export')") @Log(title = "无人机盒子", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, UavBox uavBox) public void export(HttpServletResponse response, UavBoxEntity uavBoxEntity) { List<UavBox> list = uavBoxService.selectUavBoxList(uavBox); ExcelUtil<UavBox> util = new ExcelUtil<UavBox>(UavBox.class); List<UavBoxEntity> list = uavBoxService.selectUavBoxList(uavBoxEntity); ExcelUtil<UavBoxEntity> util = new ExcelUtil<UavBoxEntity>(UavBoxEntity.class); util.exportExcel(response, list, "无人机盒子数据"); } @@ -82,9 +82,9 @@ @PreAuthorize("@ss.hasPermi('uav:box:add')") @Log(title = "无人机盒子", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody UavBox uavBox) public AjaxResult add(@RequestBody UavBoxEntity uavBoxEntity) { return toAjax(uavBoxService.insertUavBox(uavBox)); return toAjax(uavBoxService.insertUavBox(uavBoxEntity)); } /** @@ -94,9 +94,9 @@ @PreAuthorize("@ss.hasPermi('uav:box:edit')") @Log(title = "无人机盒子", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody UavBox uavBox) public AjaxResult edit(@RequestBody UavBoxEntity uavBoxEntity) { return toAjax(uavBoxService.updateUavBox(uavBox)); return toAjax(uavBoxService.updateUavBox(uavBoxEntity)); } /** ard-work/src/main/java/com/ard/tianyu/domain/entity/UavBoxEntity.java
File was renamed from ard-work/src/main/java/com/ard/tianyu/domain/entity/UavBox.java @@ -18,7 +18,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor public class UavBox extends BaseEntity public class UavBoxEntity extends BaseEntity { private static final long serialVersionUID = 1L; ard-work/src/main/java/com/ard/tianyu/mapper/UavBoxMapper.java
@@ -1,62 +1,61 @@ package com.ard.tianyu.mapper; import com.ard.tianyu.domain.entity.UavBox; import com.ard.tianyu.domain.entity.UavBoxEntity; import java.util.List; /** * 无人机盒子Mapper接口 * * @author ruoyi * * @author lsy * @date 2025-03-04 */ public interface UavBoxMapper { public interface UavBoxMapper { /** * 查询无人机盒子 * * * @param id 无人机盒子主键 * @return 无人机盒子 */ public UavBox selectUavBoxById(Long id); UavBoxEntity selectUavBoxById(Long id); /** * 查询无人机盒子列表 * * @param uavBox 无人机盒子 * * @param uavBoxEntity 无人机盒子 * @return 无人机盒子集合 */ public List<UavBox> selectUavBoxList(UavBox uavBox); List<UavBoxEntity> selectUavBoxList(UavBoxEntity uavBoxEntity); /** * 新增无人机盒子 * * @param uavBox 无人机盒子 * * @param uavBoxEntity 无人机盒子 * @return 结果 */ public int insertUavBox(UavBox uavBox); int insertUavBox(UavBoxEntity uavBoxEntity); /** * 修改无人机盒子 * * @param uavBox 无人机盒子 * * @param uavBoxEntity 无人机盒子 * @return 结果 */ public int updateUavBox(UavBox uavBox); int updateUavBox(UavBoxEntity uavBoxEntity); /** * 删除无人机盒子 * * * @param id 无人机盒子主键 * @return 结果 */ public int deleteUavBoxById(Long id); int deleteUavBoxById(Long id); /** * 批量删除无人机盒子 * * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteUavBoxByIds(Long[] ids); int deleteUavBoxByIds(Long[] ids); } ard-work/src/main/java/com/ard/tianyu/service/IUavBoxService.java
@@ -2,7 +2,7 @@ import com.ard.tianyu.domain.entity.UavBox; import com.ard.tianyu.domain.entity.UavBoxEntity; import java.util.List; @@ -20,31 +20,31 @@ * @param id 无人机盒子主键 * @return 无人机盒子 */ public UavBox selectUavBoxById(Long id); public UavBoxEntity selectUavBoxById(Long id); /** * 查询无人机盒子列表 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 无人机盒子集合 */ public List<UavBox> selectUavBoxList(UavBox uavBox); public List<UavBoxEntity> selectUavBoxList(UavBoxEntity uavBoxEntity); /** * 新增无人机盒子 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 结果 */ public int insertUavBox(UavBox uavBox); public int insertUavBox(UavBoxEntity uavBoxEntity); /** * 修改无人机盒子 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 结果 */ public int updateUavBox(UavBox uavBox); public int updateUavBox(UavBoxEntity uavBoxEntity); /** * 批量删除无人机盒子 ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java
@@ -1,7 +1,7 @@ package com.ard.tianyu.service.impl; import com.ard.common.utils.DateUtils; import com.ard.tianyu.domain.entity.UavBox; import com.ard.tianyu.domain.entity.UavBoxEntity; import com.ard.tianyu.domain.receiver.BoxInfoReceiver; import com.ard.tianyu.mapper.UavBoxMapper; import com.ard.tianyu.service.ITyService; @@ -36,43 +36,43 @@ * @return 无人机盒子 */ @Override public UavBox selectUavBoxById(Long id) { public UavBoxEntity selectUavBoxById(Long id) { return uavBoxMapper.selectUavBoxById(id); } /** * 查询无人机盒子列表 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 无人机盒子 */ @Override public List<UavBox> selectUavBoxList(UavBox uavBox) { return uavBoxMapper.selectUavBoxList(uavBox); public List<UavBoxEntity> selectUavBoxList(UavBoxEntity uavBoxEntity) { return uavBoxMapper.selectUavBoxList(uavBoxEntity); } /** * 新增无人机盒子 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 结果 */ @Override public int insertUavBox(UavBox uavBox) { uavBox.setCreateTime(DateUtils.getNowDate()); return uavBoxMapper.insertUavBox(uavBox); public int insertUavBox(UavBoxEntity uavBoxEntity) { uavBoxEntity.setCreateTime(DateUtils.getNowDate()); return uavBoxMapper.insertUavBox(uavBoxEntity); } /** * 修改无人机盒子 * * @param uavBox 无人机盒子 * @param uavBoxEntity 无人机盒子 * @return 结果 */ @Override public int updateUavBox(UavBox uavBox) { uavBox.setUpdateTime(DateUtils.getNowDate()); return uavBoxMapper.updateUavBox(uavBox); public int updateUavBox(UavBoxEntity uavBoxEntity) { uavBoxEntity.setUpdateTime(DateUtils.getNowDate()); return uavBoxMapper.updateUavBox(uavBoxEntity); } /** @@ -104,25 +104,25 @@ */ @Scheduled(fixedRate = 1000 * 60) public void syncBoxInfo() { List<UavBox> uavBoxeList = selectUavBoxList(new UavBox()); List<UavBoxEntity> uavBoxeListEntity = selectUavBoxList(new UavBoxEntity()); // 将本地列表转换为Map,方便快速查找 Map<String, UavBox> localUavBoxMap = uavBoxeList.stream() .collect(Collectors.toMap(UavBox::getBoxSn, drone -> drone)); Map<String, UavBoxEntity> localUavBoxMap = uavBoxeListEntity.stream() .collect(Collectors.toMap(UavBoxEntity::getBoxSn, drone -> drone)); //遍历接口最新获取的无人机盒子信息 tyService.getBoxList().forEach(remoteUavBox -> { UavBox localUavBox = localUavBoxMap.get(remoteUavBox.getBoxSn()); if (localUavBox != null) { if (!localUavBox.isSameAs(remoteUavBox)) { UavBoxEntity localUavBoxEntity = localUavBoxMap.get(remoteUavBox.getBoxSn()); if (localUavBoxEntity != null) { if (!localUavBoxEntity.isSameAs(remoteUavBox)) { // 修改无人机(只更新变化的属性) updateChangedAttributes(localUavBox, remoteUavBox); updateUavBox(localUavBox); updateChangedAttributes(localUavBoxEntity, remoteUavBox); updateUavBox(localUavBoxEntity); } } }); } // 更新变化的属性 private void updateChangedAttributes(UavBox localBoxInfo, BoxInfoReceiver remoteUavBox) { private void updateChangedAttributes(UavBoxEntity localBoxInfo, BoxInfoReceiver remoteUavBox) { if (!Objects.equals(localBoxInfo.getBoxName(), remoteUavBox.getBoxName())) { localBoxInfo.setBoxName(remoteUavBox.getBoxName()); } ard-work/src/main/resources/mapper/UavBoxMapper.xml
@@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ard.tianyu.mapper.UavBoxMapper"> <resultMap type="UavBox" id="UavBoxResult"> <resultMap type="UavBoxEntity" id="UavBoxResult"> <result property="id" column="id" /> <result property="boxSn" column="box_sn" /> <result property="boxName" column="box_name" /> @@ -24,7 +24,7 @@ select id, box_sn, box_name, box_version, onLine, last_task_id, user_id, dept_id, create_by, create_time, update_by, update_time, remark from uav_box </sql> <select id="selectUavBoxList" parameterType="UavBox" resultMap="UavBoxResult"> <select id="selectUavBoxList" parameterType="UavBoxEntity" resultMap="UavBoxResult"> <include refid="selectUavBoxVo"/> <where> <if test="boxSn != null and boxSn != ''"> and box_sn = #{boxSn}</if> @@ -42,7 +42,7 @@ where id = #{id} </select> <insert id="insertUavBox" parameterType="UavBox"> <insert id="insertUavBox" parameterType="UavBoxEntity"> insert into uav_box <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> @@ -76,7 +76,7 @@ </trim> </insert> <update id="updateUavBox" parameterType="UavBox"> <update id="updateUavBox" parameterType="UavBoxEntity"> update uav_box <trim prefix="SET" suffixOverrides=","> <if test="boxSn != null">box_sn = #{boxSn},</if>