chendayu 2 роки тому
батько
коміт
378deca894

+ 2 - 1
PAS/src/main/java/cn/cslg/pas/mapper/ProductCategoryMapper.java

@@ -55,9 +55,10 @@ public interface ProductCategoryMapper {
      *
      * @param id                  id
      * @param productCategoryName 名称
+     * @param tenantId            租户id
      * @return 返回统计到的数量
      */
-    int countByIdAndName(Integer id, String productCategoryName);
+    int countByIdAndName(Integer id, String productCategoryName, Integer tenantId);
 
     /**
      * 根据id统计数量

+ 5 - 2
PAS/src/main/java/cn/cslg/pas/service/impl/ProductCategoryServiceImpl.java

@@ -141,6 +141,9 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
     public void update(ProductCategoryUpdateDTO productCategoryUpdateDTO, List<MultipartFile> files) {
         log.info("开始处理【修改产品类别】的业务,参数为:{}, {}", productCategoryUpdateDTO, files);
 
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        Integer tenantId = personnelVO.getTenantId();
+
         //检查尝试修改的数据是否存在
         Integer productCategoryId = productCategoryUpdateDTO.getId();
         String productCategoryName = productCategoryUpdateDTO.getProductCategoryName();
@@ -154,7 +157,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
 
         //检查尝试修改的产品类别名称是否被占用
         log.info("检查尝试修改的产品类别名称是否被占用");
-        count = productCategoryMapper.countByIdAndName(productCategoryId, productCategoryName);
+        count = productCategoryMapper.countByIdAndName(productCategoryId, productCategoryName, tenantId);
         if (count > 0) {
             String message = "修改产品类别失败,类别名称【" + productCategoryName + "】已存在,请尝试更换名称";
             log.info("{}", message);
@@ -307,7 +310,7 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
 
     @Override
     public List<String> getAreaList(GetAreaListDTO dto) {
-        PersonnelVO personnelVO =cacheUtils.getLoginUser(loginUtils.getId());
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         dto.setTenantId(personnelVO.getTenantId());
         List<String> areaList = productCategoryMapper.getAreaList(dto);
         return areaList;

+ 22 - 15
PAS/src/main/java/cn/cslg/pas/service/impl/StructureServiceImpl.java

@@ -302,22 +302,29 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
             wrapper.like(Structure::getStructureName, structureName);
         }
         List<Structure> structures = this.list(wrapper);
-        List<Integer> ids = structures.stream().map(Structure::getId).collect(Collectors.toList());
-        List<String> paths = structures.stream().map(Structure::getPath).collect(Collectors.toList());
-        paths.forEach(
-                item -> {
-                    String[] pathStrs = item.split(",");
-                    List<String> pathStr = new ArrayList<>(Arrays.asList(pathStrs));
-                    pathStr.forEach(
-                            tem -> {
-                                Integer paId = Integer.parseInt(tem);
-                                if (!ids.contains(paId)) {
-                                    ids.add(paId);
+        List<Integer> ids;
+        if (structures != null && structures.size() > 0) {
+            ids = structures.stream().map(Structure::getId).collect(Collectors.toList());
+            List<String> paths = structures.stream().map(Structure::getPath).collect(Collectors.toList());
+            paths.forEach(
+                    item -> {
+                        String[] pathStrs = item.split(",");
+                        List<String> pathStr = new ArrayList<>(Arrays.asList(pathStrs));
+                        pathStr.forEach(
+                                tem -> {
+                                    Integer paId = Integer.parseInt(tem);
+                                    if (!ids.contains(paId)) {
+                                        ids.add(paId);
+                                    }
                                 }
-                            }
-                    );
-                }
-        );
+                        );
+                    }
+            );
+        } else {
+            ids = new ArrayList<>();
+            ids.add(-1);
+        }
+
         diGui(structureVO, map, structureId, productId, ids);
         return structureVO;
     }

+ 26 - 25
PAS/src/main/resources/mapper/ProductCategoryMapper.xml

@@ -47,11 +47,12 @@
     </select>
 
     <!--根据id和名称统计数量-->
-    <!--int countByIdAndName(Integer id, String productCategoryName);-->
+    <!--int countByIdAndName(Integer id, String productCategoryName, Integer tenantId);-->
     <select id="countByIdAndName" resultType="int">
         select count(*)
         from product_category
         where product_category_name = #{productCategoryName}
+          and tenant_id = #{tenantId}
           and id != #{id}
     </select>
 
@@ -245,31 +246,31 @@
 
     <select id="getAreaList" resultMap="getAreaListMap">
         SELECT DISTINCT sale_area
-        FROM product_market_data a left join  product b on a.product_id =b.id
+        FROM product_market_data a left join product b on a.product_id =b.id
         <where>
-        <if test="productId != null and productId != ''">
-            a.product_id = #{productId} and b.tenant_id=#{tenantId}
-        </if>
-        <if test="categoryId !=null and categoryId != ''">
-            product_id
-            IN(
-            SELECT id
-            FROM product
-            WHERE
-            product_category_id = #{categoryId})
-            and tenant_id=#{tenantId}
-        </if>
-        <if test="patentNoList != null and patentNoList.size() > 0 ">
-            product_id IN(
-            SELECT product_id
-            FROM asso_product_patent c  left join  product d on c.product_id =d.id
-            WHERE c.patent_no IN
-            <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
-                #{patentNo}
-            </foreach>
-            and d.tenant_id=#{tenantId}
-            )
-        </if>
+            <if test="productId != null and productId != ''">
+                a.product_id = #{productId} and b.tenant_id=#{tenantId}
+            </if>
+            <if test="categoryId !=null and categoryId != ''">
+                product_id
+                IN(
+                SELECT id
+                FROM product
+                WHERE
+                product_category_id = #{categoryId})
+                and tenant_id=#{tenantId}
+            </if>
+            <if test="patentNoList != null and patentNoList.size() > 0 ">
+                product_id IN(
+                SELECT product_id
+                FROM asso_product_patent c left join product d on c.product_id =d.id
+                WHERE c.patent_no IN
+                <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
+                    #{patentNo}
+                </foreach>
+                and d.tenant_id=#{tenantId}
+                )
+            </if>
         </where>
     </select>
 </mapper>