feat: 产品中心
This commit is contained in:
parent
902a3937d6
commit
91297cc2f1
|
|
@ -33,12 +33,6 @@
|
|||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.nflg.mobilebroken.admin.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;
|
||||
|
|
@ -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.request.*;
|
||||
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.PageUtil;
|
||||
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.xssf.usermodel.XSSFWorkbook;
|
||||
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.multipart.MultipartFile;
|
||||
import org.ttzero.excel.entity.TemplateSheet;
|
||||
import org.ttzero.excel.entity.Workbook;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -421,10 +423,7 @@ public class ProductModelController extends ControllerBase{
|
|||
@GetMapping("/downloadParamImportTemplate")
|
||||
public void downloadParamImportTemplate(HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.setResponseExcelHeader(response, "机型参数导入模版");
|
||||
ClassPathResource resource = new ClassPathResource("templates/ProductModelParamImport.xlsx");
|
||||
new Workbook()
|
||||
.addSheet(new TemplateSheet(resource.getInputStream()))
|
||||
.writeTo(response.getOutputStream());
|
||||
StreamUtils.copy(new ClassPathResource("templates/ProductModelParamImport.xlsx").getInputStream(), response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -608,41 +607,162 @@ public class ProductModelController extends ControllerBase{
|
|||
|
||||
/**
|
||||
* 导入设备技术参数项
|
||||
* @param modelId 机型ID
|
||||
* @param modelParamsId 机型参数ID
|
||||
* @param file 文件
|
||||
* @return 机型参数id
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("/importModelParamsItem")
|
||||
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) {
|
||||
try {
|
||||
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()));
|
||||
ProductModel model=productModelService.getById(modelId);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(model)).throwMessage("无效的"+modelId);
|
||||
try (InputStream inputStream = file.getInputStream();org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream)){
|
||||
Sheet sheet=workbook.getSheetAt(0);
|
||||
String no=StrUtil.trim(sheet.getRow(1).getCell(1).getStringCellValue());
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(model.getNo(),no)).throwMessage("产品型号不一致");
|
||||
List<ProductModelParamsExcelDTO> datas = new ArrayList<>();
|
||||
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;
|
||||
VUtils.trueThrowBusinessError(StrUtil.isNotBlank(sb.toString()))
|
||||
.throwMessage("以下数据存在重复项:\r\n" + sb);
|
||||
if (Objects.isNull(modelParamsId)) {
|
||||
if (modelParamsId == 0) {
|
||||
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);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的"+modelParamsId);
|
||||
resultId = modelParamsId;
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())) {
|
||||
resultId = productModelParamsService.add(modelId, info.getBatchNumber());
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
throw new NflgException(STATE.BusinessError, "导入失败:" + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@
|
|||
<groupId>com.nflg</groupId>
|
||||
<artifactId>nflg-mobilebroken-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
|
|
|
|||
|
|
@ -55,12 +55,6 @@
|
|||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nflg</groupId>
|
||||
<artifactId>nflg-mobilebroken-repository</artifactId>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,45 +2,33 @@ package com.nflg.mobilebroken.common.pojo.dto;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductModelParamsExcelDTO {
|
||||
|
||||
/**
|
||||
* 语言编码
|
||||
*/
|
||||
@ExcelColumn("语言编码")
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
@ExcelColumn("指标名称")
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
@ExcelColumn("参数名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 参数指标
|
||||
*/
|
||||
@ExcelColumn("参数指标")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 是否主要参数
|
||||
*/
|
||||
@ExcelColumn("是否主要参数")
|
||||
private Boolean main;
|
||||
|
||||
/**
|
||||
* 是否参与比较
|
||||
*/
|
||||
@ExcelColumn("是否参与比较")
|
||||
private Boolean compare;
|
||||
}
|
||||
|
|
@ -12,6 +12,11 @@ public class FrontendProductSeriesSearchVO {
|
|||
*/
|
||||
private Integer moduleId;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import java.util.List;
|
|||
public class FrontendProductTypeSearchVO extends FrontendProductSeriesSearchVO{
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
* 系列批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
private String seriesNumber;
|
||||
|
||||
/**
|
||||
* 机型说明
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -5,6 +5,8 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ProductHonorVO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 年份
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ public class ProductModelInfoVO {
|
|||
*/
|
||||
private Integer moduleId;
|
||||
|
||||
/**
|
||||
* 系列批次号
|
||||
*/
|
||||
private String seriesNumber;
|
||||
|
||||
/**
|
||||
* 类型批次号
|
||||
*/
|
||||
|
|
@ -62,10 +67,15 @@ public class ProductModelInfoVO {
|
|||
private ProductHotImageInfoVO hotImage;
|
||||
|
||||
/**
|
||||
* 主要参数列表
|
||||
* 所有技术参数列表
|
||||
*/
|
||||
private List<ProductModelMainParamsItemChildrenVO> params;
|
||||
|
||||
/**
|
||||
* 主要技术参数
|
||||
*/
|
||||
private List<ProductParamsItemVO> mainParams;
|
||||
|
||||
/**
|
||||
* 产品图册
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-jsqlparser</artifactId>-->
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
|
|
@ -72,8 +73,12 @@ public class InfoController extends BaseController{
|
|||
* 获取模块列表
|
||||
*/
|
||||
@GetMapping("/getModuleList")
|
||||
public ApiResult<List<DictionaryItem>> getModuleList(){
|
||||
return ApiResult.success(dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_PRODUCT_MODULE));
|
||||
public ApiResult<List<ModuleVO>> getModuleList(){
|
||||
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()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ public interface ProductModelMapper extends BaseMapper<ProductModel> {
|
|||
|
||||
Page<FrontendProductModelSearchVO> search(String name, String language, Page<?> page);
|
||||
|
||||
List<ProductModelSimpleVO> getSimpleList(Integer moduleId,String typeNumber);
|
||||
List<ProductModelSimpleVO> getSimpleList(String typeNumber);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.mobilebroken.repository.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelParams;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,4 +22,6 @@ public interface ProductModelParamsMapper extends BaseMapper<ProductModelParams>
|
|||
List<ProductModelParamVO> getAllListByLanguage(Integer modelId, String language);
|
||||
|
||||
void copyItems(Integer oldId, Integer newId);
|
||||
|
||||
List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,6 @@ public interface ProductSeriesMapper extends BaseMapper<ProductSeries> {
|
|||
Page<FrontendProductSeriesSearchVO> search(String name, String language, Page<?> page);
|
||||
|
||||
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId);
|
||||
|
||||
List<ProductSeriesSimpleVO> getSimpleListByLanguage(Integer moduleId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.nflg.mobilebroken.repository.service;
|
||||
|
||||
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.vo.ProductModelMainParamsItemVO;
|
||||
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.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +38,7 @@ public interface IProductModelParamsItemService extends IService<ProductModelPar
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.vo.ProductModelMainParamsItemChildrenVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelParams;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
|
@ -49,4 +50,6 @@ public interface IProductModelParamsService extends IService<ProductModelParams>
|
|||
List<ProductModelMainParamsItemChildrenVO> getAListByLanguage(Integer modelId, String language);
|
||||
|
||||
List<ProductModelMainParamsItemChildrenVO> getCNList(Integer modelId);
|
||||
|
||||
List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,5 +48,5 @@ public interface IProductModelService extends IService<ProductModel> {
|
|||
|
||||
Page<FrontendProductModelSearchVO> search(@Valid ProductSeriesSearchRequest request, String language);
|
||||
|
||||
List<ProductModelSimpleVO> getSimpleList(Integer moduleId,String typeNumber);
|
||||
List<ProductModelSimpleVO> getSimpleList(String typeNumber);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public interface IProductSeriesService extends IService<ProductSeries> {
|
|||
|
||||
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId);
|
||||
|
||||
List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId,String language);
|
||||
|
||||
ProductSeriesInfoVO getInfo(@Valid @NotNull Integer seriesId);
|
||||
|
||||
List<ProductSeriesSearchVO> getListForSort();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.vo.ProductModelMainParamsItemChildrenVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemVO;
|
||||
|
|
@ -25,10 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -153,12 +149,15 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
.setIndexName(indexName)
|
||||
.setBatchNumber(CollectionUtil.isNotEmpty(itemData) ? itemData.get(0).getBatchNumber() : "")
|
||||
.setItems(itemData.stream()
|
||||
.sorted(Comparator.comparing(ProductModelParamsItem::getId))
|
||||
.filter(pi -> StrUtil.isNotBlank(pi.getName()))
|
||||
.map(pi -> Convert.convert(ProductParamsItemVO.class, pi))
|
||||
.collect(Collectors.toList()));
|
||||
vo.getItems().add(ivo);
|
||||
});
|
||||
vo.getItems().sort(Comparator.comparing(ProductModelMainParamsItemChildrenVO::getIndexName));
|
||||
});
|
||||
vos.sort(Comparator.comparing(ProductModelParamsItemVO::getLanguageCode));
|
||||
return vos;
|
||||
}
|
||||
|
||||
|
|
@ -218,43 +217,43 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void importModelParamsItem(Integer modelParamsId, List<ProductModelParamsExcelDTO> datas) {
|
||||
List<ProductModelParamsItem> list = lambdaQuery().eq(ProductModelParamsItem::getModelParamsId, modelParamsId).list();
|
||||
List<ProductModelParamsItem> forAdd=new ArrayList<>();
|
||||
datas.forEach(data -> {
|
||||
ProductModelParamsItem item = list.stream().filter(li -> StrUtil.equals(li.getLanguageCode(), data.getLanguageCode())
|
||||
&& StrUtil.equals(li.getIndexName(), data.getIndexName())
|
||||
&& StrUtil.equals(li.getName(), data.getName()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(item)){
|
||||
item.setValue(data.getValue());
|
||||
item.setMain(data.getMain());
|
||||
item.setCompare(data.getCompare());
|
||||
item.setUpdateBy(AdminUserUtil.getUserName());
|
||||
item.setUpdateTime(LocalDateTime.now());
|
||||
}else {
|
||||
forAdd.add(new ProductModelParamsItem()
|
||||
.setModelParamsId(modelParamsId)
|
||||
.setLanguageCode(data.getLanguageCode())
|
||||
.setIndexName(data.getIndexName())
|
||||
.setName(data.getName())
|
||||
.setValue(data.getValue())
|
||||
.setMain(data.getMain())
|
||||
.setCompare(data.getCompare())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now()));
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
updateBatchById(list);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(forAdd)){
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
}
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public void importModelParamsItem(Integer modelParamsId, List<ProductModelParamsExcelDTO> datas) {
|
||||
// List<ProductModelParamsItem> list = lambdaQuery().eq(ProductModelParamsItem::getModelParamsId, modelParamsId).list();
|
||||
// List<ProductModelParamsItem> forAdd=new ArrayList<>();
|
||||
// datas.forEach(data -> {
|
||||
// ProductModelParamsItem item = list.stream().filter(li -> StrUtil.equals(li.getLanguageCode(), data.getLanguageCode())
|
||||
// && StrUtil.equals(li.getIndexName(), data.getIndexName())
|
||||
// && StrUtil.equals(li.getName(), data.getName()))
|
||||
// .findFirst()
|
||||
// .orElse(null);
|
||||
// if (Objects.nonNull(item)){
|
||||
// item.setValue(data.getValue());
|
||||
// item.setMain(data.getMain());
|
||||
// item.setCompare(data.getCompare());
|
||||
// item.setUpdateBy(AdminUserUtil.getUserName());
|
||||
// item.setUpdateTime(LocalDateTime.now());
|
||||
// }else {
|
||||
// forAdd.add(new ProductModelParamsItem()
|
||||
// .setModelParamsId(modelParamsId)
|
||||
// .setLanguageCode(data.getLanguageCode())
|
||||
// .setIndexName(data.getIndexName())
|
||||
// .setName(data.getName())
|
||||
// .setValue(data.getValue())
|
||||
// .setMain(data.getMain())
|
||||
// .setCompare(data.getCompare())
|
||||
// .setCreateBy(AdminUserUtil.getUserName())
|
||||
// .setCreateTime(LocalDateTime.now()));
|
||||
// }
|
||||
// });
|
||||
// if (CollectionUtil.isNotEmpty(list)){
|
||||
// updateBatchById(list);
|
||||
// }
|
||||
// if (CollectionUtil.isNotEmpty(forAdd)){
|
||||
// saveBatch(forAdd);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateItem(ProductModelParamsItemUpdateRequest1 request) {
|
||||
|
|
|
|||
|
|
@ -235,4 +235,9 @@ public class ProductModelParamsServiceImpl extends ServiceImpl<ProductModelParam
|
|||
});
|
||||
return vos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductParamsItemVO> getMainListByLanguage(Integer modelId, String language) {
|
||||
return baseMapper.getMainListByLanguage(modelId,language);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
info.setRecommend(false);
|
||||
info.setRecommendTime(null);
|
||||
}
|
||||
info.setModuleId(request.getModuleId());
|
||||
info.setSeriesNumber(request.getSeriesNumber());
|
||||
info.setTypeNumber(request.getTypeNumber());
|
||||
info.setImage(request.getImage());
|
||||
info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
info.setUpdateTime(LocalDateTime.now());
|
||||
|
|
@ -290,6 +293,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
return new ProductModelInfoVO()
|
||||
.setId(productModel.getId())
|
||||
.setModuleId(productModel.getModuleId())
|
||||
.setSeriesNumber(productModel.getSeriesNumber())
|
||||
.setTypeNumber(productModel.getTypeNumber())
|
||||
.setRecommend(productModel.getRecommend())
|
||||
.setSort(productModel.getSort())
|
||||
|
|
@ -300,6 +304,7 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
.setMerits(Objects.isNull(intro)?"":intro.getMerits())
|
||||
.setHotImage(productModelHotimageService.getListByLanguage(modelId))
|
||||
.setParams(productPartParamsService.getAListByLanguage(modelId, language))
|
||||
.setMainParams(productPartParamsService.getMainListByLanguage(modelId, language))
|
||||
.setImages(productModelImageService.getListByLanguage(modelId, language))
|
||||
.setVideos(productModelVideoService.getListByLanguage(modelId, language))
|
||||
.setFiles(productModelFileService.getListByLanguage(modelId, language));
|
||||
|
|
@ -389,8 +394,8 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModelSimpleVO> getSimpleList(Integer moduleId, String typeNumber) {
|
||||
return baseMapper.getSimpleList(moduleId,typeNumber);
|
||||
public List<ProductModelSimpleVO> getSimpleList(String typeNumber) {
|
||||
return baseMapper.getSimpleList(typeNumber);
|
||||
}
|
||||
|
||||
private ProductModelCompareInfoVO getModelCompareInfo(Integer modelId, String language){
|
||||
|
|
|
|||
|
|
@ -203,6 +203,11 @@ public class ProductSeriesServiceImpl extends ServiceImpl<ProductSeriesMapper, P
|
|||
return baseMapper.getSimpleList(moduleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSeriesSimpleVO> getSimpleList(Integer moduleId, String language) {
|
||||
return baseMapper.getSimpleListByLanguage(moduleId,language);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSeriesInfoVO getInfo(Integer seriesId) {
|
||||
ProductSeries series = getById(seriesId);
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
|
|||
.orElse(null);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(cn)).throwMessage("必须包含中文数据");
|
||||
info.setName(cn.getName().trim());
|
||||
info.setModuleId(request.getModuleId());
|
||||
info.setSeriesNumber(request.getSeriesNumber());
|
||||
// info.setSort(request.getSort());
|
||||
info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
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) {
|
||||
List<ProductTypeVO> vos = baseMapper.get(moduleId, seriesNumber, language);
|
||||
vos.forEach(vo -> {
|
||||
vo.setModels(productModelService.getSimpleList(moduleId,vo.getTypeNumber()));
|
||||
vo.setModels(productModelService.getSimpleList(vo.getTypeNumber()));
|
||||
});
|
||||
return vos;
|
||||
}
|
||||
|
|
@ -297,7 +299,7 @@ public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeMapper, Produ
|
|||
public Page<FrontendProductTypeSearchVO> search(ProductSeriesSearchRequest request, String language) {
|
||||
Page<FrontendProductTypeSearchVO> datas = baseMapper.search(request.getName(), language, new Page<>(request.getPage(), request.getPageSize()));
|
||||
datas.getRecords().forEach(it -> {
|
||||
it.setModels(productModelService.getSimpleList(it.getModuleId(), it.getBatchNumber()));
|
||||
it.setModels(productModelService.getSimpleList(it.getBatchNumber()));
|
||||
});
|
||||
return datas;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
</select>
|
||||
|
||||
<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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@
|
|||
</select>
|
||||
|
||||
<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
|
||||
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
|
||||
|
|
@ -78,7 +79,7 @@
|
|||
<select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO">
|
||||
SELECT *
|
||||
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
|
||||
LIMIT 8
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
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.compare = 1
|
||||
AND pmpi.language_code = #{language}
|
||||
ORDER BY pmp.id DESC
|
||||
</select>
|
||||
|
|
@ -30,4 +29,16 @@
|
|||
FROM product_model_params_item
|
||||
WHERE model_params_id=#{oldId}
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
</select>
|
||||
|
||||
<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
|
||||
INNER JOIN product_series_info psi ON ps.id = psi.series_id
|
||||
WHERE ps.state = 1
|
||||
|
|
@ -64,6 +64,14 @@
|
|||
<select id="getSimpleList" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductSeriesSimpleVO">
|
||||
select distinct batch_number,name
|
||||
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>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
</select>
|
||||
|
||||
<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
|
||||
INNER JOIN product_type_info pti ON pt.id = pti.type_id
|
||||
WHERE pt.state = 1
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@
|
|||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.nflg.mobilebroken.admin.config;
|
||||
package com.nflg.mobilebroken.starter.config;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
Loading…
Reference in New Issue