部件管理-设备机型改造
This commit is contained in:
parent
a7733755f1
commit
6a66ac7048
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.mobilebroken.admin.controller;
|
package com.nflg.mobilebroken.admin.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||||
|
|
@ -10,18 +11,19 @@ import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
|
||||||
import com.nflg.mobilebroken.admin.pojo.query.PartQuery;
|
import com.nflg.mobilebroken.admin.pojo.query.PartQuery;
|
||||||
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
|
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
|
||||||
import com.nflg.mobilebroken.admin.pojo.vo.DeviceExcelVO;
|
import com.nflg.mobilebroken.admin.pojo.vo.DeviceExcelVO;
|
||||||
|
import com.nflg.mobilebroken.admin.pojo.vo.PositionLanguageVO;
|
||||||
import com.nflg.mobilebroken.admin.service.AdminBasePartService;
|
import com.nflg.mobilebroken.admin.service.AdminBasePartService;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||||
import com.nflg.mobilebroken.common.pojo.dto.ExportPartDTO;
|
import com.nflg.mobilebroken.common.pojo.dto.ExportPartDTO;
|
||||||
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponentDetail;
|
import com.nflg.mobilebroken.repository.entity.*;
|
||||||
import com.nflg.mobilebroken.repository.entity.Language;
|
|
||||||
import com.nflg.mobilebroken.repository.entity.TBasePart;
|
|
||||||
import com.nflg.mobilebroken.repository.service.IDeviceComponentDetailService;
|
import com.nflg.mobilebroken.repository.service.IDeviceComponentDetailService;
|
||||||
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
||||||
|
import com.nflg.mobilebroken.repository.service.ITBaseLanguageDataService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBasePartService;
|
import com.nflg.mobilebroken.repository.service.ITBasePartService;
|
||||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -29,11 +31,14 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.ttzero.excel.entity.*;
|
import org.ttzero.excel.entity.*;
|
||||||
|
import org.ttzero.excel.reader.ExcelReader;
|
||||||
|
import org.ttzero.excel.reader.Row;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -61,19 +66,50 @@ public class BasePartController extends ControllerBase{
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ILanguageService languageService;
|
ILanguageService languageService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ITBaseLanguageDataService languageDataService;
|
||||||
/**
|
/**
|
||||||
* 获取部件列表
|
* 获取部件列表
|
||||||
* @param query
|
* @param query
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("getList")
|
@PostMapping("getList")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "获取部门列表")
|
@ApiMark(moduleName = "部件管理", apiName = "获取部件列表")
|
||||||
public ApiResult<PageData<TBasePart>> getList(@RequestBody PartQuery query){
|
public ApiResult<PageData<TBasePart>> getList(@RequestBody PartQuery query){
|
||||||
Page<TBasePart> result = partService.selectListByPage(query);
|
Page<TBasePart> result = partService.selectListByPage(query);
|
||||||
return ApiResult.success(result.getRecords(),query,result.getTotal());
|
return ApiResult.success(result.getRecords(),query,result.getTotal());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部件详情
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("getDetail")
|
||||||
|
@ApiMark(moduleName = "部件管理", apiName = "获取部件详情")
|
||||||
|
public ApiResult<BasePartDTO> getDetail(@RequestParam("id") Integer id){
|
||||||
|
TBasePart tBasePart = partService.getBaseMapper().selectById(id);
|
||||||
|
|
||||||
|
|
||||||
|
VUtils.trueThrow(tBasePart==null).throwMessage(STATE.ParamErr,"部件不存在");
|
||||||
|
BasePartDTO result= Convert.convert(BasePartDTO.class, tBasePart);
|
||||||
|
result.setLanguage(new ArrayList<>());
|
||||||
|
List<TBaseLanguageData> lanData = languageDataService.lambdaQuery().eq(TBaseLanguageData::getSourceId, id).list();
|
||||||
|
lanData.forEach(u->{
|
||||||
|
PositionLanguageVO v=new PositionLanguageVO();
|
||||||
|
v.setCode(u.getLanguageCode());
|
||||||
|
v.setLanguageValue(u.getLanguageValue());
|
||||||
|
v.setName(u.getLanguageName());
|
||||||
|
result.getLanguage().add(v);
|
||||||
|
});
|
||||||
|
return ApiResult.success(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存 id>0 时为修改
|
* 保存 id>0 时为修改
|
||||||
* @param basePartDTO
|
* @param basePartDTO
|
||||||
|
|
@ -136,7 +172,7 @@ public class BasePartController extends ControllerBase{
|
||||||
@ApiMark(moduleName = "部件管理", apiName = "下载导入模板")
|
@ApiMark(moduleName = "部件管理", apiName = "下载导入模板")
|
||||||
// @MethodInfoMark(value = "导入模板下载",menuName = "设备管理")
|
// @MethodInfoMark(value = "导入模板下载",menuName = "设备管理")
|
||||||
public void downTemplate(HttpServletResponse response) throws IOException {
|
public void downTemplate(HttpServletResponse response) throws IOException {
|
||||||
EecExcelUtil.setResponseExcelHeader(response,"设备导入模板");
|
EecExcelUtil.setResponseExcelHeader(response,"部件导入模板");
|
||||||
List<Object> rows = new ArrayList<>();
|
List<Object> rows = new ArrayList<>();
|
||||||
rows.add(adminBasePartService.buildExcelHeader());
|
rows.add(adminBasePartService.buildExcelHeader());
|
||||||
new Workbook()
|
new Workbook()
|
||||||
|
|
@ -144,9 +180,51 @@ public class BasePartController extends ControllerBase{
|
||||||
.writeTo(response.getOutputStream());
|
.writeTo(response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("enable")
|
||||||
|
@MethodInfoMark(value = "启用",menuName = "部件管理")
|
||||||
|
public ApiResult<Boolean> enable(@RequestBody List<Long> ids ){
|
||||||
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
||||||
|
partService.lambdaUpdate().in(TBasePart::getId,ids).set(TBasePart::getEnable,1);
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("disable")
|
||||||
|
@MethodInfoMark(value = "禁用",menuName = "部件管理")
|
||||||
|
public ApiResult<Boolean> disable(@RequestBody List<Long> ids ){
|
||||||
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要禁用的数据");
|
||||||
|
partService.lambdaUpdate().in(TBasePart::getId,ids).set(TBasePart::getEnable,0);
|
||||||
|
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("importData")
|
@PostMapping("importData")
|
||||||
@ApiMark(moduleName = "部件管理", apiName = "导入")
|
@ApiMark(moduleName = "部件管理", apiName = "导入")
|
||||||
public ApiResult<Boolean> importData( @RequestParam(value = "file") MultipartFile file){
|
public ApiResult<Boolean> importData( @RequestParam(value = "file") MultipartFile file){
|
||||||
|
List<Map<String,Object>> result=new ArrayList<>();
|
||||||
|
try (ExcelReader reader = ExcelReader.read(file.getInputStream())) {
|
||||||
|
reader.sheet(0)
|
||||||
|
.header(1)
|
||||||
|
.rows()
|
||||||
|
.map(Row::toMap)
|
||||||
|
.forEach(u->{
|
||||||
|
result.add(u);
|
||||||
|
});
|
||||||
|
adminBasePartService.importHandler(result);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
return ApiResult.success(true);
|
return ApiResult.success(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||||
import com.nflg.mobilebroken.admin.pojo.dto.DeviceComponentDTO;
|
import com.nflg.mobilebroken.admin.pojo.dto.DeviceComponentDTO;
|
||||||
import com.nflg.mobilebroken.admin.pojo.dto.DeviceComponentDetailDTO;
|
import com.nflg.mobilebroken.admin.pojo.dto.DeviceComponentDetailDTO;
|
||||||
import com.nflg.mobilebroken.admin.pojo.query.DeviceComponentQuery;
|
import com.nflg.mobilebroken.admin.pojo.query.DeviceComponentQuery;
|
||||||
import com.nflg.mobilebroken.admin.pojo.vo.DeviceExcelVO;
|
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentDetailVO;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
|
|
@ -64,10 +65,11 @@ public class DeviceComponentController extends ControllerBase {
|
||||||
*/
|
*/
|
||||||
@PostMapping("getList")
|
@PostMapping("getList")
|
||||||
@ApiMark(moduleName = "机型部件管理", apiName = "获取设备机型列表")
|
@ApiMark(moduleName = "机型部件管理", apiName = "获取设备机型列表")
|
||||||
public ApiResult<PageData<DeviceComponent>> getList(@RequestBody DeviceComponentQuery query){
|
public ApiResult<PageData<DeviceComponentVO>> getList(@RequestBody DeviceComponentQuery query){
|
||||||
Page<DeviceComponent> result = deviceComponentService.selectListByPage(query);
|
Page<DeviceComponentVO> result = deviceComponentService.selectListByPage(query);
|
||||||
result.getRecords().forEach(u->{
|
result.getRecords().forEach(u->{
|
||||||
u.setPartList(deviceComponentDetailService.lambdaQuery().eq(DeviceComponentDetail::getDeviceComponentId,u.getId()).list());
|
List<DeviceComponentDetail> detail = deviceComponentDetailService.lambdaQuery().eq(DeviceComponentDetail::getDeviceComponentId, u.getId()).list();
|
||||||
|
u.setPartList(Convert.toList(DeviceComponentDetailVO.class,detail));
|
||||||
});
|
});
|
||||||
return ApiResult.success(result.getRecords(),query,result.getTotal());
|
return ApiResult.success(result.getRecords(),query,result.getTotal());
|
||||||
}
|
}
|
||||||
|
|
@ -181,7 +183,7 @@ public class DeviceComponentController extends ControllerBase {
|
||||||
List<DevComponentExcel> data = EecExcelUtil.getExcelContext(file.getInputStream(), DevComponentExcel.class);
|
List<DevComponentExcel> data = EecExcelUtil.getExcelContext(file.getInputStream(), DevComponentExcel.class);
|
||||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空");
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空");
|
||||||
Set<String> modeNos = data.stream().map(u -> u.getModelNo()).collect(Collectors.toSet());
|
Set<String> modeNos = data.stream().map(u -> u.getModelNo()).collect(Collectors.toSet());
|
||||||
List<DeviceComponent> extstsModes = deviceComponentService.lambdaQuery().in(DeviceComponent::getModelNo).list();
|
List<DeviceComponent> extstsModes = deviceComponentService.lambdaQuery().in(DeviceComponent::getModelNo,modeNos).list();
|
||||||
Set<String> extstsModesSet = extstsModes.stream().map(u -> u.getModelNo()).collect(Collectors.toSet());
|
Set<String> extstsModesSet = extstsModes.stream().map(u -> u.getModelNo()).collect(Collectors.toSet());
|
||||||
Set<String> difference = Sets.difference(modeNos, extstsModesSet);
|
Set<String> difference = Sets.difference(modeNos, extstsModesSet);
|
||||||
VUtils.trueThrow(CollUtil.isNotEmpty(difference)).throwMessage(STATE.ParamErr, StrUtil.join(",", difference)+" 设备机型不存");
|
VUtils.trueThrow(CollUtil.isNotEmpty(difference)).throwMessage(STATE.ParamErr, StrUtil.join(",", difference)+" 设备机型不存");
|
||||||
|
|
@ -190,7 +192,7 @@ public class DeviceComponentController extends ControllerBase {
|
||||||
List<TBasePart> exitsParts = basePartService.lambdaQuery().in(TBasePart::getPartName, partNames).list();
|
List<TBasePart> exitsParts = basePartService.lambdaQuery().in(TBasePart::getPartName, partNames).list();
|
||||||
Set<String> exitsPartSet = exitsParts.stream().map(u -> u.getPartName()).collect(Collectors.toSet());
|
Set<String> exitsPartSet = exitsParts.stream().map(u -> u.getPartName()).collect(Collectors.toSet());
|
||||||
Set<String> diffParts = Sets.difference(partNames, exitsPartSet);
|
Set<String> diffParts = Sets.difference(partNames, exitsPartSet);
|
||||||
VUtils.trueThrow(CollUtil.isNotEmpty(diffParts)).throwMessage(STATE.ParamErr,StrUtil.join(",", diffParts)+" 部门名称不存在,请在部件管理中维护");
|
VUtils.trueThrow(CollUtil.isNotEmpty(diffParts)).throwMessage(STATE.ParamErr,StrUtil.join(",", diffParts)+" 部件名称不存在,请在部件管理中维护");
|
||||||
|
|
||||||
Map<String, List<DevComponentExcel>> dataMap = data.stream().collect(Collectors.groupingBy(DevComponentExcel::getModelNo));
|
Map<String, List<DevComponentExcel>> dataMap = data.stream().collect(Collectors.groupingBy(DevComponentExcel::getModelNo));
|
||||||
Map<String, DeviceComponent> extstsModeMap = extstsModes.stream().collect(Collectors.toMap(DeviceComponent::getModelNo, u -> u));
|
Map<String, DeviceComponent> extstsModeMap = extstsModes.stream().collect(Collectors.toMap(DeviceComponent::getModelNo, u -> u));
|
||||||
|
|
@ -242,7 +244,7 @@ public class DeviceComponentController extends ControllerBase {
|
||||||
@GetMapping("exportData")
|
@GetMapping("exportData")
|
||||||
@ApiMark(moduleName = "机型部件管理", apiName = "导出部件")
|
@ApiMark(moduleName = "机型部件管理", apiName = "导出部件")
|
||||||
public void exportData(HttpServletResponse response) throws IOException {
|
public void exportData(HttpServletResponse response) throws IOException {
|
||||||
EecExcelUtil.setResponseExcelHeader(response,"部件列表");
|
EecExcelUtil.setResponseExcelHeader(response,"机型部件管理");
|
||||||
List<DevComponentExcel> list = deviceComponentService.getExportData();
|
List<DevComponentExcel> list = deviceComponentService.getExportData();
|
||||||
if(CollUtil.isEmpty(list)) {
|
if(CollUtil.isEmpty(list)) {
|
||||||
throw new NflgException(STATE.BusinessError, "没有可导出的数据");
|
throw new NflgException(STATE.BusinessError, "没有可导出的数据");
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,10 @@ public class BasePartDTO {
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部件编码
|
||||||
|
*/
|
||||||
|
private String partNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部件名称
|
* 部件名称
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,9 @@ public class PartQuery extends PageBaseQuery {
|
||||||
* 部件名称
|
* 部件名称
|
||||||
*/
|
*/
|
||||||
private String partName;
|
private String partName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 0-禁用 1-启用
|
||||||
|
*/
|
||||||
|
private Integer enable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.mobilebroken.admin.service;
|
package com.nflg.mobilebroken.admin.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
@ -13,7 +14,9 @@ import com.nflg.mobilebroken.repository.entity.TBaseLanguageData;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBasePart;
|
import com.nflg.mobilebroken.repository.entity.TBasePart;
|
||||||
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseLanguageDataService;
|
import com.nflg.mobilebroken.repository.service.ITBaseLanguageDataService;
|
||||||
|
import com.nflg.mobilebroken.repository.service.ITBasePartService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.ttzero.excel.entity.Column;
|
import org.ttzero.excel.entity.Column;
|
||||||
import org.ttzero.excel.manager.Const;
|
import org.ttzero.excel.manager.Const;
|
||||||
|
|
||||||
|
|
@ -21,6 +24,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -32,6 +36,11 @@ public class AdminBasePartService {
|
||||||
@Resource
|
@Resource
|
||||||
ILanguageService languageService;
|
ILanguageService languageService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ITBasePartService partService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
|
|
@ -87,4 +96,44 @@ public class AdminBasePartService {
|
||||||
}
|
}
|
||||||
return excelColumns;
|
return excelColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入处理
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void importHandler(List<Map<String,Object>> data){
|
||||||
|
List<Language> languages = languageService.lambdaQuery().eq(Language::getEnable, 1).list();
|
||||||
|
List<TBaseLanguageData> languageDataList=new ArrayList<>();
|
||||||
|
for ( Map<String,Object> mp: data) {
|
||||||
|
String partName = mp.get("部件名称").toString();
|
||||||
|
TBasePart partEnt = partService.lambdaQuery().eq(TBasePart::getPartName, partName).one();
|
||||||
|
if(partEnt==null){
|
||||||
|
partEnt=new TBasePart();
|
||||||
|
partEnt.setPartNo(UniqueSequenceGenerator.generateCode(Constant.PartCodePrefix));
|
||||||
|
partEnt.setPartName(partName);
|
||||||
|
partEnt.setEnable(1);
|
||||||
|
partEnt.setCreateBy(AdminUserUtil.getUserName());
|
||||||
|
partEnt.setCreateTime(LocalDateTime.now());
|
||||||
|
partEnt.setUpdateBy(AdminUserUtil.getUserName());
|
||||||
|
partEnt.setUpdateTime(LocalDateTime.now());
|
||||||
|
partService.save(partEnt);
|
||||||
|
}
|
||||||
|
languageDataList.clear();
|
||||||
|
for (Language u :languages) {
|
||||||
|
TBaseLanguageData languageData=new TBaseLanguageData();
|
||||||
|
languageData.setSourceId(Convert.convert(Long.class, partEnt.getId()) );
|
||||||
|
languageData.setLanguageCode(u.getCode());
|
||||||
|
languageData.setLanguageName(u.getName());
|
||||||
|
languageData.setLanguageValue(mp.get(u.getName()).toString()) ;
|
||||||
|
languageDataList.add(languageData);
|
||||||
|
};
|
||||||
|
if(CollUtil.isNotEmpty(languageDataList)){
|
||||||
|
languageDataService.removeByMap(ImmutableMap.of("source_id",partEnt.getId()));
|
||||||
|
languageDataService.saveBatch(languageDataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 机型部件详情
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("device_component_detail")
|
||||||
|
public class DeviceComponentDetailVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备机型id
|
||||||
|
*/
|
||||||
|
private Integer deviceComponentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机型部件ID
|
||||||
|
*/
|
||||||
|
private Integer modelPartId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机型部件名称
|
||||||
|
*/
|
||||||
|
private String modelPartName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceComponentVO {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备机型
|
||||||
|
*/
|
||||||
|
private String modelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机型部件
|
||||||
|
*/
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
private Boolean enable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
List<DeviceComponentDetailVO> partList;
|
||||||
|
}
|
||||||
|
|
@ -65,8 +65,4 @@ public class DeviceComponent implements Serializable {
|
||||||
*/
|
*/
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 机型部件列表
|
|
||||||
*/
|
|
||||||
List<DeviceComponentDetail> partList;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import java.time.LocalDateTime;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_base_part")
|
@TableName("t_base_language_data")
|
||||||
public class TBaseLanguageData implements Serializable {
|
public class TBaseLanguageData implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.mapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -25,7 +26,7 @@ public interface DeviceComponentMapper extends BaseMapper<DeviceComponent> {
|
||||||
* @param query
|
* @param query
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Page<DeviceComponent> selectListByPage(@Param("page") Page<PageBaseQuery> page, @Param("query") PageBaseQuery query);
|
Page<DeviceComponentVO> selectListByPage(@Param("page") Page<PageBaseQuery> page, @Param("query") PageBaseQuery query);
|
||||||
|
|
||||||
List<DevComponentExcel> getExportData();
|
List<DevComponentExcel> getExportData();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -26,7 +27,7 @@ public interface IDeviceComponentService extends IService<DeviceComponent> {
|
||||||
* @param query
|
* @param query
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Page<DeviceComponent> selectListByPage( @Param("query") PageBaseQuery query);
|
Page<DeviceComponentVO> selectListByPage(@Param("query") PageBaseQuery query);
|
||||||
|
|
||||||
DeviceComponent saveComponent(DeviceComponent component);
|
DeviceComponent saveComponent(DeviceComponent component);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service.impl;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper;
|
import com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
||||||
|
|
@ -30,7 +31,7 @@ public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMappe
|
||||||
* @param query
|
* @param query
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Page<DeviceComponent> selectListByPage( @Param("query") PageBaseQuery query){
|
public Page<DeviceComponentVO> selectListByPage(@Param("query") PageBaseQuery query){
|
||||||
return this.getBaseMapper().selectListByPage(new Page<>(query.getPage(),query.getPageSize()) ,query);
|
return this.getBaseMapper().selectListByPage(new Page<>(query.getPage(),query.getPageSize()) ,query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +61,7 @@ public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMappe
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DevComponentExcel> getExportData(){
|
public List<DevComponentExcel> getExportData(){
|
||||||
return this.getExportData();
|
return this.getBaseMapper().getExportData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
and component like concat('%',#{query.component} ,"%")
|
and component like concat('%',#{query.component} ,"%")
|
||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectListByPage" resultType="com.nflg.mobilebroken.repository.entity.DeviceComponent">
|
<select id="selectListByPage" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO">
|
||||||
select * from device_component where 1=1
|
select * from device_component where 1=1
|
||||||
<include refid="whr" />
|
<include refid="whr" />
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
<if test="query.partName!=null and query.partName!=''">
|
<if test="query.partName!=null and query.partName!=''">
|
||||||
and part_name like concat('%', #{query.partName},'%')
|
and part_name like concat('%', #{query.partName},'%')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="query.enable!=null">
|
||||||
|
and enable=#{query.enable}
|
||||||
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="getListByPage" resultType="com.nflg.mobilebroken.repository.entity.TBasePart">
|
<select id="getListByPage" resultType="com.nflg.mobilebroken.repository.entity.TBasePart">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue