feat: 产品中心

This commit is contained in:
曹鹏飞 2025-06-19 14:52:13 +08:00
parent 902a3937d6
commit 91297cc2f1
32 changed files with 299 additions and 166 deletions

View File

@ -33,12 +33,6 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>

View File

@ -1,6 +1,5 @@
package com.nflg.mobilebroken.admin.controller; package com.nflg.mobilebroken.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
@ -16,6 +15,7 @@ import com.nflg.mobilebroken.common.pojo.PageData;
import com.nflg.mobilebroken.common.pojo.dto.ProductModelParamsExcelDTO; import com.nflg.mobilebroken.common.pojo.dto.ProductModelParamsExcelDTO;
import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.request.*;
import com.nflg.mobilebroken.common.pojo.vo.*; import com.nflg.mobilebroken.common.pojo.vo.*;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.EecExcelUtil; import com.nflg.mobilebroken.common.util.EecExcelUtil;
import com.nflg.mobilebroken.common.util.PageUtil; import com.nflg.mobilebroken.common.util.PageUtil;
import com.nflg.mobilebroken.common.util.VUtils; import com.nflg.mobilebroken.common.util.VUtils;
@ -26,16 +26,18 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.ttzero.excel.entity.TemplateSheet;
import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -421,10 +423,7 @@ public class ProductModelController extends ControllerBase{
@GetMapping("/downloadParamImportTemplate") @GetMapping("/downloadParamImportTemplate")
public void downloadParamImportTemplate(HttpServletResponse response) throws IOException { public void downloadParamImportTemplate(HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "机型参数导入模版"); EecExcelUtil.setResponseExcelHeader(response, "机型参数导入模版");
ClassPathResource resource = new ClassPathResource("templates/ProductModelParamImport.xlsx"); StreamUtils.copy(new ClassPathResource("templates/ProductModelParamImport.xlsx").getInputStream(), response.getOutputStream());
new Workbook()
.addSheet(new TemplateSheet(resource.getInputStream()))
.writeTo(response.getOutputStream());
} }
/** /**
@ -608,41 +607,162 @@ public class ProductModelController extends ControllerBase{
/** /**
* 导入设备技术参数项 * 导入设备技术参数项
* @param modelId 机型ID
* @param modelParamsId 机型参数ID * @param modelParamsId 机型参数ID
* @param file 文件 * @param file 文件
* @return 机型参数id * @return 机型参数id
*/ */
@Transactional
@PostMapping("/importModelParamsItem") @PostMapping("/importModelParamsItem")
public ApiResult<Integer> importModelParamsItem(@Valid @RequestParam @NotNull int modelId public ApiResult<Integer> importModelParamsItem(@Valid @RequestParam @NotNull int modelId
,@RequestParam Integer modelParamsId ,@RequestParam(required = false,defaultValue = "0") int modelParamsId
, @Valid @RequestParam(value = "file") @NotNull MultipartFile file) { , @Valid @RequestParam(value = "file") @NotNull MultipartFile file) {
try { ProductModel model=productModelService.getById(modelId);
List<ProductModelParamsExcelDTO> datas = EecExcelUtil.getExcelContext(file.getInputStream(), ProductModelParamsExcelDTO.class); VUtils.trueThrowBusinessError(Objects.isNull(model)).throwMessage("无效的"+modelId);
VUtils.trueThrowBusinessError(CollUtil.isEmpty(datas)).throwMessage("导入文件内容为空"); try (InputStream inputStream = file.getInputStream();org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream)){
Set<String> seen = new HashSet<>(); Sheet sheet=workbook.getSheetAt(0);
StringBuilder sb=new StringBuilder(); String no=StrUtil.trim(sheet.getRow(1).getCell(1).getStringCellValue());
datas.forEach(dto->{ VUtils.trueThrowBusinessError(!StrUtil.equals(model.getNo(),no)).throwMessage("产品型号不一致");
if(!seen.add(StrUtil.format("{}|{}|{}", dto.getLanguageCode(),dto.getIndexName(),dto.getName()))){ List<ProductModelParamsExcelDTO> datas = new ArrayList<>();
sb.append(StrUtil.format("语言编码:{},指标名称:{},参数名称:{}\r\n", dto.getLanguageCode(),dto.getIndexName(),dto.getName())); String indexName = null;
for (int index = 3, count = sheet.getLastRowNum(); index <= count; index++) {
// log.info("处理第{}行", index);
Row row = sheet.getRow(index);
if (Objects.isNull(row)) {
break;
} }
}); ProductModelParamsExcelDTO dto=new ProductModelParamsExcelDTO();
Cell cell0=row.getCell(0);
dto.setIndexName(StrUtil.trim(cell0.getStringCellValue()));
if (StrUtil.isBlank(dto.getIndexName())){
VUtils.trueThrowBusinessError(StrUtil.isBlank(indexName)).throwMessage("指标名称不能为空");
dto.setIndexName(indexName);
}else {
indexName=dto.getIndexName();
}
Cell cell1=row.getCell(1);
dto.setName(StrUtil.trim(cell1.getStringCellValue()));
Cell cell2=row.getCell(2);
dto.setValue(StrUtil.trim(cell2.getStringCellValue()));
Cell cell3=row.getCell(3);
dto.setMain(StrUtil.equals(cell3.getStringCellValue(),""));
Cell cell4=row.getCell(4);
dto.setCompare(StrUtil.equals(cell4.getStringCellValue(),""));
datas.add(dto);
}
// log.info("导入的数据是:{}", JSONUtil.toJsonStr(datas));
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(datas)).throwMessage("数据不能为空");
List<Language> languages = languageService.getLanguages();
languages.removeIf(l->StrUtil.equals(l.getCode(),Constant.DEFAULT_LANGUAGE_CODE));
int resultId; int resultId;
VUtils.trueThrowBusinessError(StrUtil.isNotBlank(sb.toString())) if (modelParamsId == 0) {
.throwMessage("以下数据存在重复项:\r\n" + sb);
if (Objects.isNull(modelParamsId)) {
resultId = productModelParamsService.add(modelId, IdUtil.getSnowflakeNextIdStr()); resultId = productModelParamsService.add(modelId, IdUtil.getSnowflakeNextIdStr());
} else { List<ProductModelParamsItem> items=new ArrayList<>();
int finalResultId = resultId;
datas.forEach(dto -> {
String batchNumber = IdUtil.getSnowflakeNextIdStr();
ProductModelParamsItem cn=new ProductModelParamsItem()
.setModelParamsId(finalResultId)
.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE)
.setBatchNumber(batchNumber)
.setIndexName(dto.getIndexName())
.setName(dto.getName())
.setValue(dto.getValue())
.setMain(dto.getMain())
.setCompare(dto.getCompare())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now());
items.add(cn);
languages.forEach(language -> {
ProductModelParamsItem item = new ProductModelParamsItem()
.setModelParamsId(finalResultId)
.setLanguageCode(language.getCode())
.setBatchNumber(batchNumber)
.setIndexName(translate.translateWord(dto.getIndexName(),language.getTranslateCode()))
.setName(translate.translateWord(dto.getName(),language.getTranslateCode()))
.setValue(translate.translateWord(dto.getValue(),language.getTranslateCode()))
.setMain(dto.getMain())
.setCompare(dto.getCompare())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now());
items.add(item);
});
});
productModelParamsItemService.saveBatch(items);
}else {
ProductModelParams info = productModelParamsService.getById(modelParamsId); ProductModelParams info = productModelParamsService.getById(modelParamsId);
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据"); VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的"+modelParamsId);
resultId = modelParamsId; resultId = modelParamsId;
if (Objects.equals(info.getState(), PublishState.Published.getState())) { if (Objects.equals(info.getState(), PublishState.Published.getState())) {
resultId = productModelParamsService.add(modelId, info.getBatchNumber()); resultId = productModelParamsService.add(modelId, info.getBatchNumber());
productModelParamsService.copyItems(modelParamsId, resultId); productModelParamsService.copyItems(modelParamsId, resultId);
} }
List<ProductModelParamsItem> oldItems = productModelParamsItemService.lambdaQuery().eq(ProductModelParamsItem::getModelParamsId, resultId).list();
int finalResultId1 = resultId;
List<ProductModelParamsItem> items=new ArrayList<>();
datas.forEach(dto -> {
if (oldItems.stream().noneMatch(it -> StrUtil.equals(it.getLanguageCode(), Constant.DEFAULT_LANGUAGE_CODE)
&& StrUtil.equals(it.getIndexName(), dto.getIndexName())
&& StrUtil.equals(it.getName(), dto.getName()))) {
String batchNumber = IdUtil.getSnowflakeNextIdStr();
ProductModelParamsItem cn=new ProductModelParamsItem()
.setModelParamsId(finalResultId1)
.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE)
.setBatchNumber(batchNumber)
.setIndexName(dto.getIndexName())
.setName(dto.getName())
.setValue(dto.getValue())
.setMain(dto.getMain())
.setCompare(dto.getCompare())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now());
items.add(cn);
languages.forEach(language -> {
ProductModelParamsItem item = new ProductModelParamsItem()
.setModelParamsId(finalResultId1)
.setLanguageCode(language.getCode())
.setBatchNumber(batchNumber)
.setIndexName(translate.translateWord(dto.getIndexName(), language.getTranslateCode()))
.setName(translate.translateWord(dto.getName(), language.getTranslateCode()))
.setValue(translate.translateWord(dto.getValue(), language.getTranslateCode()))
.setMain(dto.getMain())
.setCompare(dto.getCompare())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now());
items.add(item);
});
}
});
if (CollectionUtil.isNotEmpty(items)) {
productModelParamsItemService.saveBatch(items);
}
} }
productModelParamsItemService.importModelParamsItem(resultId, datas);
return ApiResult.success(resultId); return ApiResult.success(resultId);
// List<ProductModelParamsExcelDTO> datas = EecExcelUtil.getExcelContext(file.getInputStream(), ProductModelParamsExcelDTO.class);
// VUtils.trueThrowBusinessError(CollUtil.isEmpty(datas)).throwMessage("导入文件内容为空");
// Set<String> seen = new HashSet<>();
// StringBuilder sb=new StringBuilder();
// datas.forEach(dto->{
// if(!seen.add(StrUtil.format("{}|{}|{}", dto.getLanguageCode(),dto.getIndexName(),dto.getName()))){
// sb.append(StrUtil.format("语言编码:{},指标名称:{},参数名称:{}\r\n", dto.getLanguageCode(),dto.getIndexName(),dto.getName()));
// }
// });
// int resultId;
// VUtils.trueThrowBusinessError(StrUtil.isNotBlank(sb.toString()))
// .throwMessage("以下数据存在重复项:\r\n" + sb);
// if (Objects.isNull(modelParamsId)) {
// resultId = productModelParamsService.add(modelId, IdUtil.getSnowflakeNextIdStr());
// } else {
// ProductModelParams info = productModelParamsService.getById(modelParamsId);
// VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
// resultId = modelParamsId;
// if (Objects.equals(info.getState(), PublishState.Published.getState())) {
// resultId = productModelParamsService.add(modelId, info.getBatchNumber());
// productModelParamsService.copyItems(modelParamsId, resultId);
// }
// }
// productModelParamsItemService.importModelParamsItem(resultId, datas);
// return ApiResult.success(resultId);
} catch (IOException e) { } catch (IOException e) {
throw new NflgException(STATE.BusinessError, "导入失败:" + e.getMessage()); throw new NflgException(STATE.BusinessError, "导入失败:" + e.getMessage());
} }

