Forráskód Böngészése

merge from origin

maqingyang 11 hónapja
szülő
commit
cc9d1230ec

+ 28 - 5
src/main/java/com/kexun/controller/FieldDefineController.java

@@ -7,20 +7,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.kexun.common.utils.Result;
-import com.kexun.entity.BusInfoModifyHis;
-import com.kexun.entity.CooperatorInfo;
-import com.kexun.entity.FieldDefineEntity;
-import com.kexun.entity.FieldTemplateEntity;
+import com.kexun.entity.*;
 import com.kexun.hander.PageBean;
 import com.kexun.model.ro.FiledRO;
 import com.kexun.model.ro.FiledUpdateRO;
+import com.kexun.service.CooperatorProductFieldService;
 import com.kexun.service.CooperatorService;
 import com.kexun.service.FieldDefineService;
+import com.kexun.service.FieldTemplateRefService;
 import com.kexun.utils.PageUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
@@ -40,6 +40,14 @@ public class FieldDefineController {
 
     @Autowired
     private com.kexun.service.FieldDefineService fieldDefineService;
+
+    @Autowired
+    private FieldTemplateRefService fieldTemplateRefService;
+
+
+    @Autowired
+    private com.kexun.service.CooperatorProductFieldService CooperatorProductFieldService;
+
     /**
      * 字段信息读取
      *
@@ -199,7 +207,7 @@ public class FieldDefineController {
     }
 
     /**
-     * 基础字段删除
+     * 衍生字段删除,需要删除相关的模板-字段关联表,产品-字段关联表,根据fieldNo删除
      * @param id 主键ID
      * @return
      */
@@ -208,7 +216,22 @@ public class FieldDefineController {
         if (StringUtils.isEmpty(id)) {
             return Result.error("-1", "字段定义的ID不能为空");
         }
+
+        FieldDefineEntity fieldDefineEntity = fieldDefineService.findByID(id);
+        String fieldNo = fieldDefineEntity.getFieldNo();
+
+        List<FieldTemplateRefEntity> templateList = fieldTemplateRefService.findFieldByFieldNo(fieldNo);
+        List<CooperatorProductField> productList = CooperatorProductFieldService.findFieldByFieldNo(fieldNo);
+
+        List<Long> ids= templateList.stream().map(FieldTemplateRefEntity::getId)
+                .collect(Collectors.toList());
+        List<Long> idProducts= productList.stream().map(CooperatorProductField::getId)
+                .collect(Collectors.toList());
+
+        fieldTemplateRefService.removeByIds(ids);
+        CooperatorProductFieldService.removeByIds(idProducts);
         fieldDefineService.removeById(id);
+
         return Result.success();
     }
 

+ 1 - 0
src/main/java/com/kexun/controller/FieldTemplateController.java

@@ -180,6 +180,7 @@ public class FieldTemplateController {
     public Result save(@RequestBody FiledTemplateUpdateRO filedTemplateUpdateRO) {
         Result result = new Result();
         fieldTemplateService.save(filedTemplateUpdateRO);
+
         return result;
     }
 

+ 2 - 0
src/main/java/com/kexun/mapper/CooperatorProductFieldMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.kexun.entity.CooperatorField;
 import com.kexun.entity.CooperatorProduct;
 import com.kexun.entity.CooperatorProductField;
+import com.kexun.entity.FieldTemplateRefEntity;
 import org.springframework.data.repository.query.Param;
 
 import java.util.List;
@@ -14,4 +15,5 @@ import java.util.List;
 public interface CooperatorProductFieldMapper extends BaseMapper<CooperatorProductField> {
 
 
+    List<CooperatorProductField> QueryFieldByFieldNo(String fieldNo);
 }

+ 2 - 0
src/main/java/com/kexun/mapper/FieldTemplateRefMapper.java

@@ -20,4 +20,6 @@ public interface FieldTemplateRefMapper extends BaseMapper<FieldTemplateRefEntit
     List<FieldTemplateRefEntity> QueryField(String templateNo);
 
     List<FieldTemplateRefEntity> QueryDerive(String templateNo);
+
+    List<FieldTemplateRefEntity> QueryFieldByFieldNo(String fieldNo);
 }

+ 4 - 0
src/main/java/com/kexun/service/CooperatorProductFieldService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.kexun.entity.CooperatorProductField;
 import com.kexun.entity.FieldTemplateRefEntity;
 
+import java.util.List;
+
 /**
  * <p>
  * 产品和字段关系 服务类
@@ -14,4 +16,6 @@ import com.kexun.entity.FieldTemplateRefEntity;
 public interface CooperatorProductFieldService extends IService<CooperatorProductField> {
 
     CooperatorProductField findByID(long foid);
+
+    List<CooperatorProductField> findFieldByFieldNo(String fieldNo);
 }

+ 2 - 0
src/main/java/com/kexun/service/FieldTemplateRefService.java

@@ -20,4 +20,6 @@ public interface FieldTemplateRefService extends IService<FieldTemplateRefEntity
     List<FieldTemplateRefEntity> findTemplateFieldByNo(String templateNo);
 
     List<FieldTemplateRefEntity> findDeriveFieldByNo(String templateNo);
+
+    List<FieldTemplateRefEntity> findFieldByFieldNo(String fieldNo);
 }

+ 14 - 1
src/main/java/com/kexun/service/impl/CooperatorProductFieldImpl.java

@@ -5,25 +5,38 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.kexun.entity.CooperatorProductField;
 import com.kexun.entity.CreditApproval;
 import com.kexun.entity.FieldDefineEntity;
+import com.kexun.entity.FieldTemplateRefEntity;
 import com.kexun.mapper.CooperatorProductFieldMapper;
 import com.kexun.mapper.CreditApprovalMapper;
+import com.kexun.mapper.FieldTemplateRefMapper;
 import com.kexun.service.CooperatorProductFieldService;
 import com.kexun.service.CreditApprovalService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  *
  */
 @Service
 public class CooperatorProductFieldImpl extends ServiceImpl<CooperatorProductFieldMapper, CooperatorProductField>
     implements CooperatorProductFieldService {
+
+    @Autowired
+    CooperatorProductFieldMapper cooperatorProductFieldMapper;
     @Override
     public CooperatorProductField findByID(long id) {
         QueryWrapper<CooperatorProductField> wrapper=new QueryWrapper<CooperatorProductField>().eq("id",id);
         return getOne(wrapper);
     }
 
-
+    @Override
+    public List<CooperatorProductField> findFieldByFieldNo(String fieldNo) {
+//        System.out.println("aaa");
+        List<CooperatorProductField> l = cooperatorProductFieldMapper.QueryFieldByFieldNo(fieldNo);
+        return l;
+    }
 }
 
 

+ 7 - 0
src/main/java/com/kexun/service/impl/FieldTemplateRefServiceImpl.java

@@ -46,4 +46,11 @@ public class FieldTemplateRefServiceImpl extends ServiceImpl<FieldTemplateRefMap
         List<FieldTemplateRefEntity> l = fieldTemplateRefMapper.QueryDerive(templateNo);
         return l;
     }
