From 76ea66ac9d82ae00edd3d00eea76d40a88e8d40a Mon Sep 17 00:00:00 2001 From: itcast Date: Thu, 16 Oct 2025 19:29:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=E7=B1=BB=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EquipmentPropertyController.java | 12 ++++++- .../mapper/EquipmentPropertyMapper.java | 12 +++++++ .../devConfig/mapper/EquipmentTypeMapper.java | 2 ++ .../service/EquipmentPropertyService.java | 2 ++ .../impl/EquipmentPropertyServiceImpl.java | 25 +++++++++++-- .../impl/EquipmentTypeServiceImpl.java | 3 ++ .../devConfig/EquipmentPropertyMapper.xml | 36 +++++++++++++++++-- .../devConfig/EquipmentTypeMapper.xml | 9 ++++- .../material/ma/MaMachineTypeMapper.xml | 19 +++++++++- 9 files changed, 112 insertions(+), 8 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentPropertyController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentPropertyController.java index 92782a7..250d2fa 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentPropertyController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentPropertyController.java @@ -25,7 +25,8 @@ public class EquipmentPropertyController { */ @GetMapping("/list") public AjaxResult list() { - List list = equipmentPropertyService.list(); + List list=equipmentPropertyService.list() ; + return AjaxResult.success(list); } @@ -47,6 +48,15 @@ public class EquipmentPropertyController { return AjaxResult.success(properties); } + /** + * 根据类型ID查询特征项名称(去重) + */ + @GetMapping("/type/name/{typeId}") + public AjaxResult getNameByTypeId(@PathVariable Long typeId) { + List properties = equipmentPropertyService.getNameByTypeId(typeId); + return AjaxResult.success(properties); + } + /** * 根据类型ID查询装备类型及其特征值(扁平化结果) */ diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentPropertyMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentPropertyMapper.java index b15222b..d08b319 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentPropertyMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentPropertyMapper.java @@ -16,6 +16,16 @@ public interface EquipmentPropertyMapper { void insert(EquipmentProperty equipmentProperty); + + EquipmentProperty getByPropertyName(@Param("propertyName") String propertyName); + void updateById(EquipmentProperty equipmentProperty); + + + + + + + List selectByTypeId(@Param("typeId") Long typeId); EquipmentProperty selectById(@Param("typeId") Long id); @@ -27,4 +37,6 @@ public interface EquipmentPropertyMapper { List selectTypeWithProperties(@Param("typeId") Long typeId); List selectAllTypesWithProperties(); EquipmentPropertyDTO selectTypeDetailWithProperties(@Param("typeId") Long typeId); + + List selectNameByTypeId(@Param("typeId") Long typeId); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java index 4a2c3c0..7fc4b0f 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java @@ -59,4 +59,6 @@ public interface EquipmentTypeMapper { * 检查是否存在子分类 */ Long countChildrenByParentId(@Param("parentId") Long parentId); + + void deleteTypePropertiesByTypeId(@Param("typeId") Long typeId); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentPropertyService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentPropertyService.java index aed53b4..d35279d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentPropertyService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentPropertyService.java @@ -23,4 +23,6 @@ public interface EquipmentPropertyService { List getAllTypesWithProperties(); EquipmentPropertyDTO getTypeDetailWithProperties(Long typeId); + + List getNameByTypeId(Long typeId); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentPropertyServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentPropertyServiceImpl.java index 72b83ea..01c3eb4 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentPropertyServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentPropertyServiceImpl.java @@ -7,6 +7,7 @@ import com.bonus.material.devConfig.service.EquipmentPropertyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -39,8 +40,24 @@ public class EquipmentPropertyServiceImpl implements EquipmentPropertyService { @Override public void add(EquipmentProperty equipmentProperty) { - equipmentProperty.setCreateTime(new Date()); - equipmentPropertyMapper.insert(equipmentProperty); +// equipmentProperty.setCreateTime(new Date()); +// equipmentPropertyMapper.insert(equipmentProperty); + + + // 1. 根据 property_name 查询是否已存在记录 + EquipmentProperty existingProperty = equipmentPropertyMapper.getByPropertyName(equipmentProperty.getPropertyName()); + + if (existingProperty != null) { + // 2. 若存在,合并 property_value(用逗号分隔) + String mergedValue = existingProperty.getPropertyValue() + "," + equipmentProperty.getPropertyValue(); + existingProperty.setPropertyValue(mergedValue); + // 3. 更新已有记录 + equipmentPropertyMapper.updateById(existingProperty); + } else { + // 4. 若不存在,直接新增 + + equipmentPropertyMapper.insert(equipmentProperty); + } } @Override @@ -70,6 +87,10 @@ public class EquipmentPropertyServiceImpl implements EquipmentPropertyService { return equipmentPropertyMapper.selectTypeDetailWithProperties(typeId); } + @Override + public List getNameByTypeId(Long typeId) { + return equipmentPropertyMapper.selectNameByTypeId(typeId); + } } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java index d1a299d..b8fef3d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java @@ -95,6 +95,9 @@ public class EquipmentTypeServiceImpl implements EquipmentTypeService { if (count > 0) { throw new RuntimeException("存在子分类,无法删除"); } + + // 先删除属性 + equipmentTypeMapper.deleteTypePropertiesByTypeId(id); equipmentTypeMapper.deleteEquipmentTypeById(id); } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentPropertyMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentPropertyMapper.xml index 3dff3a9..8de1ad1 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentPropertyMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentPropertyMapper.xml @@ -67,9 +67,11 @@ resultMap="EquipmentPropertyResult"/> - - + SELECT DISTINCT MIN(id) as id, '' as type_id, must_have, @@ -78,6 +80,7 @@ '' as property_value, MAX(create_time) as create_time FROM ma_type_properties + WHERE type_id = #{typeId} GROUP BY property_name ORDER BY create_time DESC @@ -177,6 +180,20 @@ ORDER BY ep.create_time DESC + + + + + + + + @@ -216,4 +233,17 @@ WHERE id = #{id} + + + + + + + + UPDATE ma_type_properties + SET property_value = #{propertyValue} + WHERE id = #{id} + \ No newline at end of file diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml index 169acfe..63b8100 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml @@ -88,8 +88,15 @@ WHERE type_id = #{typeId} + + + DELETE FROM ma_type_properties WHERE type_id = #{typeId} + + + + - DELETE FROM ma_type WHERE type_id = #{typeId} + DELETE FROM ma_type WHERE type_id = #{typeId}; select m.type_id, m.type_name, m.parent_id, m.storage_num, m.manage_type, - m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, + m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time, m.maintenance_alarm_day, m.remark, m.company_id,mtf.file_url photoUrl from ma_type m @@ -448,6 +462,7 @@ m.parent_id, m.storage_num, m.manage_type, + m.lease_price, m.eff_time, m.rent_price, m.buy_price, @@ -461,6 +476,7 @@ m.create_by, m.create_time, m.remark, + m.company_id, m.maintenance_alarm_day, mtf.file_url photoUrl, mt.photoUrl as childPhoto @@ -547,6 +563,7 @@ m.storage_num, m.unit_name, m.manage_type, + m.lease_price, m.eff_time, m.rent_price, m.buy_price,