View File

@ -44,12 +44,6 @@
<groupId>com.nflg</groupId> <groupId>com.nflg</groupId>
<artifactId>nflg-mobilebroken-starter</artifactId> <artifactId>nflg-mobilebroken-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>

View File

@ -55,12 +55,6 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>com.nflg</groupId> <groupId>com.nflg</groupId>
<artifactId>nflg-mobilebroken-repository</artifactId> <artifactId>nflg-mobilebroken-repository</artifactId>

View File

@ -1,42 +0,0 @@
package com.nflg.mobilebroken.cfs.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Configuration
public class JacksonConfig {
// 定义全局日期时间格式
private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
// 创建并注册 JavaTimeModule设置日期格式化
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(
java.time.LocalDateTime.class,
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT))
);
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 注册模块到 ObjectMapper
objectMapper.registerModule(javaTimeModule);
// 禁用时间戳默认是 true会序列化为数组
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return objectMapper;
}
}

View File

@ -2,45 +2,33 @@ package com.nflg.mobilebroken.common.pojo.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.ttzero.excel.annotation.ExcelColumn;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class ProductModelParamsExcelDTO { public class ProductModelParamsExcelDTO {
/**
* 语言编码
*/
@ExcelColumn("语言编码")
private String languageCode;
/** /**
* 指标名称 * 指标名称
*/ */
@ExcelColumn("指标名称")
private String indexName; private String indexName;
/** /**
* 参数名称 * 参数名称
*/ */
@ExcelColumn("参数名称")
private String name; private String name;
/** /**
* 参数指标 * 参数指标
*/ */
@ExcelColumn("参数指标")
private String value; private String value;
/** /**
* 是否主要参数 * 是否主要参数
*/ */
@ExcelColumn("是否主要参数")
private Boolean main; private Boolean main;
/** /**
* 是否参与比较 * 是否参与比较
*/ */
@ExcelColumn("是否参与比较")
private Boolean compare; private Boolean compare;
} }

