Merge branch 'feature/gongfu-20260126' into prod/20260203

This commit is contained in:
曹鹏飞 2026-02-03 12:14:37 +08:00
commit 27cd13eb3b
28 changed files with 487 additions and 136 deletions

View File

@ -1,14 +1,22 @@
package com.nflg.mobilebroken.admin.controller;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.pojo.request.TranslateWordRequest;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.Language;
import com.nflg.mobilebroken.repository.service.IDictionaryItemService;
import com.nflg.mobilebroken.repository.service.ILanguageService;
import com.nflg.mobilebroken.starter.service.ITranslate;
import com.nflg.mobilebroken.starter.service.impl.DeepSeekTranslate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Objects;
/**
* 翻译相关
@ -23,6 +31,9 @@ public class TranslateController extends ControllerBase{
@Resource
private DeepSeekTranslate deepSeekTranslate;
@Resource
private ILanguageService languageService;
/**
* 文字翻译
* @param request 请求参数
@ -39,8 +50,16 @@ public class TranslateController extends ControllerBase{
* @return 翻译结果
*/
@PostMapping("deepseek")
public ApiResult<String> deepseek(@RequestParam String text) {
public ApiResult<String> deepseek(HttpServletRequest request, @RequestParam String text) {
String languageCode = request.getHeader("language");
if (StrUtil.isBlank(languageCode)) {
return ApiResult.success("");
}
Language language = languageService.lambdaQuery().eq(Language::getCode, languageCode).one();
if (Objects.isNull(language)) {
return ApiResult.success("");
}
text = text.replaceAll("<br>", ",");
return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", AdminUserUtil.getLanguageName(), "text"));
return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", language.getName(), "text"));
}
}

View File

