chendayu hace 2 años
padre
commit
b83e4281ac

+ 8 - 5
PAS/src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -85,19 +85,22 @@ public class ProductCategoryController {
         }
         return Response.success("删除产品类别完成");
     }
+
     @Operation(summary = "查询产品架构趋势图")
     @PostMapping("/showTrend")
-    public String showTrend(@RequestBody  ProductCategoryDTO dto) {
-        return Response.success( productCategoryService.showTrend(dto));
+    public String showTrend(@RequestBody ProductCategoryDTO dto) {
+        return Response.success(productCategoryService.showTrend(dto));
     }
+
     @Operation(summary = "获得架构的地区集合")
     @GetMapping("/getAreaList")
-    public String getAreaList(Integer id) {
-        return Response.success( productCategoryService.getAreaList(id));
+    public String getAreaList(Integer id, Integer productId) {
+        return Response.success(productCategoryService.getAreaList(id, productId));
     }
+
     @Operation(summary = "获得架构的公司集合")
     @GetMapping("/getCompanyList")
     public String getCompanyList(Integer id) {
-        return Response.success( productCategoryService.getCompanyList(id));
+        return Response.success(productCategoryService.getCompanyList(id));
     }
 }

+ 7 - 1
PAS/src/main/java/cn/cslg/pas/mapper/asso/AssoProductPatentMapper.java

@@ -30,6 +30,12 @@ public interface AssoProductPatentMapper extends BaseMapper<AssoProductPatent> {
 
     List<String> getPatentNos(@Param("params") ProductPatentDTO params);
 
-
+    /**
+     * 插入数据
+     *
+     * @param assoProductPatent 数据对象
+     * @return 返回受影响的行数
+     */
+    int insert(AssoProductPatent assoProductPatent);
 
 }

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/service/IProductCategoryService.java

@@ -59,7 +59,7 @@ public interface IProductCategoryService {
     @Transactional
     List<ProductCategoryTrendVO> showTrend(ProductCategoryDTO dto);
 
-    List<String>  getAreaList(Integer id);
+    List<String> getAreaList(Integer id,Integer productId);
 
     List<String> getCompanyList(Integer id);
 }

+ 20 - 12
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -321,23 +321,31 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     }
 
     @Override
-    public List<String> getAreaList(Integer id) {
+    public List<String> getAreaList(Integer id,Integer productId) {
         //存储所有产品的营销数据
         List<ProductMarketData> marketData = new ArrayList<>();
         List<String> areaList = new ArrayList<>();
-        //根据架构id获得产品
-        LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
-        productWrapper.eq(Product::getProductCategoryId, id);
-        List<Product> products = productService.list(productWrapper);
-        if (products.size() != 0) {
-            List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList());
-            if (productIds.size() > 0) {
-                //根据产品Id获得产品营销数据
-                LambdaQueryWrapper<ProductMarketData> market = new LambdaQueryWrapper<>();
-                market.in(ProductMarketData::getProductId, productIds);
-                marketData = productMarketDataIService.list(market);
+        List<Integer> productIds = new ArrayList<>();
+        if(productId==null) {
+            //根据架构id获得产品
+            LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
+            productWrapper.eq(Product::getProductCategoryId, id);
+            List<Product> products = productService.list(productWrapper);
+
+            if (products.size() != 0) {
+                productIds = products.stream().map(Product::getId).collect(Collectors.toList());
             }
         }
+        else {
+            productIds=Arrays.asList(productId);
+        }
+        if (productIds.size() > 0) {
+            //根据产品Id获得产品营销数据
+            LambdaQueryWrapper<ProductMarketData> market = new LambdaQueryWrapper<>();
+            market.in(ProductMarketData::getProductId, productIds);
+            marketData = productMarketDataIService.list(market);
+        }
+
         marketData.forEach(
                 item -> {
                     if (!areaList.contains(item.getSaleArea())) {

+ 58 - 50
PAS/src/main/resources/mapper/AssoProductPatentMapper.xml

@@ -26,7 +26,7 @@
         a.patsnap_family as patSnapFamily, a.patsnapfamilynum as patSnapFamilyNum
         from os_patent a
         left join asso_product_patent i on i.patent_no=a.patentno
-            left join asso_structure_patent t on t.patent_no =a.patentno
+        left join asso_structure_patent t on t.patent_no =a.patentno
         <if test="params.applicationName !=null ">
             left join os_applicant_attr b on a.id=b.pid and b.type =1
             left join os_patent_applicant c on c.id=b.applicantid
@@ -45,51 +45,51 @@
             left join os_patent_typeno h on h.pid =a.id and h.type =3
         </if>
         <where>
-          ( i.product_id =#{params.productId}
+            ( i.product_id =#{params.productId}
             or t.product_id =#{params.productId} )
-                    <if test="params.applicationName !=null and params.applicationName !=''  ">
-                        and c.name  REGEXP #{params.applicationName}
-                    </if>
-                    <if test="params.obligeeName !=null and params.obligeeName!=''">
-                        and e.name  REGEXP #{params.obligeeName}
-                    </if>
-                    <if test="params.numberIpc !=null and params.numberIpc!=''">
-                        and f.code like concat("%", #{params.numberIpc}, "%")
-                    </if>
-                    <if test="params.numberCpc !=null and params.numberCpc!=''">
-                        and g.code like concat("%", #{params.numberCpc}, "%")
-                    </if>
-                    <if test="params.numberUpc !=null and params.numberUpc!=''">
-                        and h.code like concat("%", #{params.numberUpc}, "%")
-                    </if>
-                    <if test="params.patentNo !=null and params.patentNo !=''">
-                        and a.patentNo REGEXP  #{params.patentNo}
-                    </if>
-                    <if test="params.applicationNo !=null and params.applicationNo !=''">
-                        and a.applicationNo like concat("%", #{params.applicationNo}, "%")
-                    </if>
-                    <if test="params.abstractStr !=null and params.abstractStr !=''">
-                        and a.abstract like concat("%", #{params.abstractStr}, "%")
-                    </if>
-                    <if test="params.patentName !=null and params.patentName !=''">
-                        and a.`name` like concat("%", #{params.patentName}, "%")
-                    </if>
-                    <if test="params.orderItem!=null and params.orderItem!='SysOrder'">
-                        order by #{params.orderItem}
-                        <if test="params.orderType!=null">
-                            #{params.orderType}
-                        </if>
-                    </if>
-                    <if test="params.orderItem==null">
-                        order by a.patentno
-                    </if>
-                    <if test="params.orderItem=='SysOrder' and params.patentNos != null and params.patentNos.size()!=0">
-                        order by field (a.patentno,
-                        <foreach item="item" collection="params.patentNos" index="index" open="" separator=","
-                                 close=")">
-                            #{item}
-                        </foreach>
-                    </if>
+            <if test="params.applicationName !=null and params.applicationName !=''  ">
+                and c.name REGEXP #{params.applicationName}
+            </if>
+            <if test="params.obligeeName !=null and params.obligeeName!=''">
+                and e.name REGEXP #{params.obligeeName}
+            </if>
+            <if test="params.numberIpc !=null and params.numberIpc!=''">
+                and f.code like concat("%", #{params.numberIpc}, "%")
+            </if>
+            <if test="params.numberCpc !=null and params.numberCpc!=''">
+                and g.code like concat("%", #{params.numberCpc}, "%")
+            </if>
+            <if test="params.numberUpc !=null and params.numberUpc!=''">
+                and h.code like concat("%", #{params.numberUpc}, "%")
+            </if>
+            <if test="params.patentNo !=null and params.patentNo !=''">
+                and a.patentNo REGEXP #{params.patentNo}
+            </if>
+            <if test="params.applicationNo !=null and params.applicationNo !=''">
+                and a.applicationNo like concat("%", #{params.applicationNo}, "%")
+            </if>
+            <if test="params.abstractStr !=null and params.abstractStr !=''">
+                and a.abstract like concat("%", #{params.abstractStr}, "%")
+            </if>
+            <if test="params.patentName !=null and params.patentName !=''">
+                and a.`name` like concat("%", #{params.patentName}, "%")
+            </if>
+            <if test="params.orderItem!=null and params.orderItem!='SysOrder'">
+                order by #{params.orderItem}
+                <if test="params.orderType!=null">
+                    #{params.orderType}
+                </if>
+            </if>
+            <if test="params.orderItem==null">
+                order by a.patentno
+            </if>
+            <if test="params.orderItem=='SysOrder' and params.patentNos != null and params.patentNos.size()!=0">
+                order by field (a.patentno,
+                <foreach item="item" collection="params.patentNos" index="index" open="" separator=","
+                         close=")">
+                    #{item}
+                </foreach>
+            </if>
 
         </where>
     </select>
@@ -119,10 +119,10 @@
         <where>
 
             <if test="params.applicationName !=null and params.applicationName !=''  ">
-                and c.name  REGEXP #{params.applicationName}
+                and c.name REGEXP #{params.applicationName}
             </if>
             <if test="params.obligeeName !=null and params.obligeeName!=''">
-                and e.name  REGEXP #{params.obligeeName}
+                and e.name REGEXP #{params.obligeeName}
             </if>
             <if test="params.numberIpc !=null and params.numberIpc!=''">
                 and f.code like concat("%", #{params.numberIpc}, "%")
@@ -134,7 +134,7 @@
                 and h.code like concat("%", #{params.numberUpc}, "%")
             </if>
             <if test="params.patentNo !=null and params.patentNo !=''">
-                and a.patentNo REGEXP  #{params.patentNo}
+                and a.patentNo = #{params.patentNo}
             </if>
             <if test="params.applicationNo !=null and params.applicationNo !=''">
                 and a.applicationNo like concat("%", #{params.applicationNo}, "%")
@@ -146,11 +146,11 @@
                 and a.`name` like concat("%", #{params.patentName}, "%")
             </if>
             <if test="params.isIn ==0">
-             and   (i.product_id !=#{params.productId} or i.product_id is null)
+                and (i.product_id !=#{params.productId} or i.product_id is null)
                 and (t.product_id !=#{params.productId} or t.product_id is null)
             </if>
             <if test="params.isIn !=0">
-             and (i.product_id =#{params.productId} or t.product_id =#{params.productId})
+                and (i.product_id =#{params.productId} or t.product_id =#{params.productId})
             </if>
             <if test="params.orderItem!=null and params.orderItem!='SysOrder'">
                 order by #{params.orderItem}
@@ -175,4 +175,12 @@
 
     </select>
 
+    <!--插入数据-->
+    <!--int insert(AssoProductPatent assoProductPatent);-->
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id">
+        insert into asso_product_patent (patent_no, product_id)
+        values (#{patentNo}, #{productId});
+    </insert>
+
+
 </mapper>

+ 5 - 1
PAS/src/main/resources/mapper/ProductMapper.xml

@@ -111,7 +111,11 @@
                 and company_name like '%${companyName}%'
             </if>
             <if test="patentNo != null">
-                and id in (select product_id from asso_product_patent where patent_no like '%${patentNo}%')
+                and id in
+                (select app.product_id, asp.product_Id
+                from asso_product_patent app,
+                asso_structure_patent asp
+                where app.patent_no = #{patentNo} and asp.patent_no = #{patentNo})
             </if>
             <if test="productCategoryId != null">
                 and product_category_id = #{productCategoryId}

+ 40 - 0
PAS/src/test/java/cn/cslg/pas/service/ProductServiceImplTests.java

@@ -0,0 +1,40 @@
+package cn.cslg.pas.service;
+
+import cn.cslg.pas.common.JsonPage;
+import cn.cslg.pas.common.model.dto.ProductQueryPageDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+/**
+ * 产品的Service层接口实现类的测试类
+ *
+ * @Author chenyu
+ * @Date 2023/3/16
+ */
+@Slf4j
+@SpringBootTest
+public class ProductServiceImplTests {
+    @Autowired
+    private IProductService productService;
+
+    @Test
+    void query() {
+        ProductQueryPageDTO productQueryPageDTO = new ProductQueryPageDTO()
+                //.setProductName("手")
+                //.setCompanyName("世博")
+                //.setProductCategoryId(16)
+                .setPatentNo("CN202674151U");
+        JsonPage jsonPage = productService.query(productQueryPageDTO);
+        List<Object> list = jsonPage.getList();
+        log.info("根据专利号查询产品完成,数据信息为:");
+        for (Object o : list) {
+            log.info("{}", o);
+        }
+    }
+
+
+}