fix: 调整获取设备部位的逻辑

This commit is contained in:
曹鹏飞 2025-03-04 20:04:15 +08:00
parent aca359088d
commit fd6a020f61
5 changed files with 38 additions and 11 deletions

View File

@ -0,0 +1,13 @@
package com.nflg.mobilebroken.common.pojo.vo;
import lombok.Data;
@Data
public class ComponentInfo {
//部位名称
private String name;
//语言对应的名称
private String languageValue;
}

View File

@ -1,6 +1,6 @@
package com.nflg.mobilebroken.common.pojo.vo;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
@ -35,16 +35,12 @@ public class DeviceInfoVO {
//质保期()
private Integer warrantyMonth;
//机型部件
private String component;
//设备部件列表
private List<String> components;
public List<String> getComponents(){
return StrUtil.split(component,";");
}
private List<ComponentInfo> components;
//客户名称
private String customerName;
@JsonIgnore
private Integer componentId;
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
import com.nflg.mobilebroken.common.pojo.request.SearchDeviceRequest;
import com.nflg.mobilebroken.common.pojo.vo.ComponentInfo;
import com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceVO;
import com.nflg.mobilebroken.repository.entity.Device;
@ -40,4 +41,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
void taskWarrantyStateNotOutsideWarranty();
void taskWarrantyStateNotOutsideWithinWarranty();
List<ComponentInfo> getComponents(Integer componentId,String language);
}

View File

@ -7,6 +7,7 @@ import com.nflg.mobilebroken.common.pojo.request.SearchDeviceRequest;
import com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceVO;
import com.nflg.mobilebroken.common.util.AppUserUtil;
import com.nflg.mobilebroken.common.util.MultilingualUtil;
import com.nflg.mobilebroken.repository.entity.Device;
import com.nflg.mobilebroken.repository.mapper.DeviceMapper;
import com.nflg.mobilebroken.repository.service.IDeviceService;
@ -14,6 +15,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* <p>
@ -28,7 +30,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override
public DeviceInfoVO getByDeviceNo(String deviceNo) {
return baseMapper.getByDeviceNo(deviceNo);
DeviceInfoVO vo=baseMapper.getByDeviceNo(deviceNo);
if (Objects.nonNull(vo.getComponentId())){
vo.setComponents(baseMapper.getComponents(vo.getComponentId(), MultilingualUtil.getLanguage()));
}
return vo;
}

View File

@ -3,9 +3,10 @@
<mapper namespace="com.nflg.mobilebroken.repository.mapper.DeviceMapper">
<select id="getByDeviceNo" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO">
SELECT d.device_no AS 'deviceNo',d.model_no AS 'modelNo',dc.component AS 'component',d.device_type AS 'deviceType'
SELECT d.device_no AS 'deviceNo',d.model_no AS 'modelNo',d.device_type AS 'deviceType'
,d.device_type_sub AS 'deviceTypeSub',d.warranty_state AS 'warrantyState',d.shipment_date AS 'shipmentDate'
,d.start_warranty_date AS 'startWarrantyDate',d.warranty_month AS 'warrantyMonth',d.customer_name AS 'customerName'
,dc.id AS 'componentId'
FROM device d
LEFT JOIN device_component dc ON d.model_no=dc.model_no AND dc.`enable`=1
WHERE d.device_no=#{deviceNo}
@ -87,4 +88,12 @@
join dictionary_item b on a.id=b.dictionary_id
where a.code='deviceWarrantyState' and b.`code`='WithinWarranty') where start_warranty_date &lt;= now() and DATE_ADD(start_warranty_date, INTERVAL warranty_month MONTH) &gt;= now() ;
</update>
<select id="getComponents" resultType="com.nflg.mobilebroken.common.pojo.vo.ComponentInfo">
SELECT dcd.model_part_name AS 'name',ld.language_value AS 'languageValue'
FROM device_component_detail dcd
INNER JOIN t_base_part p ON dcd.model_part_id=p.id
LEFT JOIN t_base_language_data ld ON dcd.model_part_id=ld.source_id
WHERE dcd.device_component_id=#{componentId} AND ld.language_code=#{language}
</select>
</mapper>