@ -1,7 +1,10 @@
package com.nflg.mobilebroken.cfs.controller;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.util.AppUserUtil;
import com.nflg.mobilebroken.repository.entity.Language;
import com.nflg.mobilebroken.repository.service.ILanguageService;
import com.nflg.mobilebroken.starter.service.impl.DeepSeekTranslate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -9,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* 翻译相关
@ -20,13 +25,24 @@ public class TranslateController extends ControllerBase {
@Resource
private DeepSeekTranslate deepSeekTranslate;
@Resource
private ILanguageService languageService;
/**
* deepseek翻译
* @param text 要翻译的文本
* @return 翻译结果
*/
@PostMapping("deepseek")
public ApiResult<String> deepseek(@RequestParam String text) {
return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", AppUserUtil.getLanguageName(), "text"));
public ApiResult<String> deepseek(HttpServletRequest request, @RequestParam String text) {
String languageCode = request.getHeader("language");
if (StrUtil.isBlank(languageCode)) {
return ApiResult.success("");
}
Language language = languageService.lambdaQuery().eq(Language::getCode, languageCode).one();
if (Objects.isNull(language)) {
return ApiResult.success("");
}
return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", language.getName(), "text"));
}
}

View File

@ -0,0 +1,20 @@
package com.nflg.mobilebroken.common.pojo.dto;
import lombok.Data;
import org.ttzero.excel.annotation.ExcelColumn;
@Data
public class GongFuDeviceComponentExportDTO extends GongFuDeviceComponentImportDTO{
/**
* 创建人
*/
@ExcelColumn(value = "创建人",colIndex = 2)
private String createBy;
/**
* 创建时间
*/
@ExcelColumn(value = "创建时间",colIndex = 3)
private String createTime;
}

View File

@ -0,0 +1,20 @@
package com.nflg.mobilebroken.common.pojo.dto;
import lombok.Data;
import org.ttzero.excel.annotation.ExcelColumn;
@Data
public class GongFuDeviceComponentImportDTO {
/**
* 产品线
*/
@ExcelColumn("产品线")
private String productLine;
/**
* 机型部件
*/
@ExcelColumn("部件名称")
private String modelPartName;
}

View File

@ -38,6 +38,12 @@ public class SolutionMeasuresSaveRequest {
*/
private List<Integer> imageIds;
/**
* 问题部件id
*/
@NotNull
private Long componentId;
/**
* 解决措施
*/

View File

@ -66,7 +66,7 @@ public class TicketAddRequest {
private String handlerUserName;
/**
* 工单区域id工服工单必填
* 工单区域id
*/
private Long areaId;

View File

@ -20,4 +20,9 @@ public class SolutionMeasuresVO {
// 是否审核通过默认为null表示未审核false不通过true通过
private Boolean approved;
/**
* 部件列表
*/
private List<ComponentInfo> components;
}

View File

@ -2,26 +2,26 @@ package com.nflg.mobilebroken.gongfu.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.nflg.mobilebroken.common.constant.STATE;
import com.nflg.mobilebroken.common.exception.NflgException;
import com.nflg.mobilebroken.common.pojo.ApiResult;
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.gongfu.annotation.ApiMark;
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceComponentDTO;
import com.nflg.mobilebroken.gongfu.pojo.dto.DeviceComponentDetailDTO;
import com.nflg.mobilebroken.common.pojo.dto.GongFuDeviceComponentExportDTO;
import com.nflg.mobilebroken.common.pojo.dto.GongFuDeviceComponentImportDTO;
import com.nflg.mobilebroken.gongfu.pojo.query.GongFuDeviceComponentQuery;
import com.nflg.mobilebroken.gongfu.pojo.vo.GongFuDeviceTypeVO;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponent;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponentDetail;
import com.nflg.mobilebroken.repository.entity.GongfuDevicePart;
@ -29,6 +29,7 @@ import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentDetailServ
import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentService;
import com.nflg.mobilebroken.repository.service.IGongfuDevicePartService;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -41,12 +42,12 @@ import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 机型部件管理
*/
@Slf4j
@RestController
@RequestMapping("/deviceComponent")
public class DeviceComponentController extends ControllerBase {
@ -67,32 +68,66 @@ public class DeviceComponentController extends ControllerBase {
*/
@PostMapping("getList")
@ApiMark(moduleName = "机型部件管理", apiName = "获取设备机型列表")
public ApiResult<PageData<DeviceTypeVO>> getList(@RequestBody DeviceComponentQuery query) {
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();
PageData<DeviceTypeVO> pageData = new PageData<>();
List<DeviceTypeVO> items = new ArrayList<>();
mps.forEach((k, v) -> {
if (index.get() >= first && index.get() < last) {
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())
);
items.add(vo);
}
index.getAndIncrement();
public ApiResult<PageData<GongFuDeviceTypeVO>> getList(@RequestBody GongFuDeviceComponentQuery query) {
// List<DeviceComponent1VO> deviceComponents = deviceComponentService.getByProductLine(query.getProductLine(), 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();
// PageData<DeviceTypeVO> pageData = new PageData<>();
// List<DeviceTypeVO> items = new ArrayList<>();
// mps.forEach((k, v) -> {
// if (index.get() >= first && index.get() < last) {
// 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())
// );
// items.add(vo);
// }
// index.getAndIncrement();
// });
// pageData.setItems(items);
// pageData.setPage(query.getPage());
// pageData.setPageSize(query.getPageSize());
// pageData.setTotal(mps.size());
// return ApiResult.success(pageData);
List<GongfuDeviceComponent> productLines = deviceComponentService.lambdaQuery()
.select(GongfuDeviceComponent::getId, GongfuDeviceComponent::getProductLine)
.eq(GongfuDeviceComponent::getEnable, true)
.like(StrUtil.isNotBlank(query.getProductLine()), GongfuDeviceComponent::getProductLine, query.getProductLine())
.list();
List<GongfuDeviceComponentDetail> details = deviceComponentDetailService.list();
List<GongFuDeviceTypeVO> datas = new ArrayList<>();
productLines.forEach(p -> {
GongFuDeviceTypeVO vo = datas.stream()
.filter(d -> StrUtil.equals(p.getProductLine(), d.getProductLine()))
.findFirst()
.orElseGet(() -> {
GongFuDeviceTypeVO v = new GongFuDeviceTypeVO()
.setId(p.getId())
.setProductLine(p.getProductLine());
datas.add(v);
return v;
});
vo.getItems().addAll(
details.stream()
.filter(d -> Objects.equals(d.getDeviceComponentId(), p.getId()))
.collect(Collectors.toList())
);
});
pageData.setItems(items);
pageData.setPage(query.getPage());
pageData.setPageSize(query.getPageSize());
pageData.setTotal(mps.size());
return ApiResult.success(pageData);
if (query.getComponentSort()) {
datas.sort(Comparator.comparing(GongFuDeviceTypeVO::getSort).reversed());
} else {
datas.sort(Comparator.comparing(GongFuDeviceTypeVO::getSort));
}
List<GongFuDeviceTypeVO> pageData = datas.stream()
.skip((long) (query.getPage() - 1) * query.getPageSize())
.limit(query.getPageSize())
.collect(Collectors.toList());
return ApiResult.success(pageData, query, datas.size());
}
/**
@ -181,10 +216,9 @@ public class DeviceComponentController extends ControllerBase {
// @MethodInfoMark(value = "导入模板下载",menuName = "设备管理")
public void downTemplate(HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "机型部件导入模板");
final ListSheet<DevComponentImportExcel> listSheet = new ListSheet<DevComponentImportExcel>() {
final ListSheet<GongFuDeviceComponentImportDTO> listSheet = new ListSheet<>() {
@Override
protected List<DevComponentImportExcel> more() {
protected List<GongFuDeviceComponentImportDTO> more() {
return null;
}
};
@ -196,13 +230,14 @@ public class DeviceComponentController extends ControllerBase {
* 检查重复行
* @param list
*/
private List<String> checkDuplicates(List<DevComponentExcel> list) {
private List<String> checkDuplicates(List<GongFuDeviceComponentImportDTO> list) {
List<String> checkResult = new ArrayList<>();
list.stream()
.collect(Collectors.groupingBy(d -> d.getModelNo() + "-" + d.getModelPartName()))
.entrySet().stream()
.collect(Collectors.groupingBy(d -> d.getProductLine() + "-" + d.getModelPartName()))
.entrySet()
.stream()
.filter(e -> e.getValue().size() > 1)
.forEach(e -> checkResult.add(e.getKey() + " -> " + e.getValue()));
.forEach(e -> checkResult.add(e.getKey().replace("-","->")));
return checkResult;
}
@ -211,61 +246,80 @@ public class DeviceComponentController extends ControllerBase {
* @param file
* @return
*/
@Transactional
@PostMapping("importData")
public ApiResult<Boolean> importData(@RequestParam(value = "file") MultipartFile file) {
try {
List<DevComponentExcel> data = EecExcelUtil.getExcelContext(file.getInputStream(), DevComponentExcel.class);
List<GongFuDeviceComponentImportDTO> data = EecExcelUtil.getExcelContext(file.getInputStream(), GongFuDeviceComponentImportDTO.class);
VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空");
//检查内容是否重复
List<String> checkResult = checkDuplicates(data);
VUtils.trueThrow(CollUtil.isNotEmpty(checkResult)).throwMessage(STATE.PageError, StrUtil.join(",", checkResult) + "内容重复,请检查导入的数据");
Set<String> modeNos = data.stream().map(DevComponentExcel::getModelNo).collect(Collectors.toSet());
List<GongfuDeviceComponent> extstsModes = deviceComponentService.lambdaQuery().in(GongfuDeviceComponent::getModelNo, modeNos).list();
Set<String> extstsModesSet = extstsModes.stream().map(GongfuDeviceComponent::getModelNo).collect(Collectors.toSet());
Set<String> difference = Sets.difference(modeNos, extstsModesSet);
VUtils.trueThrow(CollUtil.isNotEmpty(difference)).throwMessage(STATE.ParamErr, StrUtil.join(",", difference) + " 设备机型不存");
VUtils.trueThrow(CollUtil.isNotEmpty(checkResult)).throwMessage(STATE.PageError, "以下内容重复:"+StrUtil.join(",", checkResult));
//检查部件是否存在
Set<String> partNames = data.stream().map(DevComponentExcel::getModelPartName).collect(Collectors.toSet());
Set<String> partNames = data.stream().map(GongFuDeviceComponentImportDTO::getModelPartName).collect(Collectors.toSet());
List<GongfuDevicePart> exitsParts = basePartService.lambdaQuery().in(GongfuDevicePart::getPartName, partNames).list();
Set<String> exitsPartSet = exitsParts.stream().map(GongfuDevicePart::getPartName).collect(Collectors.toSet());
Set<String> diffParts = Sets.difference(partNames, exitsPartSet);
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, GongfuDeviceComponent> extstsModeMap = extstsModes.stream().collect(Collectors.toMap(GongfuDeviceComponent::getModelNo, u -> u));
Map<String, List<GongFuDeviceComponentImportDTO>> dataMap = data.stream().collect(Collectors.groupingBy(GongFuDeviceComponentImportDTO::getProductLine));
List<GongfuDeviceComponent> exitsComponent = deviceComponentService.list();
Map<String, GongfuDeviceComponent> extstsModeMap = exitsComponent.stream().collect(Collectors.toMap(GongfuDeviceComponent::getProductLine, u -> u));
Map<String, GongfuDevicePart> exitsPartMap = exitsParts.stream().collect(Collectors.toMap(GongfuDevicePart::getPartName, u -> u));
List<GongfuDeviceComponentDetail> result = new ArrayList<>();
List<GongfuDeviceComponent> deviceComponentResult = new ArrayList<>();
List<GongfuDeviceComponentDetail> details = new ArrayList<>();
List<GongfuDeviceComponent> componentsForAdd = new ArrayList<>();
List<GongfuDeviceComponent> componentsForUpdate = new ArrayList<>();
for (String key : dataMap.keySet()) {
List<DevComponentExcel> componments = dataMap.get(key);
GongfuDeviceComponent dev = new GongfuDeviceComponent();
dev.setId(extstsModeMap.get(key).getId());
dev.setComponent(StrUtil.join(",", componments.stream().map(DevComponentExcel::getModelPartName).collect(Collectors.toSet())));
deviceComponentResult.add(dev);
//删除现有部件
deviceComponentDetailService.removeByMap(ImmutableMap.of("device_component_id", dev.getId()));
for (DevComponentExcel componment : componments) {
GongfuDeviceComponentDetail ent = new GongfuDeviceComponentDetail();
ent.setDeviceComponentId(extstsModeMap.get(key).getId());
ent.setModelPartId(exitsPartMap.get(componment.getModelPartName()).getId());
ent.setModelPartName(componment.getModelPartName());
ent.setCreateBy(AdminUserUtil.getUserName());
ent.setCreateTime(LocalDateTime.now());
result.add(ent);
Set<String> components = dataMap.get(key).stream()
.map(GongFuDeviceComponentImportDTO::getModelPartName)
.collect(Collectors.toSet());
if (extstsModeMap.containsKey(key)) {
StrUtil.split(extstsModeMap.get(key).getComponent(), ",").forEach(components::remove);
if (CollectionUtil.isNotEmpty(components)) {
GongfuDeviceComponent dev = extstsModeMap.get(key);
dev.setComponent(dev.getComponent() + "," + StrUtil.join(",", components));
dev.setUpdateBy(AdminUserUtil.getUserName());
dev.setUpdateTime(LocalDateTime.now());
componentsForUpdate.add(dev);
for (String component : components) {
GongfuDeviceComponentDetail ent = new GongfuDeviceComponentDetail();
ent.setDeviceComponentId(extstsModeMap.get(key).getId());
ent.setModelPartId(exitsPartMap.get(component).getId());
ent.setModelPartName(component);
ent.setCreateBy(AdminUserUtil.getUserName());
ent.setCreateTime(LocalDateTime.now());
details.add(ent);
}
}
} else {
GongfuDeviceComponent dev = new GongfuDeviceComponent();
dev.setId(IdUtil.getSnowflakeNextId());
dev.setProductLine(key);
dev.setComponent(StrUtil.join(",", components));
dev.setCreateBy(AdminUserUtil.getUserName());
dev.setCreateTime(LocalDateTime.now());
componentsForAdd.add(dev);
for (String component : components) {
GongfuDeviceComponentDetail ent = new GongfuDeviceComponentDetail();
ent.setDeviceComponentId(dev.getId());
ent.setModelPartId(exitsPartMap.get(component).getId());
ent.setModelPartName(component);
ent.setCreateBy(AdminUserUtil.getUserName());
ent.setCreateTime(LocalDateTime.now());
details.add(ent);
}
}
}
if (CollUtil.isNotEmpty(deviceComponentResult)) {
deviceComponentService.saveOrUpdateBatch(deviceComponentResult);
if (CollUtil.isNotEmpty(componentsForAdd)) {
deviceComponentService.saveBatch(componentsForAdd);
}
if (CollUtil.isNotEmpty(result)) {
deviceComponentDetailService.saveOrUpdateBatch(result);
if (CollUtil.isNotEmpty(componentsForUpdate)) {
deviceComponentService.updateBatchById(componentsForUpdate);
}
if (CollUtil.isNotEmpty(details)) {
deviceComponentDetailService.saveOrUpdateBatch(details);
}
} catch (IOException e) {
throw new NflgException(STATE.BusinessError, "导入失败:" + e.getMessage());
}
@ -276,13 +330,12 @@ public class DeviceComponentController extends ControllerBase {
/**
* 导出部件
* @param response
* @throws IOException
*/
@GetMapping("exportData")
@ApiMark(moduleName = "机型部件管理", apiName = "导出部件")
public void exportData(HttpServletResponse response) throws IOException {
public void exportData(HttpServletResponse response) {
EecExcelUtil.setResponseExcelHeader(response, "机型部件管理");
List<DevComponentExcel> list = deviceComponentService.getExportData();
List<GongFuDeviceComponentExportDTO> list = deviceComponentService.getExportData();
if (CollUtil.isEmpty(list)) {
throw new NflgException(STATE.BusinessError, "没有可导出的数据");
}

View File

@ -456,9 +456,9 @@ public class DeviceController extends ControllerBase {
ent.setDataModifyTime(LocalDateTime.now());
deviceTypes.add(ent);
}
if (!deviceComponentService.lambdaQuery().eq(GongfuDeviceComponent::getModelNo, dto.getModelNo()).exists()) {
if (!deviceComponentService.lambdaQuery().eq(GongfuDeviceComponent::getProductLine, dto.getProductLine()).exists()) {
GongfuDeviceComponent ent = new GongfuDeviceComponent();
ent.setModelNo(dto.getModelNo());
ent.setProductLine(dto.getProductLine());
ent.setComponent("");
ent.setEnable(true);
ent.setCreateBy(AdminUserUtil.getUserName());
@ -714,9 +714,9 @@ public class DeviceController extends ControllerBase {
ent.setDataModifyTime(LocalDateTime.now());
deviceTypes.add(ent);
}
if (!deviceComponentService.lambdaQuery().eq(GongfuDeviceComponent::getModelNo, dto.getModelNo()).exists()) {
if (!deviceComponentService.lambdaQuery().eq(GongfuDeviceComponent::getProductLine, dto.getProductLine()).exists()) {
GongfuDeviceComponent ent = new GongfuDeviceComponent();
ent.setModelNo(dto.getModelNo());
ent.setProductLine(dto.getProductLine());
ent.setComponent("");
ent.setEnable(true);
ent.setCreateBy(AdminUserUtil.getUserName());

View File

@ -0,0 +1,139 @@
package com.nflg.mobilebroken.gongfu.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.repository.entity.GongfuDevice;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponent;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponentDetail;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentDetailService;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceComponentService;
import com.nflg.mobilebroken.repository.service.IGongfuDeviceService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 测试
*/
@RestController
@RequestMapping("/test")
public class TestController extends ControllerBase {
@Resource
private IGongfuDeviceService gongfuDeviceService;
@Resource
private IGongfuDeviceComponentService gongfuDeviceComponentService;
@Resource
private IGongfuDeviceComponentDetailService gongfuDeviceComponentDetailService;
/**
* 初始化设备组件中的产品线数据
*/
@Transactional
@GetMapping("initDeviceComponentProductLine")
public ApiResult<Void> initDeviceComponentProductLine() {
List<GongfuDeviceComponent> deviceComponents = gongfuDeviceComponentService
.lambdaQuery()
.isNull(GongfuDeviceComponent::getProductLine)
.list();
if (CollectionUtil.isEmpty(deviceComponents)) {
return ApiResult.success();
}
List<GongfuDevice> devices = gongfuDeviceService.lambdaQuery()
.select(GongfuDevice::getModelNo, GongfuDevice::getProductLine)
.eq(GongfuDevice::getDataValidState, 1)
.list();
List<GongfuDeviceComponent> forUpdate = new ArrayList<>();
List<GongfuDeviceComponent> forAdd = new ArrayList<>();
List<GongfuDeviceComponentDetail> detailsForAdd = new ArrayList<>();
deviceComponents.forEach(deviceComponent -> {
List<GongfuDevice> ds = devices.stream()
.filter(d -> d.getModelNo().equals(deviceComponent.getModelNo()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(ds)) {
forUpdate.add(new GongfuDeviceComponent()
.setId(deviceComponent.getId())
.setProductLine(ds.get(0).getProductLine())
);
if (ds.size() > 1) {
List<GongfuDeviceComponentDetail> details = gongfuDeviceComponentDetailService.lambdaQuery()
.eq(GongfuDeviceComponentDetail::getDeviceComponentId, deviceComponent.getId())
.list();
for (int i = 1; i < ds.size(); i++) {
String prodoctLine = ds.get(i).getProductLine();
GongfuDeviceComponent component = deviceComponents.stream()
.filter(dc -> StrUtil.equals(dc.getProductLine(), prodoctLine))
.findFirst()
.orElse(null);
if (Objects.isNull(component)) {
component = forAdd.stream()
.filter(dc -> StrUtil.equals(dc.getProductLine(), prodoctLine))
.findFirst()
.orElse(null);
if (Objects.isNull(component)) {
component = new GongfuDeviceComponent()
.setId(IdUtil.getSnowflakeNextId())
.setProductLine(ds.get(i).getProductLine())
.setComponent(deviceComponent.getComponent())
.setEnable(deviceComponent.getEnable())
.setCreateBy(deviceComponent.getCreateBy())
.setCreateTime(deviceComponent.getCreateTime())
.setUpdateBy(deviceComponent.getUpdateBy())
.setUpdateTime(deviceComponent.getUpdateTime());
forAdd.add(component);
}
}
for (GongfuDeviceComponentDetail detail : details) {
detailsForAdd.add(new GongfuDeviceComponentDetail()
.setDeviceComponentId(component.getId())
.setModelPartId(detail.getModelPartId())
.setModelPartName(detail.getModelPartName())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
}
}
}
}
});
if (CollectionUtil.isNotEmpty(forUpdate)) {
gongfuDeviceComponentService.updateBatchById(forUpdate);
}
if (CollectionUtil.isNotEmpty(forAdd)) {
gongfuDeviceComponentService.saveBatch(forAdd);
}
if (CollectionUtil.isNotEmpty(detailsForAdd)) {
gongfuDeviceComponentDetailService.saveBatch(detailsForAdd);
}
List<GongfuDeviceComponentDetail> allDetails = gongfuDeviceComponentDetailService
.lambdaQuery()
.select(GongfuDeviceComponentDetail::getDeviceComponentId, GongfuDeviceComponentDetail::getModelPartName)
.list();
List<GongfuDeviceComponent> allComponents = gongfuDeviceComponentService.lambdaQuery()
.select(GongfuDeviceComponent::getId)
.list();
allComponents.forEach(component -> {
component.setComponent(
allDetails.stream()
.filter(detail -> detail.getDeviceComponentId().equals(component.getId()))
.map(GongfuDeviceComponentDetail::getModelPartName)
.collect(Collectors.joining(","))
);
});
gongfuDeviceComponentService.updateBatchById(allComponents);
return ApiResult.success();
}
}

View File

@ -669,6 +669,7 @@ public class TicketController extends ControllerBase {
.setDeviceAddress(ticket.getDeviceAddress())
.setModelNo(device.getModelNo())
.setDeviceType(device.getDeviceType())
.setComponentId(ticket.getComponentId())
.setComponent(Objects.nonNull(part) ? part.getPartName() : "")
.setUseTime(ticket.getUseTime())
.setDescription(ticket.getDescription())

View File

@ -0,0 +1,20 @@
package com.nflg.mobilebroken.gongfu.pojo.query;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
import lombok.Data;
@Data
public class GongFuDeviceComponentQuery extends PageBaseQuery {
/**
* 产品线
*/
private String productLine;
// private String component;
/**
* 组件排序true:有组件在前false:无组件在前null:按id倒序
*/
private Boolean componentSort=false;
}

View File

@ -18,10 +18,10 @@ public class PartQuery extends PageBaseQuery {
*/
private String partName;
/**
* 类别属性
*/
private String typeAttr;
// /**
// * 类别属性
// */
// private String typeAttr;
/**
* 状态 0-禁用 1-启用

View File

@ -0,0 +1,31 @@
package com.nflg.mobilebroken.gongfu.pojo.vo;
import com.nflg.mobilebroken.repository.entity.GongfuDeviceComponentDetail;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
@Data
@Accessors(chain = true)
public class GongFuDeviceTypeVO {
private Long id;
/**
* 产品线
*/
private String productLine;
/**
* 部件列表
*/
private List<GongfuDeviceComponentDetail> items = new ArrayList<>();
private Integer sort;
public Integer getSort() {
return items.size();
}
}

View File

@ -153,13 +153,13 @@ public class AdminBasePartService {
List<GongfuDevicePartLanguageData> languageDataList = new ArrayList<>();
for (Map<String, Object> mp : data) {
String partName = mp.get("部件名称").toString();
String typeAttr = mp.get("类别属性").toString();
// String typeAttr = mp.get("类别属性").toString();
GongfuDevicePart partEnt = partService.lambdaQuery().eq(GongfuDevicePart::getPartName, partName).one();
if (partEnt == null) {
partEnt = new GongfuDevicePart();
partEnt.setPartNo(UniqueSequenceGenerator.generateCode(Constant1.PartCodePrefix));
partEnt.setPartName(partName);
partEnt.setTypeAttr(typeAttr);
// partEnt.setTypeAttr(typeAttr);
partEnt.setEnable(true);
partEnt.setCreateBy(AdminUserUtil.getUserName());
partEnt.setCreateTime(LocalDateTime.now());

View File

@ -21,21 +21,20 @@ public class AdminDeviceComponentService {
@Resource
IGongfuDeviceComponentService deviceComponentService;
public void batchAddModelNo(List<String> modelNos) {
public void batchAdd(List<String> productLines) {
List<GongfuDeviceComponent> existDeviceTypes = deviceComponentService.lambdaQuery()
.in(GongfuDeviceComponent::getModelNo, modelNos)
.select(GongfuDeviceComponent::getModelNo).list();
.in(GongfuDeviceComponent::getProductLine, productLines)
.select(GongfuDeviceComponent::getProductLine).list();
Set<String> existDeviceModelSet = existDeviceTypes.stream().map(GongfuDeviceComponent::getModelNo).collect(Collectors.toSet());
HashSet<String> addTypeSet = Sets.newHashSet(modelNos);
Set<String> existDeviceModelSet = existDeviceTypes.stream().map(GongfuDeviceComponent::getProductLine).collect(Collectors.toSet());
HashSet<String> addTypeSet = Sets.newHashSet(productLines);
Sets.SetView<String> needAddModels = Sets.difference(addTypeSet, existDeviceModelSet);
if (CollUtil.isNotEmpty(needAddModels)) {
List<GongfuDeviceComponent> modelList = new ArrayList<>();
for (String model : needAddModels) {
for (String productLine : needAddModels) {
GongfuDeviceComponent ent = new GongfuDeviceComponent();
ent.setId(null);
ent.setModelNo(model);
ent.setProductLine(productLine);
ent.setEnable(Boolean.TRUE);
ent.setCreateBy(AdminUserUtil.getUserName());
ent.setCreateTime(LocalDateTime.now());

View File

@ -73,7 +73,7 @@ public class AdminDeviceService {
dataTypes.put(deviceDTO.getProductLine(), Set.of(deviceDTO.getModelNo()));
adminDeviceTypeService.batchAddDeviceType(dataTypes);
//将设备机型
adminDeviceComponentService.batchAddModelNo(ImmutableList.of(deviceDTO.getModelNo()));
adminDeviceComponentService.batchAdd(ImmutableList.of(deviceDTO.getProductLine()));
}
@Transactional(rollbackFor = Exception.class)
@ -92,7 +92,7 @@ public class AdminDeviceService {
dataTypes.put(deviceDTO.getProductLine(), Set.of(deviceDTO.getModelNo()));
adminDeviceTypeService.batchAddDeviceType(dataTypes);
//将设备机型
adminDeviceComponentService.batchAddModelNo(ImmutableList.of(deviceDTO.getModelNo()));
adminDeviceComponentService.batchAdd(ImmutableList.of(deviceDTO.getProductLine()));
}
// /**
@ -266,8 +266,8 @@ public class AdminDeviceService {
});
adminDeviceTypeService.batchAddDeviceType(dataTypes);
//将设备机型
List<String> models = result.stream().map(GongfuDevice::getModelNo).collect(Collectors.toList());
adminDeviceComponentService.batchAddModelNo(models);
List<String> productLines = result.stream().map(GongfuDevice::getProductLine).collect(Collectors.toList());
adminDeviceComponentService.batchAdd(productLines);
deviceService.lambdaUpdate()
.set(GongfuDevice::getDataValidState, false)
.eq(GongfuDevice::getDataValidState, true)

View File

@ -33,6 +33,11 @@ public class GongfuDeviceComponent implements Serializable {
*/
private String modelNo;
/**
* 产品线
*/
private String productLine;
/**
* 机型部件
*/

View File

@ -38,10 +38,10 @@ public class GongfuDevicePart implements Serializable {
*/
private String partName;
/**
* 类别属性
*/
private String typeAttr;
// /**
// * 类别属性
// */
// private String typeAttr;
/**
* 是否启用

View File

@ -47,5 +47,5 @@ public interface DeviceMapper extends BaseMapper<Device> {
List<DeviceAgentVO> getAgents();
List<ComponentInfo> getComponents1(String modelNo, String language);
List<ComponentInfo> getComponents1(String productLine, String language);
}

View File

@ -2,6 +2,7 @@ package com.nflg.mobilebroken.repository.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
import com.nflg.mobilebroken.common.pojo.dto.GongFuDeviceComponentExportDTO;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
@ -29,7 +30,7 @@ public interface GongfuDeviceComponentMapper extends BaseMapper<GongfuDeviceComp
*/
Page<DeviceComponentVO> selectListByPage(@Param("page") Page<PageBaseQuery> page, @Param("query") DeviceComponentQuery query);
List<DevComponentExcel> getExportData();
List<GongFuDeviceComponentExportDTO> getExportData();
List<DeviceComponent1VO> getWithDeviceType(String modelNo, Boolean componentSort);
}

View File

@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service;
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.dto.GongFuDeviceComponentExportDTO;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
@ -37,7 +38,7 @@ public interface IGongfuDeviceComponentService extends IService<GongfuDeviceComp
Boolean saveOrUpdateBatchComponent(List<GongfuDeviceComponent> data);
List<DevComponentExcel> getExportData();
List<GongFuDeviceComponentExportDTO> getExportData();
List<DeviceComponent1VO> getWithDeviceType(String modelNo, Boolean componentSort);
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.mobilebroken.common.constant.Constant;
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.DeviceAgentVO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceVO;
@ -39,7 +40,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
if (Objects.equals(vo.getType(), 0)) {
vo.setComponents(baseMapper.getComponents(vo.getModelNo(), MultilingualUtil.getLanguage()));
} else {
vo.setComponents(baseMapper.getComponents1(vo.getModelNo(), MultilingualUtil.getLanguage()));
vo.setComponents(baseMapper.getComponents1(vo.getProductLine(), MultilingualUtil.getLanguage()));
}
}
return Optional.ofNullable(vo).orElse(new DeviceInfoVO());

View File

@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service.impl;
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.dto.GongFuDeviceComponentExportDTO;
import com.nflg.mobilebroken.common.pojo.query.DeviceComponentQuery;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO;
import com.nflg.mobilebroken.common.pojo.vo.DeviceComponentVO;
@ -58,7 +59,7 @@ public class GongfuDeviceComponentServiceImpl extends ServiceImpl<GongfuDeviceCo
}
public List<DevComponentExcel> getExportData() {
public List<GongFuDeviceComponentExportDTO> getExportData() {
return this.getBaseMapper().getExportData();
}

View File

@ -8,6 +8,7 @@ import com.nflg.mobilebroken.common.constant.Constant;
import com.nflg.mobilebroken.common.constant.TicketState;
import com.nflg.mobilebroken.common.pojo.dto.TicketDTO;
import com.nflg.mobilebroken.common.pojo.request.SolutionMeasuresSaveRequest;
import com.nflg.mobilebroken.common.pojo.vo.DeviceInfoVO;
import com.nflg.mobilebroken.common.pojo.vo.SolutionMeasuresDataItemVO;
import com.nflg.mobilebroken.common.pojo.vo.SolutionMeasuresItemVO;
import com.nflg.mobilebroken.common.pojo.vo.SolutionMeasuresVO;
@ -56,6 +57,9 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
@Resource
private IFileUploadRecordService fileUploadRecordService;
@Resource
private IDeviceService deviceService;
@Override
public SolutionMeasuresVO getSolutionMeasures(Long ticketId) {
TicketDTO ticket = ticketService.getDto(ticketId);
@ -129,6 +133,12 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
}
}
vo.setMeasures(items);
if (Objects.equals(ticket.getType(), 1)) {
DeviceInfoVO deviceInfoVO = deviceService.getByDeviceNo(ticket.getDeviceNo());
if (Objects.nonNull(deviceInfoVO)) {
vo.setComponents(deviceInfoVO.getComponents());
}
}
return vo;
}
@ -271,6 +281,7 @@ public class TicketSolutionServiceImpl extends ServiceImpl<TicketSolutionMapper,
.set(GongfuTicket::getReason, request.getReason())
.set(GongfuTicket::getQuestion, request.getQuestion())
.set(GongfuTicket::getAccidentLevel, request.getAccidentLevel())
.set(GongfuTicket::getComponentId, request.getComponentId())
.eq(GongfuTicket::getId, request.getTicketId())
.update();
if (CollectionUtil.isNotEmpty(idForReserve)) {

View File

@ -144,6 +144,6 @@
inner join gongfu_device_component dc ON dc.id = dcd.device_component_id
INNER JOIN gongfu_device_part p ON dcd.model_part_id = p.id
LEFT JOIN gongfu_device_part_language_data ld ON dcd.model_part_id = ld.source_id
WHERE p.enable=1 AND dc.`enable` = 1 AND dc.model_no=#{modelNo} AND ld.language_code=#{language}
WHERE p.enable=1 AND dc.`enable` = 1 AND dc.product_line=#{productLine} AND ld.language_code=#{language}
</select>
</mapper>

View File

@ -23,11 +23,11 @@
</if>
</select>
<select id="getExportData" resultType="com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel">
select a.model_no,b.model_part_name,b.create_by,b.create_time
<select id="getExportData" resultType="com.nflg.mobilebroken.common.pojo.dto.GongFuDeviceComponentExportDTO">
select a.product_line,b.model_part_name,b.create_by,b.create_time
from gongfu_device_component a
join gongfu_device_component_detail b on a.id=b.device_component_id
join t_base_part c on b.model_part_id=c.id
join gongfu_device_component_detail b on a.id=b.device_component_id
join gongfu_device_part c on b.model_part_id=c.id
</select>
<select id="getWithDeviceType" resultType="com.nflg.mobilebroken.common.pojo.vo.DeviceComponent1VO">

View File

@ -9,31 +9,33 @@
<if test="query.partName!=null and query.partName!=''">
and part_name like concat('%', #{query.partName},'%')
</if>
<if test="query.typeAttr!=null and query.typeAttr!=''">
and type_attr=#{query.typeAttr}
</if>
<!-- <if test="query.typeAttr!=null and query.typeAttr!=''">-->
<!-- and type_attr=#{query.typeAttr}-->
<!-- </if>-->
<if test="query.enable!=null">
and enable=#{query.enable}
</if>
</sql>
<select id="getListByPage" resultType="com.nflg.mobilebroken.repository.entity.GongfuDevicePart">
select * from gongfu_device_part where 1=1
<include refid="whr">
</include>
select * from gongfu_device_part
<where>
<include refid="whr">
</include>
</where>
</select>
<select id="exportPart" resultType="com.nflg.mobilebroken.common.pojo.dto.ExportPartDTO">
select a.part_name,a.type_attr,b.language_name,b.language_value
from gongfu_device_part a join gongfu_device_part_language_data b on a.id=b.source_id
where 1=1
<if test="partNo!=null and partNo!=''">
and part_no=#{partNo}
</if>
<if test="partName!=null and partName!=''">
and part_name like concat('%', #{partName},'%')
</if>
select a.part_name,a.type_attr,b.language_name,b.language_value
from gongfu_device_part a
join gongfu_device_part_language_data b on a.id=b.source_id
<where>
<if test="partNo!=null and partNo!=''">
and part_no=#{partNo}
</if>
<if test="partName!=null and partName!=''">
and part_name like concat('%', #{partName},'%')
</if>
</where>
</select>
</mapper>