Kaynağa Gözat

feat:产品要素导入优化

chenjianhua 1 hafta önce
ebeveyn
işleme
2b1bb0ed91

+ 4 - 2
service-base/src/main/java/com/simuwang/base/mapper/daq/ProductInformationMapper.java

@@ -14,9 +14,11 @@ public interface ProductInformationMapper extends BaseMapper<ProductInformationD
 
     long countProductList(ProductPageQuery productPageQuery);
 
-    ProductInformationDO selectByNameAndRegisterNumber(@Param("registerNumber") String registerNumber,@Param("productName")String productName);
-
     List<ProductInformationDO> selectAllRecord();
 
     List<ProductInformationDO> selectByIdList(@Param("idList") List<Integer> idList);
+
+    ProductInformationDO selectByRegisterNumber(@Param("registerNumber")String registerNumber);
+
+    ProductInformationDO selectByProductName(@Param("productName")String productName);
 }

+ 18 - 18
service-base/src/main/resources/mapper/daq/ProductInformationMapper.xml

@@ -85,24 +85,6 @@
       and report_frequency like concat('%',#{reportFrequency},'%')
     </if>
   </select>
-  <select id="selectByNameAndRegisterNumber" resultMap="BaseResultMap">
-    select <include refid="Base_Column_List"></include>
-    from product_information where isvalid=1
-    <if test="registerNumber != '' and registerNumber != null">
-      and register_number=#{registerNumber}
-    </if>
-    <if test="productName != '' and productName != null">
-      and product_name=#{productName}
-    </if>
-    <if test="productName == null">
-      and product_name is null
-    </if>
-    <if test="registerNumber == null">
-      and register_number is null
-    </if>
-    order by createtime
-    limit 1
-  </select>
   <select id="selectAllRecord" resultMap="BaseResultMap">
     select <include refid="Base_Column_List"></include>
     from product_information where isvalid=1
@@ -114,4 +96,22 @@
       #{id}
     </foreach>
   </select>
+  <select id="selectByRegisterNumber"  resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"></include>
+    from product_information where isvalid=1
+    <if test="registerNumber != '' and registerNumber != null">
+      and register_number=#{registerNumber}
+    </if>
+    order by createtime
+    limit 1
+  </select>
+  <select id="selectByProductName"  resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"></include>
+    from product_information where isvalid=1
+    <if test="productName != '' and productName != null">
+      and product_name=#{productName}
+    </if>
+    order by createtime
+    limit 1
+  </select>
 </mapper>

+ 18 - 3
service-manage/src/main/java/com/simuwang/manage/service/impl/ProductServiceImpl.java

@@ -234,7 +234,12 @@ public class ProductServiceImpl implements ProductService {
                 continue;
             }
             ProductDerivativeDO productDerivativeDO = toProductDerivativeDO(productDerivativeData);
-            ProductInformationDO productInformationDO = productInformationMapper.selectByNameAndRegisterNumber(productDerivativeDO.getRegisterNumber(),productDerivativeDO.getProductName());
+            ProductInformationDO productInformationDO = null;
+            if(!StringUtil.isEmpty(productDerivativeDO.getProductName())){
+                productInformationDO = productInformationMapper.selectByRegisterNumber(productDerivativeDO.getRegisterNumber());
+            }else{
+                productInformationDO = productInformationMapper.selectByProductName(productDerivativeDO.getProductName());
+            }
             if(productInformationDO != null){
                 productDerivativeDO.setProductId(productInformationDO.getId());
             }else{
@@ -292,7 +297,12 @@ public class ProductServiceImpl implements ProductService {
                 continue;
             }
             ProductContractDO productContractDO = toProductContractDO(productContractData);
-            ProductInformationDO productInformationDO = productInformationMapper.selectByNameAndRegisterNumber(productContractData.getRegisterNumber(),productContractData.getProductName());
+            ProductInformationDO productInformationDO = null;
+            if(!StringUtil.isEmpty(productContractDO.getProductName())){
+                productInformationDO = productInformationMapper.selectByRegisterNumber(productContractDO.getRegisterNumber());
+            }else{
+                productInformationDO = productInformationMapper.selectByProductName(productContractDO.getProductName());
+            }
             if(productInformationDO != null){
                 productContractDO.setProductId(productInformationDO.getId());
             }else{
@@ -363,7 +373,12 @@ public class ProductServiceImpl implements ProductService {
                 continue;
             }
             ProductInformationDO productInformationDO = toProductDO(productInformationData);
-            ProductInformationDO oldProductInformationDO = productInformationMapper.selectByNameAndRegisterNumber(productInformationDO.getRegisterNumber(),productInformationDO.getProductName());
+            ProductInformationDO oldProductInformationDO = null;
+            if(!StringUtil.isEmpty(productInformationDO.getProductName())){
+                oldProductInformationDO = productInformationMapper.selectByRegisterNumber(productInformationDO.getRegisterNumber());
+            }else{
+                oldProductInformationDO = productInformationMapper.selectByProductName(productInformationDO.getProductName());
+            }
             if(oldProductInformationDO != null){
                 productInformationDO.setId(oldProductInformationDO.getId());
             }else{