装备类型配置页面
This commit is contained in:
parent
67b0771294
commit
76ea66ac9d
|
|
@ -25,7 +25,8 @@ public class EquipmentPropertyController {
|
|||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list() {
|
||||
List<EquipmentProperty> list = equipmentPropertyService.list();
|
||||
List<EquipmentProperty> 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<EquipmentProperty> properties = equipmentPropertyService.getNameByTypeId(typeId);
|
||||
return AjaxResult.success(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型ID查询装备类型及其特征值(扁平化结果)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,6 +16,16 @@ public interface EquipmentPropertyMapper {
|
|||
|
||||
void insert(EquipmentProperty equipmentProperty);
|
||||
|
||||
|
||||
EquipmentProperty getByPropertyName(@Param("propertyName") String propertyName);
|
||||
void updateById(EquipmentProperty equipmentProperty);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List<EquipmentProperty> selectByTypeId(@Param("typeId") Long typeId);
|
||||
|
||||
EquipmentProperty selectById(@Param("typeId") Long id);
|
||||
|
|
@ -27,4 +37,6 @@ public interface EquipmentPropertyMapper {
|
|||
List<EquipmentPropertyDTO> selectTypeWithProperties(@Param("typeId") Long typeId);
|
||||
List<EquipmentPropertyDTO> selectAllTypesWithProperties();
|
||||
EquipmentPropertyDTO selectTypeDetailWithProperties(@Param("typeId") Long typeId);
|
||||
|
||||
List<EquipmentProperty> selectNameByTypeId(@Param("typeId") Long typeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,6 @@ public interface EquipmentTypeMapper {
|
|||
* 检查是否存在子分类
|
||||
*/
|
||||
Long countChildrenByParentId(@Param("parentId") Long parentId);
|
||||
|
||||
void deleteTypePropertiesByTypeId(@Param("typeId") Long typeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,6 @@ public interface EquipmentPropertyService {
|
|||
List<EquipmentPropertyDTO> getAllTypesWithProperties();
|
||||
|
||||
EquipmentPropertyDTO getTypeDetailWithProperties(Long typeId);
|
||||
|
||||
List<EquipmentProperty> getNameByTypeId(Long typeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<EquipmentProperty> getNameByTypeId(Long typeId) {
|
||||
return equipmentPropertyMapper.selectNameByTypeId(typeId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,9 @@ public class EquipmentTypeServiceImpl implements EquipmentTypeService {
|
|||
if (count > 0) {
|
||||
throw new RuntimeException("存在子分类,无法删除");
|
||||
}
|
||||
|
||||
// 先删除属性
|
||||
equipmentTypeMapper.deleteTypePropertiesByTypeId(id);
|
||||
equipmentTypeMapper.deleteEquipmentTypeById(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,9 +67,11 @@
|
|||
resultMap="EquipmentPropertyResult"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 查询所有特征值 -->
|
||||
<select id="selectAll" resultMap="EquipmentPropertyResult">
|
||||
SELECT
|
||||
|
||||
|
||||
<!-- 根据typeId查询去重后的特征项 -->
|
||||
<select id="selectAll" 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
|
||||
</select>
|
||||
|
|
@ -177,6 +180,20 @@
|
|||
ORDER BY ep.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="selectNameByTypeId" resultType="com.bonus.material.devConfig.domain.EquipmentProperty">
|
||||
SELECT id, type_id, must_have, input_type, property_name
|
||||
FROM ma_type_properties
|
||||
WHERE type_id = #{typeId}
|
||||
GROUP BY property_name
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 新增特征值 -->
|
||||
<insert id="insert" parameterType="com.bonus.material.devConfig.domain.EquipmentProperty"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
@ -216,4 +233,17 @@
|
|||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<!-- 根据 propertyName 查询记录 -->
|
||||
<select id="getByPropertyName" resultType="com.bonus.material.devConfig.domain.EquipmentProperty">
|
||||
SELECT * FROM ma_type_properties WHERE property_name = #{propertyName}
|
||||
</select>
|
||||
|
||||
<!-- 更新记录 -->
|
||||
<update id="updateById" parameterType="com.bonus.material.devConfig.domain.EquipmentProperty">
|
||||
UPDATE ma_type_properties
|
||||
SET property_value = #{propertyValue}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -88,8 +88,15 @@
|
|||
WHERE type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<!-- 删除关联属性 -->
|
||||
<delete id="deleteTypePropertiesByTypeId">
|
||||
DELETE FROM ma_type_properties WHERE type_id = #{typeId}
|
||||
</delete>
|
||||
|
||||
|
||||
<!-- 删除装备类型-->
|
||||
<delete id="deleteEquipmentTypeById">
|
||||
DELETE FROM ma_type WHERE type_id = #{typeId}
|
||||
DELETE FROM ma_type WHERE type_id = #{typeId};
|
||||
</delete>
|
||||
|
||||
<select id="countChildrenByParentId" resultType="java.lang.Long">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
<result property="code" column="code"/>
|
||||
<result property="unitName" column="unit_name"/>
|
||||
<result property="manageType" column="manage_type"/>
|
||||
<result property="leasePrice" column="lease_price"/>
|
||||
<result property="effTime" column="eff_time"/>
|
||||
<result property="rentPrice" column="rent_price"/>
|
||||
<result property="buyPrice" column="buy_price"/>
|
||||
|
|
@ -39,10 +40,15 @@
|
|||
type_name,
|
||||
parent_id,
|
||||
storage_num,
|
||||
company_id,
|
||||
code,
|
||||
unit_name,
|
||||
manage_type,
|
||||
lease_price,
|
||||
eff_time,
|
||||
rent_price,
|
||||
buy_price,
|
||||
pay_price,
|
||||
level,
|
||||
rated_load,
|
||||
test_load,
|
||||
|
|
@ -54,6 +60,7 @@
|
|||
update_by,
|
||||
update_time,
|
||||
is_plan,
|
||||
is_ancuo,
|
||||
remark,
|
||||
intelligent_code,
|
||||
maintenance_alarm_day,
|
||||
|
|
@ -312,8 +319,11 @@
|
|||
m.storage_num,
|
||||
m.unit_name,
|
||||
m.manage_type,
|
||||
m.lease_price,
|
||||
m.eff_time,
|
||||
m.rent_price,
|
||||
m.buy_price,
|
||||
m.pay_price,
|
||||
m.level,
|
||||
m.rated_load,
|
||||
m.test_load,
|
||||
|
|
@ -382,8 +392,12 @@
|
|||
m.storage_num,
|
||||
m.unit_name,
|
||||
m.manage_type,
|
||||
m.lease_price,
|
||||
m.is_state_grid,
|
||||
m.eff_time,
|
||||
m.rent_price,
|
||||
m.buy_price,
|
||||
m.pay_price,
|
||||
m.level,
|
||||
m.rated_load,
|
||||
m.test_load,
|
||||
|
|
@ -431,7 +445,7 @@
|
|||
|
||||
<select id="selectMaTypeTreeByLevel" resultMap="MaTypeResult" parameterType="java.lang.String">
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue