fix: 一些调整优化

This commit is contained in:
曹鹏飞 2025-05-04 18:22:28 +08:00
parent e2c49908fc
commit e6b76fd135
7 changed files with 58 additions and 5 deletions

View File

@ -16,12 +16,12 @@ import com.nflg.mobilebroken.common.pojo.PageData;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentImportExcel;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceTypeVO;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.EecExcelUtil;
import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.Device;
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
import com.nflg.mobilebroken.repository.entity.DeviceComponentDetail;
import com.nflg.mobilebroken.repository.entity.TBasePart;
@ -72,8 +72,8 @@ public class DeviceComponentController extends ControllerBase {
@PostMapping("getList")
@ApiMark(moduleName = "机型部件管理", apiName = "获取设备机型列表")
public ApiResult<PageData<DeviceTypeVO>> getList(@RequestBody DeviceComponentQuery query){
List<Device> devices=deviceService.lambdaQuery().select(Device::getDeviceType,Device::getModelNo).eq(Device::getDataValidState,true).list();
Map<String,List<Device>> mps=devices.stream().collect(Collectors.groupingBy(Device::getDeviceType));
List<DeviceComponent1VO> deviceComponents=deviceComponentService.getWithDeviceType(query.getModelNo(),query.getComponentSort());
Map<String,List<DeviceComponent1VO>> mps=deviceComponents.stream().collect(Collectors.groupingBy(DeviceComponent1VO::getDeviceType));
AtomicInteger index= new AtomicInteger();
int first=(query.getPage()-1)*query.getPageSize();
int last=query.getPage()*query.getPageSize();
@ -84,6 +84,7 @@ public class DeviceComponentController extends ControllerBase {
DeviceTypeVO vo=new DeviceTypeVO();
vo.setDeviceType(k);
vo.setItems(v.stream().map(d -> new DeviceComponentVO()
.setId(d.getId())
.setModelNo(d.getModelNo())
.setPartList(deviceComponentDetailService.getByModelNo(d.getModelNo()))).collect(Collectors.toList())
);

View File

@ -9,7 +9,7 @@ public class DeviceComponentQuery extends PageBaseQuery{
private String modelNo;
private String component;
// private String component;
/**
* 组件排序true:有组件在前false:无组件在前null:按id倒序

View File

@ -0,0 +1,21 @@
package com.nflg.mobilebroken.common.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class DeviceComponent1VO {
private Integer id;
/**
* 设备机型
*/
private String modelNo;
/**
* 设备类型
*/
private String deviceType;
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
import org.apache.ibatis.annotations.Param;
@ -30,4 +31,6 @@ public interface DeviceComponentMapper extends BaseMapper<DeviceComponent> {
Page<DeviceComponentVO> selectListByPage(@Param("page") Page<PageBaseQuery> page, @Param("query") DeviceComponentQuery query);
List<DevComponentExcel> getExportData();
List<DeviceComponent1VO> getWithDeviceType(String modelNo, Boolean componentSort);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
import org.apache.ibatis.annotations.Param;
@ -38,4 +39,6 @@ public interface IDeviceComponentService extends IService<DeviceComponent> {
Boolean saveOrUpdateBatchComponent(List<DeviceComponent> data);
List<DevComponentExcel> getExportData();
List<DeviceComponent1VO> getWithDeviceType(String modelNo, Boolean componentSort);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
import com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper;
@ -63,7 +64,10 @@ public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMappe
return this.getBaseMapper().getExportData();
}
@Override
public List<DeviceComponent1VO> getWithDeviceType(String modelNo, Boolean componentSort) {
return this.getBaseMapper().getWithDeviceType(modelNo,componentSort);
}
}

View File

@ -29,4 +29,25 @@
join device_component_detail b on a.id=b.device_component_id
join t_base_part c on b.model_part_id=c.id
</select>
<select id="getWithDeviceType" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO">
SELECT d.device_type, dc.id, dc.model_no
FROM device d
LEFT JOIN device_component dc ON d.model_no = dc.model_no AND dc.`enable` = 1
WHERE d.data_valid_state = 1
<if test="modelNo!=null and modelNo!=''">
AND d.model_no = #{modelNo}
</if>
GROUP BY d.device_type, dc.id, dc.model_no
ORDER BY dc.id DESC
<!-- <if test="componentSort==null">-->
<!-- ORDER BY dc.id DESC-->
<!-- </if>-->
<!-- <if test="componentSort==true">-->
<!-- ORDER BY LENGTH(dc.component) > 0, dc.id DESC-->
<!-- </if>-->
<!-- <if test="componentSort==false">-->
<!-- ORDER BY LENGTH(dc.component) = 0, dc.id DESC-->
<!-- </if>-->
</select>
</mapper>