Commit f22b52e0095b28c63cda08427f7ad75e1dd3b653
Merge branch 'master' of http://39.108.227.113:8001/xiemaosheng2/canrd-services
Showing
7 changed files
with
71 additions
and
15 deletions
shop/src/main/java/com/canrd/shop/controller/ProductController.java
@@ -12,10 +12,7 @@ import com.canrd.shop.module.dto.ImportProductRelatedJournal; | @@ -12,10 +12,7 @@ import com.canrd.shop.module.dto.ImportProductRelatedJournal; | ||
12 | import com.canrd.shop.module.dto.ProductCategoryDO; | 12 | import com.canrd.shop.module.dto.ProductCategoryDO; |
13 | import com.canrd.shop.module.dto.ProductDO; | 13 | import com.canrd.shop.module.dto.ProductDO; |
14 | import com.canrd.shop.module.dto.ProductFunctionDO; | 14 | import com.canrd.shop.module.dto.ProductFunctionDO; |
15 | -import com.canrd.shop.module.vo.ImportRelatedCategoryVo; | ||
16 | -import com.canrd.shop.module.vo.ProductCategoryQueryVO; | ||
17 | -import com.canrd.shop.module.vo.ProductQueryVO; | ||
18 | -import com.canrd.shop.module.vo.ProductVO; | 15 | +import com.canrd.shop.module.vo.*; |
19 | import com.canrd.shop.service.*; | 16 | import com.canrd.shop.service.*; |
20 | import freemarker.template.Configuration; | 17 | import freemarker.template.Configuration; |
21 | import freemarker.template.Template; | 18 | import freemarker.template.Template; |
@@ -32,6 +29,8 @@ import org.springframework.web.multipart.MultipartFile; | @@ -32,6 +29,8 @@ import org.springframework.web.multipart.MultipartFile; | ||
32 | import javax.annotation.Resource; | 29 | import javax.annotation.Resource; |
33 | import java.io.*; | 30 | import java.io.*; |
34 | import java.util.*; | 31 | import java.util.*; |
32 | +import java.util.stream.Collectors; | ||
33 | +import java.util.stream.Stream; | ||
35 | 34 | ||
36 | /** | 35 | /** |
37 | * (Product)表控制层 | 36 | * (Product)表控制层 |
@@ -81,6 +80,54 @@ public class ProductController { | @@ -81,6 +80,54 @@ public class ProductController { | ||
81 | return productCategoryService.category(productCategoryQueryVO); | 80 | return productCategoryService.category(productCategoryQueryVO); |
82 | } | 81 | } |
83 | 82 | ||
83 | + @GetMapping("/generateAllUrl") | ||
84 | + public ServerResult generateAllUrl(){ | ||
85 | + ProductCategoryQueryVO productCategoryQueryVO = new ProductCategoryQueryVO(); | ||
86 | + ServerResult<ProductCategoryResultVO> category = productCategoryService.category(productCategoryQueryVO); | ||
87 | + ProductCategoryResultVO data = category.getData(); | ||
88 | + List<ProductCategoryDisplayVO> rootCategoryList = data.getRootCategoryList(); | ||
89 | + | ||
90 | + Map<String, ProductCategoryDisplayVO> name2ProductCategoryDisplayVOMap = rootCategoryList.stream() | ||
91 | + .collect(Collectors.toMap(ProductCategoryDisplayVO::getCategoryDisplayName, v -> v)); | ||
92 | + | ||
93 | + List<ProductQueryVO> queries = name2ProductCategoryDisplayVOMap.entrySet().stream() | ||
94 | + .flatMap(entry -> { | ||
95 | + String rootCategoryName = entry.getKey(); | ||
96 | + ProductCategoryDisplayVO categoryDisplay = entry.getValue(); | ||
97 | + List<String> cateNames = categoryDisplay.getList().stream().map(ProductCategoryVO::getName).collect(Collectors.toList()); | ||
98 | + List<String> funNames = Optional.ofNullable(categoryDisplay.getProductFunctions()).orElse(new ArrayList<ProductFunctionVO>()) | ||
99 | + .stream().map(ProductFunctionVO::getName).collect(Collectors.toList()); | ||
100 | + | ||
101 | + return cateNames.stream().flatMap(cateName -> { | ||
102 | + if (CollUtil.isEmpty(funNames)) { | ||
103 | + return Stream.of(ProductQueryVO.builder() | ||
104 | + .rootProductCategoryName(rootCategoryName) | ||
105 | + .productCategoryName(cateName) | ||
106 | + .pageNo(1) | ||
107 | + .pageSize(20) | ||
108 | + .build()); | ||
109 | + } else { | ||
110 | + return funNames.stream().map(funName -> ProductQueryVO.builder() | ||
111 | + .rootProductCategoryName(rootCategoryName) | ||
112 | + .productCategoryName(cateName) | ||
113 | + .productFunctionName(funName) | ||
114 | + .pageNo(1) | ||
115 | + .pageSize(20) | ||
116 | + .build()); | ||
117 | + } | ||
118 | + }); | ||
119 | + }) | ||
120 | + .collect(Collectors.toList()); | ||
121 | + queries.forEach(query -> { | ||
122 | + try { | ||
123 | + generateList(query,"canrd@2024"); | ||
124 | + } catch (IOException | TemplateException e) { | ||
125 | + throw new RuntimeException(e); | ||
126 | + } | ||
127 | + }); | ||
128 | + return ServerResult.success(); | ||
129 | + } | ||
130 | + | ||
84 | @GetMapping("/categorySearch") | 131 | @GetMapping("/categorySearch") |
85 | public ServerResult categorySearch(ProductQueryVO productQueryVO){ | 132 | public ServerResult categorySearch(ProductQueryVO productQueryVO){ |
86 | return productService.categorySearch(productQueryVO); | 133 | return productService.categorySearch(productQueryVO); |
@@ -126,13 +173,12 @@ public class ProductController { | @@ -126,13 +173,12 @@ public class ProductController { | ||
126 | } | 173 | } |
127 | } | 174 | } |
128 | if(StringUtils.isNotBlank(productQueryVO.getRootProductCategoryName())){ | 175 | if(StringUtils.isNotBlank(productQueryVO.getRootProductCategoryName())){ |
129 | - Optional<ProductCategoryDO> productCategoryDOOpt = productCategoryService.lambdaQuery() | 176 | + List<ProductCategoryDO> list = productCategoryService.lambdaQuery() |
130 | .eq(ProductCategoryDO::getName, productQueryVO.getRootProductCategoryName()) | 177 | .eq(ProductCategoryDO::getName, productQueryVO.getRootProductCategoryName()) |
131 | - .oneOpt(); | 178 | + .list(); |
179 | + List<String> collect = list.stream().map(ProductCategoryDO::getId).collect(Collectors.toList()); | ||
132 | productQueryVO | 180 | productQueryVO |
133 | - .setRootProductCategoryId(productCategoryDOOpt | ||
134 | - .orElseThrow(()-> new BusinessException("productCategoryName not exist")) | ||
135 | - .getId()); | 181 | + .setRootProductCategoryIdIn(collect); |
136 | } | 182 | } |
137 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionName())){ | 183 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionName())){ |
138 | Optional<ProductFunctionDO> productFunctionDO = productFunctionService.lambdaQuery() | 184 | Optional<ProductFunctionDO> productFunctionDO = productFunctionService.lambdaQuery() |
@@ -145,7 +191,7 @@ public class ProductController { | @@ -145,7 +191,7 @@ public class ProductController { | ||
145 | String path = staticHtmlConfig.getUrl(); | 191 | String path = staticHtmlConfig.getUrl(); |
146 | String fileName = (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryName())?productQueryVO.getRootProductCategoryName():"-") | 192 | String fileName = (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryName())?productQueryVO.getRootProductCategoryName():"-") |
147 | +"_" | 193 | +"_" |
148 | - +(StringUtils.isNotBlank(productQueryVO.getProductCategoryName())?productQueryVO.getProductCategoryName():"-") | 194 | + +(StringUtils.isNotBlank(productQueryVO.getProductCategoryName())?productQueryVO.getProductCategoryName().replace('/','-'):"-") |
149 | +"_" | 195 | +"_" |
150 | +(StringUtils.isNotBlank(productQueryVO.getProductFunctionName())?productQueryVO.getProductFunctionName():"-") | 196 | +(StringUtils.isNotBlank(productQueryVO.getProductFunctionName())?productQueryVO.getProductFunctionName():"-") |
151 | +"_" | 197 | +"_" |
shop/src/main/java/com/canrd/shop/module/vo/ProductQueryVO.java
@@ -36,6 +36,11 @@ public class ProductQueryVO extends BasePageVO implements Serializable { | @@ -36,6 +36,11 @@ public class ProductQueryVO extends BasePageVO implements Serializable { | ||
36 | private String rootProductCategoryId; | 36 | private String rootProductCategoryId; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | + * 顶级产品分类 | ||
40 | + */ | ||
41 | + private List<String> rootProductCategoryIdIn; | ||
42 | + | ||
43 | + /** | ||
39 | * 产品分类id | 44 | * 产品分类id |
40 | */ | 45 | */ |
41 | private String productCategoryId; | 46 | private String productCategoryId; |
shop/src/main/java/com/canrd/shop/service/ProductCategoryService.java
@@ -5,6 +5,7 @@ import com.canrd.shop.common.constant.ServerResult; | @@ -5,6 +5,7 @@ import com.canrd.shop.common.constant.ServerResult; | ||
5 | import com.canrd.shop.module.dto.ProductCategoryDO; | 5 | import com.canrd.shop.module.dto.ProductCategoryDO; |
6 | import com.canrd.shop.module.dto.ProductDO; | 6 | import com.canrd.shop.module.dto.ProductDO; |
7 | import com.canrd.shop.module.vo.ProductCategoryQueryVO; | 7 | import com.canrd.shop.module.vo.ProductCategoryQueryVO; |
8 | +import com.canrd.shop.module.vo.ProductCategoryResultVO; | ||
8 | import com.canrd.shop.module.vo.ProductQueryVO; | 9 | import com.canrd.shop.module.vo.ProductQueryVO; |
9 | 10 | ||
10 | /** | 11 | /** |
@@ -18,6 +19,6 @@ public interface ProductCategoryService extends IService<ProductCategoryDO> { | @@ -18,6 +19,6 @@ public interface ProductCategoryService extends IService<ProductCategoryDO> { | ||
18 | * @param productCategoryQueryVO | 19 | * @param productCategoryQueryVO |
19 | * @return | 20 | * @return |
20 | */ | 21 | */ |
21 | - ServerResult category(ProductCategoryQueryVO productCategoryQueryVO); | 22 | + ServerResult<ProductCategoryResultVO> category(ProductCategoryQueryVO productCategoryQueryVO); |
22 | 23 | ||
23 | } | 24 | } |
shop/src/main/java/com/canrd/shop/service/impl/ProductCagegoryServiceImpl.java
@@ -40,7 +40,7 @@ public class ProductCagegoryServiceImpl extends ServiceImpl<ProductCategoryMappe | @@ -40,7 +40,7 @@ public class ProductCagegoryServiceImpl extends ServiceImpl<ProductCategoryMappe | ||
40 | private ProductFunctionService productFunctionService; | 40 | private ProductFunctionService productFunctionService; |
41 | 41 | ||
42 | @Override | 42 | @Override |
43 | - public ServerResult category(ProductCategoryQueryVO productCategoryQueryVO) { | 43 | + public ServerResult<ProductCategoryResultVO> category(ProductCategoryQueryVO productCategoryQueryVO) { |
44 | List<ProductCategoryDO> productCategoryDOList = this.list(); | 44 | List<ProductCategoryDO> productCategoryDOList = this.list(); |
45 | List<ProductCategoryVO> energyMaterialCategoryList = Lists.newArrayList(); | 45 | List<ProductCategoryVO> energyMaterialCategoryList = Lists.newArrayList(); |
46 | List<ProductCategoryVO> laboratoryConsumables = Lists.newArrayList(); | 46 | List<ProductCategoryVO> laboratoryConsumables = Lists.newArrayList(); |
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
@@ -283,6 +283,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | @@ -283,6 +283,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | ||
283 | queryWapper.eq("pc.id",productQueryVO.getProductCategoryId()); | 283 | queryWapper.eq("pc.id",productQueryVO.getProductCategoryId()); |
284 | }else if (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryId())){ | 284 | }else if (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryId())){ |
285 | queryWapper.eq("pc.id",productQueryVO.getRootProductCategoryId()); | 285 | queryWapper.eq("pc.id",productQueryVO.getRootProductCategoryId()); |
286 | + queryWapper.in(CollUtil.isNotEmpty(productQueryVO.getRootProductCategoryIdIn()),"pc.id",productQueryVO.getRootProductCategoryIdIn()); | ||
286 | } | 287 | } |
287 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionId())){ | 288 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionId())){ |
288 | queryWapper.eq("pf.id",productQueryVO.getProductFunctionId()); | 289 | queryWapper.eq("pf.id",productQueryVO.getProductFunctionId()); |
@@ -390,6 +391,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | @@ -390,6 +391,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | ||
390 | queryWapper.eq("pc.id",productQueryVO.getProductCategoryId()); | 391 | queryWapper.eq("pc.id",productQueryVO.getProductCategoryId()); |
391 | }else if (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryId())){ | 392 | }else if (StringUtils.isNotBlank(productQueryVO.getRootProductCategoryId())){ |
392 | queryWapper.eq("pc.id",productQueryVO.getRootProductCategoryId()); | 393 | queryWapper.eq("pc.id",productQueryVO.getRootProductCategoryId()); |
394 | + queryWapper.in(CollUtil.isNotEmpty(productQueryVO.getRootProductCategoryIdIn()),"pc.id",productQueryVO.getRootProductCategoryIdIn()); | ||
395 | + | ||
393 | } | 396 | } |
394 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionId())){ | 397 | if(StringUtils.isNotBlank(productQueryVO.getProductFunctionId())){ |
395 | queryWapper.eq("pf.id",productQueryVO.getProductFunctionId()); | 398 | queryWapper.eq("pf.id",productQueryVO.getProductFunctionId()); |
shop/src/main/resources/log4j2-dev.xml
@@ -20,7 +20,8 @@ | @@ -20,7 +20,8 @@ | ||
20 | <console name="Console" target="SYSTEM_OUT"> | 20 | <console name="Console" target="SYSTEM_OUT"> |
21 | <!--输出日志的格式 --> | 21 | <!--输出日志的格式 --> |
22 | <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> | 22 | <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> |
23 | - <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" /> | 23 | + <!-- 只接受ERROR级别及其以上的日志 --> |
24 | + <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY" /> | ||
24 | </console> | 25 | </console> |
25 | <!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 --> | 26 | <!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 --> |
26 | <RollingFile name="RollingFileInfo" fileName="${sys:logging.path}/logs/overtime.log" filePattern="${sys:logging.path}/logs/$${date:yyyy-MM-dd}/info-%d{yyyy-MM-dd}-%i.log"> | 27 | <RollingFile name="RollingFileInfo" fileName="${sys:logging.path}/logs/overtime.log" filePattern="${sys:logging.path}/logs/$${date:yyyy-MM-dd}/info-%d{yyyy-MM-dd}-%i.log"> |
@@ -54,7 +55,7 @@ | @@ -54,7 +55,7 @@ | ||
54 | <logger name="com.canrd.shop" level="debug" additivity="false"> | 55 | <logger name="com.canrd.shop" level="debug" additivity="false"> |
55 | <appender-ref ref="RollingFileInfo" /> | 56 | <appender-ref ref="RollingFileInfo" /> |
56 | </logger> | 57 | </logger> |
57 | - <root level="debug"> | 58 | + <root level="error"> |
58 | <appender-ref ref="Console" /> | 59 | <appender-ref ref="Console" /> |
59 | </root> | 60 | </root> |
60 | </loggers> | 61 | </loggers> |
shop/src/main/resources/templates/canrud.ftl
@@ -27202,7 +27202,7 @@ | @@ -27202,7 +27202,7 @@ | ||
27202 | </div> | 27202 | </div> |
27203 | <div data-v-f467c4e7="" class="v-card-text tw-text-left font-weight-medium title"> | 27203 | <div data-v-f467c4e7="" class="v-card-text tw-text-left font-weight-medium title"> |
27204 | <!--商品--> | 27204 | <!--商品--> |
27205 | - <h3 data-v-f6bc2735="" style="color: red;"> ${item.price}</h3> | 27205 | + <h3 data-v-f6bc2735="" style="color: red;"> ${item.price!""}</h3> |
27206 | <h4 data-v-f467c4e7="">${item.name}</h4> | 27206 | <h4 data-v-f467c4e7="">${item.name}</h4> |
27207 | </div> | 27207 | </div> |
27208 | <!----><span class="v-card__overlay"></span><span | 27208 | <!----><span class="v-card__overlay"></span><span |