+
+    @Override
+    public List<FieldTemplateRefEntity> findFieldByFieldNo(String fieldNo) {
+//        System.out.println("aaa");
+        List<FieldTemplateRefEntity> l = fieldTemplateRefMapper.QueryFieldByFieldNo(fieldNo);
+        return l;
+    }
 }

+ 7 - 0
src/main/resources/mapper/CooperatorProductFieldMapper.xml

@@ -27,5 +27,12 @@
         WHERE model_id=#{modelNo}
     </select>
 
+    <select id="QueryFieldByFieldNo" resultType="com.kexun.entity.CooperatorProductField" >
+        select id from product_field_ref
+        WHERE
+            field_no   = #{fieldNo}
+          and product_field_ref.is_deleted = 0
+
+    </select>
 
 </mapper>

+ 3 - 2
src/main/resources/mapper/CooperatorProductMapper.xml

@@ -47,8 +47,9 @@
         field_define.create_time,
             product_field_ref.id
         FROM
-            product_field_ref
-        LEFT JOIN field_define ON product_field_ref.field_id = field_define.id
+         field_define
+        LEFT JOIN  product_field_ref ON product_field_ref.field_no = field_define.field_no
+
         WHERE product_field_ref.product_num = #{productNum}
         and product_field_ref.is_deleted = 0
         and field_define.is_deleted=0

+ 8 - 5
src/main/resources/mapper/FieldDefineMapper.xml

@@ -36,7 +36,10 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        d.category,
+        d
+        .
+        category
+        ,
         d.create_by,
         d.create_time,
         d.fetch_logic,
@@ -72,7 +75,7 @@
         from field_define
         where category = #{cat}
           and is_deleted = 0
-        order by create_time desc,id desc
+        order by create_time desc, id desc
 
 
     </select>
@@ -82,7 +85,7 @@
         from field_define
         WHERE name_zh LIKE concat('%', #{info}, '%')
           and is_deleted = 0
-        order by create_time desc,id desc
+        order by create_time desc, id desc
 
     </select>
 
@@ -91,7 +94,7 @@
         from field_define
         WHERE name_zh LIKE concat('%', #{info}, '%')
           and is_deleted = 0
-        order by create_time desc,id desc
+        order by create_time desc, id desc
 
     </select>
 
@@ -107,7 +110,7 @@
         from field_define d
         LEFT JOIN product_field_ref r on d.field_no = r.field_no
         where r.product_num = #{productNum}
-        <if test="oneLevel!=null">
+        <if test="oneLevel!=null and oneLevel!=''">
             and d.one_level = #{oneLevel}
         </if>
         <if test="category!=null">

+ 8 - 0
src/main/resources/mapper/FieldTemplateRefMapper.xml

@@ -56,6 +56,14 @@
             template_no   = #{templateNo}
           and field_template_ref.type  = 2
           and field_template_ref.is_deleted = 0
+    </select>
+
+    <select id="QueryFieldByFieldNo" resultType="com.kexun.entity.FieldTemplateRefEntity" >
+        select id from field_template_ref
+        WHERE
+            field_no   = #{fieldNo}
+          and field_template_ref.is_deleted = 0
 
     </select>
+
 </mapper>