View File

@ -12,6 +12,11 @@ public class FrontendProductSeriesSearchVO {
*/ */
private Integer moduleId; private Integer moduleId;
/**
* 批次号
*/
private String batchNumber;
/** /**
* 名称 * 名称
*/ */

View File

@ -10,9 +10,9 @@ import java.util.List;
public class FrontendProductTypeSearchVO extends FrontendProductSeriesSearchVO{ public class FrontendProductTypeSearchVO extends FrontendProductSeriesSearchVO{
/** /**
* 批次号 * 系列批次号
*/ */
private String batchNumber; private String seriesNumber;
/** /**
* 机型说明 * 机型说明

View File

@ -0,0 +1,21 @@
package com.nflg.mobilebroken.common.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class ModuleVO {
private Integer id;
private String name;
/**
* 系列
*/
private List<ProductSeriesSimpleVO> series;
}

View File

@ -5,6 +5,8 @@ import lombok.Data;
@Data @Data
public class ProductHonorVO { public class ProductHonorVO {
private Integer id;
/** /**
* 年份 * 年份
**/ **/

View File

@ -16,6 +16,11 @@ public class ProductModelInfoVO {
*/ */
private Integer moduleId; private Integer moduleId;
/**
* 系列批次号
*/
private String seriesNumber;
/** /**
* 类型批次号 * 类型批次号
*/ */
@ -62,10 +67,15 @@ public class ProductModelInfoVO {
private ProductHotImageInfoVO hotImage; private ProductHotImageInfoVO hotImage;
/** /**
* 主要参数列表 * 所有技术参数列表
*/ */
private List<ProductModelMainParamsItemChildrenVO> params; private List<ProductModelMainParamsItemChildrenVO> params;
/**
* 主要技术参数
*/
private List<ProductParamsItemVO> mainParams;
/** /**
* 产品图册 * 产品图册
*/ */

View File

@ -41,12 +41,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>--> <!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-jsqlparser</artifactId>--> <!-- <artifactId>mybatis-plus-jsqlparser</artifactId>-->

View File

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 基础信息 * 基础信息
@ -72,8 +73,12 @@ public class InfoController extends BaseController{
* 获取模块列表 * 获取模块列表
*/ */
@GetMapping("/getModuleList") @GetMapping("/getModuleList")
public ApiResult<List<DictionaryItem>> getModuleList(){ public ApiResult<List<ModuleVO>> getModuleList(){
return ApiResult.success(dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_PRODUCT_MODULE)); List<DictionaryItem> items = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_PRODUCT_MODULE);
return ApiResult.success(items.stream().map(it -> new ModuleVO()
.setId(it.getId())
.setName(it.getName())
.setSeries(productSeriesService.getSimpleList(it.getId(), MultilingualUtil.getLanguage()))).collect(Collectors.toList()));
} }
/** /**

View File

@ -26,5 +26,5 @@ public interface ProductModelMapper extends BaseMapper<ProductModel> {
Page<FrontendProductModelSearchVO> search(String name, String language, Page<?> page); Page<FrontendProductModelSearchVO> search(String name, String language, Page<?> page);
List<ProductModelSimpleVO> getSimpleList(Integer moduleId,String typeNumber); List<ProductModelSimpleVO> getSimpleList(String typeNumber);
} }

View File

@ -2,6 +2,7 @@ package com.nflg.mobilebroken.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
import com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO;
import com.nflg.mobilebroken.repository.entity.ProductModelParams; import com.nflg.mobilebroken.repository.entity.ProductModelParams;
import java.util.List; import java.util.List;
@ -21,4 +22,6 @@ public interface ProductModelParamsMapper extends BaseMapper<ProductModelParams>
List<ProductModelParamVO> getAllListByLanguage(Integer modelId, String language); List<ProductModelParamVO> getAllListByLanguage(Integer modelId, String language);
void copyItems(Integer oldId, Integer newId); void copyItems(Integer oldId, Integer newId);
List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language);
} }

View File

@ -31,4 +31,6 @@ public interface ProductSeriesMapper extends BaseMapper<ProductSeries> {
Page<FrontendProductSeriesSearchVO> search(String name, String language, Page<?> page); Page<FrontendProductSeriesSearchVO> search(String name, String language, Page<?> page);
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId); List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId);
List<ProductSeriesSimpleVO> getSimpleListByLanguage(Integer moduleId, String language);
} }

View File

@ -1,7 +1,6 @@
package com.nflg.mobilebroken.repository.service; package com.nflg.mobilebroken.repository.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.mobilebroken.common.pojo.dto.ProductModelParamsExcelDTO;
import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.request.*;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemVO;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamsItemVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamsItemVO;
@ -9,7 +8,6 @@ import com.nflg.mobilebroken.repository.entity.ProductModelParamsItem;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
@ -40,7 +38,7 @@ public interface IProductModelParamsItemService extends IService<ProductModelPar
void deleteParam(@Valid ProductModelParamsItemDeleteRequest request); void deleteParam(@Valid ProductModelParamsItemDeleteRequest request);
void importModelParamsItem(@Valid @NotNull Integer modelParamsId, List<ProductModelParamsExcelDTO> datas); // void importModelParamsItem(@Valid @NotNull Integer modelParamsId, List<ProductModelParamsExcelDTO> datas);
void updateItem(@Valid ProductModelParamsItemUpdateRequest1 request); void updateItem(@Valid ProductModelParamsItemUpdateRequest1 request);

View File

@ -7,6 +7,7 @@ import com.nflg.mobilebroken.common.pojo.request.ProductModelIntroSearchRequest;
import com.nflg.mobilebroken.common.pojo.request.ProductPublishRequest; import com.nflg.mobilebroken.common.pojo.request.ProductPublishRequest;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
import com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO;
import com.nflg.mobilebroken.repository.entity.ProductModelParams; import com.nflg.mobilebroken.repository.entity.ProductModelParams;
import javax.validation.Valid; import javax.validation.Valid;
@ -49,4 +50,6 @@ public interface IProductModelParamsService extends IService<ProductModelParams>
List<ProductModelMainParamsItemChildrenVO> getAListByLanguage(Integer modelId, String language); List<ProductModelMainParamsItemChildrenVO> getAListByLanguage(Integer modelId, String language);
List<ProductModelMainParamsItemChildrenVO> getCNList(Integer modelId); List<ProductModelMainParamsItemChildrenVO> getCNList(Integer modelId);
List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language);
} }

View File

@ -48,5 +48,5 @@ public interface IProductModelService extends IService<ProductModel> {
Page<FrontendProductModelSearchVO> search(@Valid ProductSeriesSearchRequest request, String language); Page<FrontendProductModelSearchVO> search(@Valid ProductSeriesSearchRequest request, String language);
List<ProductModelSimpleVO> getSimpleList(Integer moduleId,String typeNumber); List<ProductModelSimpleVO> getSimpleList(String typeNumber);
} }

View File

@ -36,6 +36,8 @@ public interface IProductSeriesService extends IService<ProductSeries> {
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId); List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId);
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId,String language);
ProductSeriesInfoVO getInfo(@Valid @NotNull Integer seriesId); ProductSeriesInfoVO getInfo(@Valid @NotNull Integer seriesId);
List<ProductSeriesSearchVO> getListForSort(); List<ProductSeriesSearchVO> getListForSort();

View File

@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.mobilebroken.common.constant.Constant; import com.nflg.mobilebroken.common.constant.Constant;
import com.nflg.mobilebroken.common.pojo.dto.ProductModelParamsExcelDTO;
import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.request.*;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemVO; import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemVO;
@ -25,10 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -153,12 +149,15 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
.setIndexName(indexName) .setIndexName(indexName)
.setBatchNumber(CollectionUtil.isNotEmpty(itemData) ? itemData.get(0).getBatchNumber() : "") .setBatchNumber(CollectionUtil.isNotEmpty(itemData) ? itemData.get(0).getBatchNumber() : "")
.setItems(itemData.stream() .setItems(itemData.stream()
.sorted(Comparator.comparing(ProductModelParamsItem::getId))
.filter(pi -> StrUtil.isNotBlank(pi.getName())) .filter(pi -> StrUtil.isNotBlank(pi.getName()))
.map(pi -> Convert.convert(ProductParamsItemVO.class, pi)) .map(pi -> Convert.convert(ProductParamsItemVO.class, pi))
.collect(Collectors.toList())); .collect(Collectors.toList()));
vo.getItems().add(ivo); vo.getItems().add(ivo);
}); });
vo.getItems().sort(Comparator.comparing(ProductModelMainParamsItemChildrenVO::getIndexName));
}); });
vos.sort(Comparator.comparing(ProductModelParamsItemVO::getLanguageCode));
return vos; return vos;
} }
@ -218,43 +217,43 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
); );
} }
@Transactional // @Transactional
@Override // @Override
public void importModelParamsItem(Integer modelParamsId, List<ProductModelParamsExcelDTO> datas) { // public void importModelParamsItem(Integer modelParamsId, List<ProductModelParamsExcelDTO> datas) {
List<ProductModelParamsItem> list = lambdaQuery().eq(ProductModelParamsItem::getModelParamsId, modelParamsId).list(); // List<ProductModelParamsItem> list = lambdaQuery().eq(ProductModelParamsItem::getModelParamsId, modelParamsId).list();
List<ProductModelParamsItem> forAdd=new ArrayList<>(); // List<ProductModelParamsItem> forAdd=new ArrayList<>();
datas.forEach(data -> { // datas.forEach(data -> {
ProductModelParamsItem item = list.stream().filter(li -> StrUtil.equals(li.getLanguageCode(), data.getLanguageCode()) // ProductModelParamsItem item = list.stream().filter(li -> StrUtil.equals(li.getLanguageCode(), data.getLanguageCode())
&& StrUtil.equals(li.getIndexName(), data.getIndexName()) // && StrUtil.equals(li.getIndexName(), data.getIndexName())
&& StrUtil.equals(li.getName(), data.getName())) // && StrUtil.equals(li.getName(), data.getName()))
.findFirst() // .findFirst()
.orElse(null); // .orElse(null);
if (Objects.nonNull(item)){ // if (Objects.nonNull(item)){
item.setValue(data.getValue()); // item.setValue(data.getValue());
item.setMain(data.getMain()); // item.setMain(data.getMain());
item.setCompare(data.getCompare()); // item.setCompare(data.getCompare());
item.setUpdateBy(AdminUserUtil.getUserName()); // item.setUpdateBy(AdminUserUtil.getUserName());
item.setUpdateTime(LocalDateTime.now()); // item.setUpdateTime(LocalDateTime.now());
}else { // }else {
forAdd.add(new ProductModelParamsItem() // forAdd.add(new ProductModelParamsItem()
.setModelParamsId(modelParamsId) // .setModelParamsId(modelParamsId)
.setLanguageCode(data.getLanguageCode()) // .setLanguageCode(data.getLanguageCode())
.setIndexName(data.getIndexName()) // .setIndexName(data.getIndexName())
.setName(data.getName()) // .setName(data.getName())
.setValue(data.getValue()) // .setValue(data.getValue())
.setMain(data.getMain()) // .setMain(data.getMain())
.setCompare(data.getCompare()) // .setCompare(data.getCompare())
.setCreateBy(AdminUserUtil.getUserName()) // .setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())); // .setCreateTime(LocalDateTime.now()));
} // }
}); // });
if (CollectionUtil.isNotEmpty(list)){ // if (CollectionUtil.isNotEmpty(list)){
updateBatchById(list); // updateBatchById(list);
} // }
if (CollectionUtil.isNotEmpty(forAdd)){ // if (CollectionUtil.isNotEmpty(forAdd)){
saveBatch(forAdd); // saveBatch(forAdd);
} // }
} // }
@Override @Override
public void updateItem(ProductModelParamsItemUpdateRequest1 request) { public void updateItem(ProductModelParamsItemUpdateRequest1 request) {

View File

@ -235,4 +235,9 @@ public class ProductModelParamsServiceImpl extends ServiceImpl<ProductModelParam
}); });
return vos; return vos;
} }
@Override
public List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language) {
return baseMapper.getMainListByLanguage(modelId,language);
}
} }

View File

@ -105,6 +105,9 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
info.setRecommend(false); info.setRecommend(false);
info.setRecommendTime(null); info.setRecommendTime(null);
} }
info.setModuleId(request.getModuleId());
info.setSeriesNumber(request.getSeriesNumber());
info.setTypeNumber(request.getTypeNumber());
info.setImage(request.getImage()); info.setImage(request.getImage());
info.setUpdateBy(AdminUserUtil.getUserName()); info.setUpdateBy(AdminUserUtil.getUserName());
info.setUpdateTime(LocalDateTime.now()); info.setUpdateTime(LocalDateTime.now());
@ -290,6 +293,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
return new ProductModelInfoVO() return new ProductModelInfoVO()
.setId(productModel.getId()) .setId(productModel.getId())
.setModuleId(productModel.getModuleId()) .setModuleId(productModel.getModuleId())
.setSeriesNumber(productModel.getSeriesNumber())
.setTypeNumber(productModel.getTypeNumber()) .setTypeNumber(productModel.getTypeNumber())
.setRecommend(productModel.getRecommend()) .setRecommend(productModel.getRecommend())
.setSort(productModel.getSort()) .setSort(productModel.getSort())
@ -300,6 +304,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
.setMerits(Objects.isNull(intro)?"":intro.getMerits()) .setMerits(Objects.isNull(intro)?"":intro.getMerits())
.setHotImage(productModelHotimageService.getListByLanguage(modelId)) .setHotImage(productModelHotimageService.getListByLanguage(modelId))
.setParams(productPartParamsService.getAListByLanguage(modelId, language)) .setParams(productPartParamsService.getAListByLanguage(modelId, language))
.setMainParams(productPartParamsService.getMainListByLanguage(modelId, language))
.setImages(productModelImageService.getListByLanguage(modelId, language)) .setImages(productModelImageService.getListByLanguage(modelId, language))
.setVideos(productModelVideoService.getListByLanguage(modelId, language)) .setVideos(productModelVideoService.getListByLanguage(modelId, language))
.setFiles(productModelFileService.getListByLanguage(modelId, language)); .setFiles(productModelFileService.getListByLanguage(modelId, language));
@ -389,8 +394,8 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
} }
@Override @Override
public List<ProductModelSimpleVO> getSimpleList(Integer moduleId, String typeNumber) { public List<ProductModelSimpleVO> getSimpleList(String typeNumber) {
return baseMapper.getSimpleList(moduleId,typeNumber); return baseMapper.getSimpleList(typeNumber);
} }
private ProductModelCompareInfoVO getModelCompareInfo(Integer modelId, String language){ private ProductModelCompareInfoVO getModelCompareInfo(Integer modelId, String language){

View File

@ -203,6 +203,11 @@ public class ProductSeriesServiceImpl extends ServiceImpl<ProductSeriesMapper, P
return baseMapper.getSimpleList(moduleId); return baseMapper.getSimpleList(moduleId);
} }
@Override
public List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId, String language) {
return baseMapper.getSimpleListByLanguage(moduleId,language);
}
@Override @Override
public ProductSeriesInfoVO getInfo(Integer seriesId) { public ProductSeriesInfoVO getInfo(Integer seriesId) {
ProductSeries series = getById(seriesId); ProductSeries series = getById(seriesId);

View File

@ -104,6 +104,8 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
.orElse(null); .orElse(null);
VUtils.trueThrowBusinessError(Objects.isNull(cn)).throwMessage("必须包含中文数据"); VUtils.trueThrowBusinessError(Objects.isNull(cn)).throwMessage("必须包含中文数据");
info.setName(cn.getName().trim()); info.setName(cn.getName().trim());
info.setModuleId(request.getModuleId());
info.setSeriesNumber(request.getSeriesNumber());
// info.setSort(request.getSort()); // info.setSort(request.getSort());
info.setUpdateBy(AdminUserUtil.getUserName()); info.setUpdateBy(AdminUserUtil.getUserName());
info.setUpdateTime(LocalDateTime.now()); info.setUpdateTime(LocalDateTime.now());
@ -134,7 +136,7 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
public List<ProductTypeVO> get(Integer moduleId, String seriesNumber, String language) { public List<ProductTypeVO> get(Integer moduleId, String seriesNumber, String language) {
List<ProductTypeVO> vos = baseMapper.get(moduleId, seriesNumber, language); List<ProductTypeVO> vos = baseMapper.get(moduleId, seriesNumber, language);
vos.forEach(vo -> { vos.forEach(vo -> {
vo.setModels(productModelService.getSimpleList(moduleId,vo.getTypeNumber())); vo.setModels(productModelService.getSimpleList(vo.getTypeNumber()));
}); });
return vos; return vos;
} }
@ -297,7 +299,7 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
public Page<FrontendProductTypeSearchVO> search(ProductSeriesSearchRequest request, String language) { public Page<FrontendProductTypeSearchVO> search(ProductSeriesSearchRequest request, String language) {
Page<FrontendProductTypeSearchVO> datas = baseMapper.search(request.getName(), language, new Page<>(request.getPage(), request.getPageSize())); Page<FrontendProductTypeSearchVO> datas = baseMapper.search(request.getName(), language, new Page<>(request.getPage(), request.getPageSize()));
datas.getRecords().forEach(it -> { datas.getRecords().forEach(it -> {
it.setModels(productModelService.getSimpleList(it.getModuleId(), it.getBatchNumber())); it.setModels(productModelService.getSimpleList(it.getBatchNumber()));
}); });
return datas; return datas;
} }

View File

@ -26,7 +26,7 @@
</select> </select>
<select id="get" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductHonorVO"> <select id="get" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductHonorVO">
SELECT YEAR(ph.obtaining_time) AS 'year',phi.title,phi.image SELECT ph.id,YEAR(ph.obtaining_time) AS 'year',phi.title,phi.image
FROM product_honor ph FROM product_honor ph
LEFT JOIN product_honor_info phi ON phi.honor_id=ph.id AND phi.language_code=#{language} LEFT JOIN product_honor_info phi ON phi.honor_id=ph.id AND phi.language_code=#{language}
WHERE ph.enable=1 AND ph.state=1 WHERE ph.enable=1 AND ph.state=1

View File

@ -63,7 +63,8 @@
</select> </select>
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductModelSearchVO"> <select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductModelSearchVO">
SELECT pm.id, pm.`no`, pm.image, pm.recommend, pmii.`desc`, pmii.feature SELECT pm.*, pmii.`desc`, pmii.feature
,(SELECT `name` FROM product_type WHERE batch_number=pm.type_number AND state!=2 ORDER BY state DESC LIMIT 1) as 'typeName'
FROM product_model pm FROM product_model pm
INNER JOIN product_model_intro pmi ON pm.id = pmi.model_id INNER JOIN product_model_intro pmi ON pm.id = pmi.model_id
INNER JOIN product_model_intro_item pmii ON pmi.id = pmii.model_intro_id INNER JOIN product_model_intro_item pmii ON pmi.id = pmii.model_intro_id
@ -78,7 +79,7 @@
<select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO"> <select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO">
SELECT * SELECT *
FROM product_model FROM product_model
WHERE `enable`=1 AND state=1 AND module_id=#{moduleId} AND type_number=#{typeNumber} WHERE `enable`=1 AND state=1 AND type_number=#{typeNumber}
ORDER BY recommend DESC,sort,id DESC ORDER BY recommend DESC,sort,id DESC
LIMIT 8 LIMIT 8
</select> </select>

View File

@ -19,7 +19,6 @@
INNER JOIN product_model_params_item pmpi ON pmp.id = pmpi.model_params_id INNER JOIN product_model_params_item pmpi ON pmp.id = pmpi.model_params_id
WHERE pmp.model_id = #{modelId} WHERE pmp.model_id = #{modelId}
AND pmp.state = 1 AND pmp.state = 1
AND pmpi.compare = 1
AND pmpi.language_code = #{language} AND pmpi.language_code = #{language}
ORDER BY pmp.id DESC ORDER BY pmp.id DESC
</select> </select>
@ -30,4 +29,16 @@
FROM product_model_params_item FROM product_model_params_item
WHERE model_params_id=#{oldId} WHERE model_params_id=#{oldId}
</select> </select>
<select id="getMainListByLanguage" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO">
SELECT pmpi.*
FROM product_model_params pmp
INNER JOIN product_model_params_item pmpi ON pmp.id = pmpi.model_params_id
WHERE pmp.model_id = #{modelId}
AND pmp.state = 1
AND pmpi.main = 1
AND pmpi.compare = 1
AND pmpi.language_code = #{language}
ORDER BY pmp.id DESC
</select>
</mapper> </mapper>

View File

@ -51,7 +51,7 @@
</select> </select>
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductSeriesSearchVO"> <select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductSeriesSearchVO">
SELECT ps.id,ps.module_id, psi.`name`, psi.content, psi.image SELECT ps.id,ps.module_id,ps.batch_number, psi.*
FROM product_series ps FROM product_series ps
INNER JOIN product_series_info psi ON ps.id = psi.series_id INNER JOIN product_series_info psi ON ps.id = psi.series_id
WHERE ps.state = 1 WHERE ps.state = 1
@ -64,6 +64,14 @@
<select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductSeriesSimpleVO"> <select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductSeriesSimpleVO">
select distinct batch_number,name select distinct batch_number,name
from product_series from product_series
where state!=2 where state!=2 and module_id=#{moduleId}
</select>
<select id="getSimpleListByLanguage" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductSeriesSimpleVO">
select distinct batch_number,psi.name,sort
from product_series ps
inner join product_series_info psi on ps.id=psi.series_id
where state=1 and enable=1 and module_id=#{moduleId} and psi.language_code=#{language}
order by ps.sort
</select> </select>
</mapper> </mapper>

View File

@ -56,7 +56,7 @@
</select> </select>
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductTypeSearchVO"> <select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.FrontendProductTypeSearchVO">
SELECT pt.id, pti.`name`, pti.content, pti.image, pti.model_desc SELECT pt.id,pt.batch_number,pt.series_number,pt.module_id, pti.*
FROM product_type pt FROM product_type pt
INNER JOIN product_type_info pti ON pt.id = pti.type_id INNER JOIN product_type_info pti ON pt.id = pti.type_id
WHERE pt.state = 1 WHERE pt.state = 1

View File

@ -108,6 +108,10 @@
<groupId>cn.dev33</groupId> <groupId>cn.dev33</groupId>
<artifactId>sa-token-jwt</artifactId> <artifactId>sa-token-jwt</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

View File

@ -1,4 +1,4 @@
package com.nflg.mobilebroken.admin.config; package com.nflg.mobilebroken.starter.config;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;