From a27906a75f974d2d53607d463832584c8d1fb8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Mon, 26 Jan 2026 15:44:37 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/GongFuDeviceComponentExportDTO.java | 20 ++ .../dto/GongFuDeviceComponentImportDTO.java | 20 ++ .../request/SolutionMeasuresSaveRequest.java | 5 + .../common/pojo/request/TicketAddRequest.java | 2 +- .../controller/DeviceComponentController.java | 209 +++++++++++------- .../gongfu/controller/DeviceController.java | 8 +- .../query/GongFuDeviceComponentQuery.java | 20 ++ .../gongfu/pojo/query/PartQuery.java | 8 +- .../gongfu/pojo/vo/GongFuDeviceTypeVO.java | 29 +++ .../gongfu/service/AdminBasePartService.java | 4 +- .../service/AdminDeviceComponentService.java | 15 +- .../gongfu/service/AdminDeviceService.java | 8 +- .../entity/GongfuDeviceComponent.java | 9 +- .../repository/entity/GongfuDevicePart.java | 8 +- .../mapper/GongfuDeviceComponentMapper.java | 3 +- .../IGongfuDeviceComponentService.java | 3 +- .../GongfuDeviceComponentServiceImpl.java | 3 +- .../impl/TicketSolutionServiceImpl.java | 1 + .../mapper/GongfuDeviceComponentMapper.xml | 8 +- .../mapper/GongfuDevicePartMapper.xml | 36 +-- 20 files changed, 288 insertions(+), 131 deletions(-) create mode 100644 nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentExportDTO.java create mode 100644 nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentImportDTO.java create mode 100644 nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/GongFuDeviceComponentQuery.java create mode 100644 nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentExportDTO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentExportDTO.java new file mode 100644 index 00000000..0731c404 --- /dev/null +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentExportDTO.java @@ -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; +} diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentImportDTO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentImportDTO.java new file mode 100644 index 00000000..2118855b --- /dev/null +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/dto/GongFuDeviceComponentImportDTO.java @@ -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; +} diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java index e40bc9e8..ff937fc3 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java @@ -38,6 +38,11 @@ public class SolutionMeasuresSaveRequest { */ private List imageIds; + /** + * 问题部件id + */ + private Long componentId; + /** * 解决措施 */ diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/TicketAddRequest.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/TicketAddRequest.java index 404c3e3e..84b204cf 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/TicketAddRequest.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/TicketAddRequest.java @@ -66,7 +66,7 @@ public class TicketAddRequest { private String handlerUserName; /** - * 工单区域id,工服工单必填 + * 工单区域id */ private Long areaId; diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java index c1d80ab5..1b40e339 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java @@ -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> getList(@RequestBody DeviceComponentQuery query) { - List deviceComponents = deviceComponentService.getWithDeviceType(query.getModelNo(), query.getComponentSort()); - Map> 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 pageData = new PageData<>(); - List 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> getList(@RequestBody GongFuDeviceComponentQuery query) { +// List deviceComponents = deviceComponentService.getByProductLine(query.getProductLine(), query.getComponentSort()); +// Map> 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 pageData = new PageData<>(); +// List 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 productLines = deviceComponentService.lambdaQuery() + .select(GongfuDeviceComponent::getId, GongfuDeviceComponent::getProductLine) + .eq(GongfuDeviceComponent::getEnable, true) + .like(StrUtil.isNotBlank(query.getProductLine()), GongfuDeviceComponent::getProductLine, query.getProductLine()) + .list(); + List details = deviceComponentDetailService.list(); + details.forEach(d -> d.setId(d.getDeviceComponentId())); + List datas = new ArrayList<>(); + productLines.forEach(p -> { + GongFuDeviceTypeVO vo = datas.stream() + .filter(d -> StrUtil.equals(p.getProductLine(), d.getProductLine())) + .findFirst() + .orElseGet(() -> { + GongFuDeviceTypeVO v = new GongFuDeviceTypeVO() + .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 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 listSheet = new ListSheet() { + final ListSheet listSheet = new ListSheet<>() { @Override - protected List more() { + protected List more() { return null; } }; @@ -196,13 +230,14 @@ public class DeviceComponentController extends ControllerBase { * 检查重复行 * @param list */ - private List checkDuplicates(List list) { + private List checkDuplicates(List list) { List 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 importData(@RequestParam(value = "file") MultipartFile file) { - try { - List data = EecExcelUtil.getExcelContext(file.getInputStream(), DevComponentExcel.class); + List data = EecExcelUtil.getExcelContext(file.getInputStream(), GongFuDeviceComponentImportDTO.class); VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空"); //检查内容是否重复 List checkResult = checkDuplicates(data); - VUtils.trueThrow(CollUtil.isNotEmpty(checkResult)).throwMessage(STATE.PageError, StrUtil.join(",", checkResult) + "内容重复,请检查导入的数据"); - - Set modeNos = data.stream().map(DevComponentExcel::getModelNo).collect(Collectors.toSet()); - List extstsModes = deviceComponentService.lambdaQuery().in(GongfuDeviceComponent::getModelNo, modeNos).list(); - Set extstsModesSet = extstsModes.stream().map(GongfuDeviceComponent::getModelNo).collect(Collectors.toSet()); - Set 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 partNames = data.stream().map(DevComponentExcel::getModelPartName).collect(Collectors.toSet()); + Set partNames = data.stream().map(GongFuDeviceComponentImportDTO::getModelPartName).collect(Collectors.toSet()); List exitsParts = basePartService.lambdaQuery().in(GongfuDevicePart::getPartName, partNames).list(); Set exitsPartSet = exitsParts.stream().map(GongfuDevicePart::getPartName).collect(Collectors.toSet()); Set diffParts = Sets.difference(partNames, exitsPartSet); VUtils.trueThrow(CollUtil.isNotEmpty(diffParts)).throwMessage(STATE.ParamErr, StrUtil.join(",", diffParts) + " 部件名称不存在,请在部件管理中维护"); - Map> dataMap = data.stream().collect(Collectors.groupingBy(DevComponentExcel::getModelNo)); - Map extstsModeMap = extstsModes.stream().collect(Collectors.toMap(GongfuDeviceComponent::getModelNo, u -> u)); + Map> dataMap = data.stream().collect(Collectors.groupingBy(GongFuDeviceComponentImportDTO::getProductLine)); + List exitsComponent = deviceComponentService.list(); + Map extstsModeMap = exitsComponent.stream().collect(Collectors.toMap(GongfuDeviceComponent::getProductLine, u -> u)); Map exitsPartMap = exitsParts.stream().collect(Collectors.toMap(GongfuDevicePart::getPartName, u -> u)); - List result = new ArrayList<>(); - List deviceComponentResult = new ArrayList<>(); + List details = new ArrayList<>(); + List componentsForAdd = new ArrayList<>(); + List componentsForUpdate = new ArrayList<>(); for (String key : dataMap.keySet()) { - List 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 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 list = deviceComponentService.getExportData(); + List list = deviceComponentService.getExportData(); if (CollUtil.isEmpty(list)) { throw new NflgException(STATE.BusinessError, "没有可导出的数据"); } diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java index 206886db..c3223ee0 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java @@ -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()); diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/GongFuDeviceComponentQuery.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/GongFuDeviceComponentQuery.java new file mode 100644 index 00000000..ee7dcffd --- /dev/null +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/GongFuDeviceComponentQuery.java @@ -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; +} diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/PartQuery.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/PartQuery.java index fb1d0685..8343c857 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/PartQuery.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/PartQuery.java @@ -18,10 +18,10 @@ public class PartQuery extends PageBaseQuery { */ private String partName; - /** - * 类别属性 - */ - private String typeAttr; +// /** +// * 类别属性 +// */ +// private String typeAttr; /** * 状态 0-禁用 1-启用 diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java new file mode 100644 index 00000000..8eb831c3 --- /dev/null +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java @@ -0,0 +1,29 @@ +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 String productLine; + + /** + * 部件列表 + */ + private List items = new ArrayList<>(); + + private Integer sort; + + public Integer getSort() { + return items.size(); + } +} diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminBasePartService.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminBasePartService.java index c78e307c..c708765f 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminBasePartService.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminBasePartService.java @@ -153,13 +153,13 @@ public class AdminBasePartService { List languageDataList = new ArrayList<>(); for (Map 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()); diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceComponentService.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceComponentService.java index 853e526b..03e0d3f0 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceComponentService.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceComponentService.java @@ -21,21 +21,20 @@ public class AdminDeviceComponentService { @Resource IGongfuDeviceComponentService deviceComponentService; - public void batchAddModelNo(List modelNos) { + public void batchAdd(List productLines) { List existDeviceTypes = deviceComponentService.lambdaQuery() - .in(GongfuDeviceComponent::getModelNo, modelNos) - .select(GongfuDeviceComponent::getModelNo).list(); + .in(GongfuDeviceComponent::getProductLine, productLines) + .select(GongfuDeviceComponent::getProductLine).list(); - Set existDeviceModelSet = existDeviceTypes.stream().map(GongfuDeviceComponent::getModelNo).collect(Collectors.toSet()); - HashSet addTypeSet = Sets.newHashSet(modelNos); + Set existDeviceModelSet = existDeviceTypes.stream().map(GongfuDeviceComponent::getProductLine).collect(Collectors.toSet()); + HashSet addTypeSet = Sets.newHashSet(productLines); Sets.SetView needAddModels = Sets.difference(addTypeSet, existDeviceModelSet); if (CollUtil.isNotEmpty(needAddModels)) { List 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()); diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceService.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceService.java index 1aad402c..f627b5e8 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceService.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/service/AdminDeviceService.java @@ -64,7 +64,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) @@ -83,7 +83,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())); } // /** @@ -230,8 +230,8 @@ public class AdminDeviceService { }); adminDeviceTypeService.batchAddDeviceType(dataTypes); //将设备机型 - List models = result.stream().map(GongfuDevice::getModelNo).collect(Collectors.toList()); - adminDeviceComponentService.batchAddModelNo(models); + List productLines = result.stream().map(GongfuDevice::getProductLine).collect(Collectors.toList()); + adminDeviceComponentService.batchAdd(productLines); deviceService.lambdaUpdate() .set(GongfuDevice::getDataValidState, false) .eq(GongfuDevice::getDataValidState, true) diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java index 68ee96b8..4e5c3cc0 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java @@ -28,10 +28,15 @@ public class GongfuDeviceComponent implements Serializable { @TableId(value = "id", type = IdType.ASSIGN_ID) private Long id; +// /** +// * 设备机型 +// */ +// private String modelNo; + /** - * 设备机型 + * 产品线 */ - private String modelNo; + private String productLine; /** * 机型部件 diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDevicePart.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDevicePart.java index a37faeba..a45ed9a6 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDevicePart.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDevicePart.java @@ -38,10 +38,10 @@ public class GongfuDevicePart implements Serializable { */ private String partName; - /** - * 类别属性 - */ - private String typeAttr; +// /** +// * 类别属性 +// */ +// private String typeAttr; /** * 是否启用 diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/GongfuDeviceComponentMapper.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/GongfuDeviceComponentMapper.java index 14aeaaab..bd088c6a 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/GongfuDeviceComponentMapper.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/GongfuDeviceComponentMapper.java @@ -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 selectListByPage(@Param("page") Page page, @Param("query") DeviceComponentQuery query); - List getExportData(); + List getExportData(); List getWithDeviceType(String modelNo, Boolean componentSort); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IGongfuDeviceComponentService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IGongfuDeviceComponentService.java index 6036f3e5..dc4811af 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IGongfuDeviceComponentService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IGongfuDeviceComponentService.java @@ -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 data); - List getExportData(); + List getExportData(); List getWithDeviceType(String modelNo, Boolean componentSort); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/GongfuDeviceComponentServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/GongfuDeviceComponentServiceImpl.java index 6cb1edcb..1b7cd4bc 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/GongfuDeviceComponentServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/GongfuDeviceComponentServiceImpl.java @@ -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 getExportData() { + public List getExportData() { return this.getBaseMapper().getExportData(); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java index 2421bb1a..3c8cea02 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java @@ -271,6 +271,7 @@ public class TicketSolutionServiceImpl extends ServiceImpl - + 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 * from gongfu_device_part where 1=1 - - + select * from gongfu_device_part + + + + From 8d215772fe4b737511bdb96f5b71cf8fe63d0f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 27 Jan 2026 16:06:03 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nflg/mobilebroken/repository/mapper/DeviceMapper.java | 2 +- .../mobilebroken/repository/service/impl/DeviceServiceImpl.java | 2 +- .../src/main/resources/mapper/DeviceMapper.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/DeviceMapper.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/DeviceMapper.java index 3f326c5b..1340f8a5 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/DeviceMapper.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/DeviceMapper.java @@ -47,5 +47,5 @@ public interface DeviceMapper extends BaseMapper { List getAgents(); - List getComponents1(String modelNo, String language); + List getComponents1(String productLine, String language); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java index aeb19adc..6ea40f1e 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java @@ -39,7 +39,7 @@ public class DeviceServiceImpl extends ServiceImpl 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()); diff --git a/nflg-mobilebroken-repository/src/main/resources/mapper/DeviceMapper.xml b/nflg-mobilebroken-repository/src/main/resources/mapper/DeviceMapper.xml index ae46e199..238556f3 100644 --- a/nflg-mobilebroken-repository/src/main/resources/mapper/DeviceMapper.xml +++ b/nflg-mobilebroken-repository/src/main/resources/mapper/DeviceMapper.xml @@ -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} From e0571e24b35f11b7a1b7896c17f0ad41f0ac2402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 27 Jan 2026 16:28:16 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/pojo/vo/SolutionMeasuresVO.java | 5 +++++ .../gongfu/controller/DeviceComponentController.java | 1 + .../gongfu/pojo/vo/GongFuDeviceTypeVO.java | 2 ++ .../repository/service/impl/DeviceServiceImpl.java | 1 + .../service/impl/TicketSolutionServiceImpl.java | 10 ++++++++++ 5 files changed, 19 insertions(+) diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SolutionMeasuresVO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SolutionMeasuresVO.java index 3c090dfd..ad323261 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SolutionMeasuresVO.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/SolutionMeasuresVO.java @@ -20,4 +20,9 @@ public class SolutionMeasuresVO { // 是否审核通过,默认为null,表示未审核;false:不通过,true:通过 private Boolean approved; + + /** + * 部件列表 + */ + private List components; } diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java index 1b40e339..a752ece2 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java @@ -108,6 +108,7 @@ public class DeviceComponentController extends ControllerBase { .findFirst() .orElseGet(() -> { GongFuDeviceTypeVO v = new GongFuDeviceTypeVO() + .setId(p.getId()) .setProductLine(p.getProductLine()); datas.add(v); return v; diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java index 8eb831c3..c4a2d629 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/vo/GongFuDeviceTypeVO.java @@ -11,6 +11,8 @@ import java.util.List; @Accessors(chain = true) public class GongFuDeviceTypeVO { + private Long id; + /** * 产品线 */ diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java index 6ea40f1e..361a7bdb 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/DeviceServiceImpl.java @@ -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; diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java index 3c8cea02..19622797 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TicketSolutionServiceImpl.java @@ -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 Date: Tue, 27 Jan 2026 16:40:34 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongfu/controller/DeviceComponentController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java index a752ece2..cee742e4 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceComponentController.java @@ -100,7 +100,6 @@ public class DeviceComponentController extends ControllerBase { .like(StrUtil.isNotBlank(query.getProductLine()), GongfuDeviceComponent::getProductLine, query.getProductLine()) .list(); List details = deviceComponentDetailService.list(); - details.forEach(d -> d.setId(d.getDeviceComponentId())); List datas = new ArrayList<>(); productLines.forEach(p -> { GongFuDeviceTypeVO vo = datas.stream() From 04d2482850cacf629144a6a6301fdff6c107392c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 27 Jan 2026 17:17:03 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/mobilebroken/gongfu/controller/TicketController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TicketController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TicketController.java index 9ec34595..abe09fe7 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TicketController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TicketController.java @@ -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()) From 381b9ec5f87c19da2257f82ec2f0c926b6e63152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 27 Jan 2026 17:46:03 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=B7=A5=E6=9C=8D=E8=B0=83=E6=95=B42026012?= =?UTF-8?q?6=201=E3=80=81=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=8C=BA=E5=9F=9F=E7=9A=84=E5=85=88=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA=EF=BC=9B?= =?UTF-8?q?=202=E3=80=81=E6=89=80=E6=9C=89=E7=9A=84=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=A7=BB=E9=99=A4=EF=BC=9B=203=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=B8=8D=E5=86=8D=E7=BB=91=E5=AE=9A=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=91=E5=AE=9A=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=BA=BF=EF=BC=9B=204=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/TranslateController.java | 23 +++++++++++++++++-- .../cfs/controller/TranslateController.java | 20 ++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/TranslateController.java b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/TranslateController.java index 092d11aa..87efff73 100644 --- a/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/TranslateController.java +++ b/nflg-mobilebroken-admin/src/main/java/com/nflg/mobilebroken/admin/controller/TranslateController.java @@ -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 deepseek(@RequestParam String text) { + public ApiResult 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("
", ","); - return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", AdminUserUtil.getLanguageName(), "text")); + return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", language.getName(), "text")); } } diff --git a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/TranslateController.java b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/TranslateController.java index 1cdd983e..972985b4 100644 --- a/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/TranslateController.java +++ b/nflg-mobilebroken-cfs-app/src/main/java/com/nflg/mobilebroken/cfs/controller/TranslateController.java @@ -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 deepseek(@RequestParam String text) { - return ApiResult.success(deepSeekTranslate.translateWord(text, "auto", AppUserUtil.getLanguageName(), "text")); + public ApiResult 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")); } } From 2c678c27cbb52b46ae37a6cf01d73935313869e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 29 Jan 2026 16:09:01 +0800 Subject: [PATCH 7/7] =?UTF-8?q?feat(gongfu):=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8E=A7=E5=88=B6=E5=99=A8=E5=B9=B6=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增TestController用于初始化设备组件产品线数据 - 实现批量更新设备组件的产品线信息功能 - 添加设备机型字段到GongfuDeviceComponent实体类 - 在SolutionMeasuresSaveRequest中增加componentId非空验证 - 实现设备组件详情的批量创建和更新逻辑 - 添加多产品线设备组件的复制处理机制 --- .../request/SolutionMeasuresSaveRequest.java | 1 + .../gongfu/controller/TestController.java | 139 ++++++++++++++++++ .../entity/GongfuDeviceComponent.java | 8 +- 3 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TestController.java diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java index ff937fc3..753eb457 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/SolutionMeasuresSaveRequest.java @@ -41,6 +41,7 @@ public class SolutionMeasuresSaveRequest { /** * 问题部件id */ + @NotNull private Long componentId; /** diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TestController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TestController.java new file mode 100644 index 00000000..e7512c6c --- /dev/null +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/TestController.java @@ -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 initDeviceComponentProductLine() { + List deviceComponents = gongfuDeviceComponentService + .lambdaQuery() + .isNull(GongfuDeviceComponent::getProductLine) + .list(); + if (CollectionUtil.isEmpty(deviceComponents)) { + return ApiResult.success(); + } + List devices = gongfuDeviceService.lambdaQuery() + .select(GongfuDevice::getModelNo, GongfuDevice::getProductLine) + .eq(GongfuDevice::getDataValidState, 1) + .list(); + List forUpdate = new ArrayList<>(); + List forAdd = new ArrayList<>(); + List detailsForAdd = new ArrayList<>(); + deviceComponents.forEach(deviceComponent -> { + List 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 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 allDetails = gongfuDeviceComponentDetailService + .lambdaQuery() + .select(GongfuDeviceComponentDetail::getDeviceComponentId, GongfuDeviceComponentDetail::getModelPartName) + .list(); + List 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(); + } +} diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java index 4e5c3cc0..c0ed6c5d 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/GongfuDeviceComponent.java @@ -28,10 +28,10 @@ public class GongfuDeviceComponent implements Serializable { @TableId(value = "id", type = IdType.ASSIGN_ID) private Long id; -// /** -// * 设备机型 -// */ -// private String modelNo; + /** + * 设备机型 + */ + private String modelNo; /** * 产品线