Browse Source

1.项目申报_项目申报项目类型数据状态联动
2.项目申报_项目申报类型删除check

dongbing 2 years ago
parent
commit
87752ce59a

+ 7 - 0
ruoyi-modules/mz-business-xmsb/src/main/java/com/ruoyi/business/domain/ZwywXmsbXmbdpz.java

@@ -73,4 +73,11 @@ public class ZwywXmsbXmbdpz extends BaseEntity
 
     private String dictType;
 
+    /** 数据状态 */
+    @Excel(name = "数据状态")
+    @ApiModelProperty(value = "数据状态", required = true)
+    @NotBlank(message = "{数据状态}",groups = AddGroup.class)
+    @Size(min = 1, max = 2, message = "{数据状态}")
+    private String status;
+
 }

+ 7 - 1
ruoyi-modules/mz-business-xmsb/src/main/java/com/ruoyi/business/mapper/ZwywXmsbXmlxMapper.java

@@ -6,10 +6,16 @@ import com.ruoyi.common.datascope.utils.BaseMapperPlus;
 
 /**
  * 项目申报项目类型信息Mapper接口
- * 
+ *
  * @author sun
  * @date 2022-10-25
  */
 public interface ZwywXmsbXmlxMapper extends BaseMapperPlus<ZwywXmsbXmlx> {
 
+
+    //根据申报项目类型信息id查询上级关联项目申报信息
+    public List<String> zwywXmsbCommonInfoById(String id);
+
+    //根据申报项目类型信息id查询下级关联附件类型信息
+    public List<String> zwywXmsbFjlxById(String id);
 }

+ 24 - 7
ruoyi-modules/mz-business-xmsb/src/main/java/com/ruoyi/business/service/IZwywXmsbXmlxService.java

@@ -5,15 +5,15 @@ import com.ruoyi.business.domain.ZwywXmsbXmlx;
 
 /**
  * 项目申报项目类型信息Service接口
- * 
+ *
  * @author sun
  * @date 2022-10-25
  */
-public interface IZwywXmsbXmlxService 
+public interface IZwywXmsbXmlxService
 {
     /**
      * 查询项目申报项目类型信息
-     * 
+     *
      * @param id 项目申报项目类型信息主键
      * @return 项目申报项目类型信息
      */
@@ -21,7 +21,7 @@ public interface IZwywXmsbXmlxService
 
     /**
      * 查询项目申报项目类型信息列表
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 项目申报项目类型信息集合
      */
@@ -29,7 +29,7 @@ public interface IZwywXmsbXmlxService
 
     /**
      * 新增项目申报项目类型信息
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface IZwywXmsbXmlxService
 
     /**
      * 修改项目申报项目类型信息
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 结果
      */
@@ -45,10 +45,27 @@ public interface IZwywXmsbXmlxService
 
     /**
      * 批量删除项目申报项目类型信息
-     * 
+     *
      * @param ids 需要删除的项目申报项目类型信息主键集合
      * @return 结果
      */
     public int deleteZwywXmsbXmlxByIds(String[] ids);
 
+
+    /**
+     * 根据申报项目类型信息id查询上级关联项目申报信息
+     *
+     * @param id
+     * @return
+     */
+    public List<String> zwywXmsbCommonInfoById(String id);
+
+    /**
+     * 根据申报项目类型信息id查询下级关联附件类型信息
+     *
+     * @param id
+     * @return
+     */
+    public List<String> zwywXmsbFjlxById(String id);
+
 }

+ 42 - 7
ruoyi-modules/mz-business-xmsb/src/main/java/com/ruoyi/business/service/impl/ZwywXmsbXmlxServiceImpl.java

@@ -1,6 +1,14 @@
 package com.ruoyi.business.service.impl;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.business.domain.ZwywXmsbFjlx;
+import com.ruoyi.business.domain.ZwywXmsbXmbdpz;
+import com.ruoyi.business.mapper.ZwywXmsbFjlxMapper;
+import com.ruoyi.business.mapper.ZwywXmsbXmbdpzMapper;
+import com.ruoyi.system.api.enums.StateStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import java.util.Arrays;
@@ -11,19 +19,25 @@ import com.ruoyi.business.service.IZwywXmsbXmlxService;
 
 /**
  * 项目申报项目类型信息Service业务层处理
- * 
+ *
  * @author sun
  * @date 2022-10-25
  */
 @Service
-public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService 
+public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService
 {
     @Autowired
     private ZwywXmsbXmlxMapper zwywXmsbXmlxMapper;
 
+    @Autowired
+    private ZwywXmsbFjlxMapper zwywXmsbFjlxMapper;
+
+    @Autowired
+    private ZwywXmsbXmbdpzMapper zwywXmsbXmbdpzMapper;
+
     /**
      * 查询项目申报项目类型信息
-     * 
+     *
      * @param id 项目申报项目类型信息主键
      * @return 项目申报项目类型信息
      */
@@ -35,7 +49,7 @@ public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService
 
     /**
      * 查询项目申报项目类型信息列表
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 项目申报项目类型信息
      */
@@ -47,7 +61,7 @@ public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService
 
     /**
      * 新增项目申报项目类型信息
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 结果
      */
@@ -59,19 +73,29 @@ public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService
 
     /**
      * 修改项目申报项目类型信息
-     * 
+     *
      * @param zwywXmsbXmlx 项目申报项目类型信息
      * @return 结果
      */
     @Override
     public int updateZwywXmsbXmlx(ZwywXmsbXmlx zwywXmsbXmlx)
     {
+        //0 开启
+        if (StateStatus.NORMAL.getCode().equals(zwywXmsbXmlx.getStatus())){
+            LambdaUpdateWrapper<ZwywXmsbFjlx> zwywXmsbFjlx = Wrappers.lambdaUpdate();
+            zwywXmsbFjlx.eq(ZwywXmsbFjlx::getXmlxId,zwywXmsbXmlx.getId()).set(ZwywXmsbFjlx::getStatus,StateStatus.NORMAL.getCode());
+            zwywXmsbFjlxMapper.update(null,zwywXmsbFjlx);
+
+            LambdaUpdateWrapper<ZwywXmsbXmbdpz> zwywXmsbXmbdpz = Wrappers.lambdaUpdate();
+            zwywXmsbXmbdpz.eq(ZwywXmsbXmbdpz::getXmlxId,zwywXmsbXmlx.getId()).set(ZwywXmsbXmbdpz::getStatus,StateStatus.NORMAL.getCode());
+            zwywXmsbXmbdpzMapper.update(null,zwywXmsbXmbdpz);
+        }
         return zwywXmsbXmlxMapper.updateById(zwywXmsbXmlx);
     }
 
     /**
      * 批量删除项目申报项目类型信息
-     * 
+     *
      * @param ids 需要删除的项目申报项目类型信息主键
      * @return 结果
      */
@@ -81,4 +105,15 @@ public class ZwywXmsbXmlxServiceImpl implements IZwywXmsbXmlxService
         return zwywXmsbXmlxMapper.deleteBatchIds(Arrays.asList(ids));
     }
 
+
+    @Override
+    public List<String> zwywXmsbCommonInfoById(String id) {
+        return zwywXmsbXmlxMapper.zwywXmsbCommonInfoById(id);
+    }
+
+    @Override
+    public List<String> zwywXmsbFjlxById(String id) {
+        return zwywXmsbXmlxMapper.zwywXmsbFjlxById(id);
+    }
+
 }

+ 9 - 2
ruoyi-modules/mz-business-xmsb/src/main/resources/mapper/business/ZwywXmsbXmlxMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.business.mapper.ZwywXmsbXmlxMapper">
-    
+
     <resultMap type="ZwywXmsbXmlx" id="ZwywXmsbXmlxResult">
         <result property="id"    column="id"    />
         <result property="lxmc"    column="lxmc"    />
@@ -23,4 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="state"    column="state"    />
     </resultMap>
 
-</mapper>
+    <select id="zwywXmsbCommonInfoById" resultType="String">
+        select id from zwyw_xmsb_common where xmlx = #{id}
+    </select>
+
+    <select id="zwywXmsbFjlxById" resultType="String">
+        select id from zwyw_xmsb_fjlx where xmlx_id = #{id}
+    </select>
+</mapper>

+ 14 - 1
ruoyi-modules/mz-business/src/main/java/com/ruoyi/business/controller/ZwywXmsbXmlxController.java

@@ -15,11 +15,12 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
 import java.util.List;
 
 /**
  * 项目申报项目类型信息Controller
- * 
+ *
  * @author sun
  * @date 2022-10-25
  */
@@ -103,6 +104,18 @@ public class ZwywXmsbXmlxController extends BaseController
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable String[] ids)
     {
+        //项目申报类型信息id
+        String xmlxId = Arrays.asList(ids).get(0);
+        //根据项目申报类型信息id查询关联项目申报信息list
+        List<String> xmlxCommon = zwywXmsbXmlxService.zwywXmsbCommonInfoById(xmlxId);
+        //根据项目申报类型信息id查询关联附件类型list
+        List<String> xmlxFjlx = zwywXmsbXmlxService.zwywXmsbFjlxById(xmlxId);
+        if (xmlxCommon.size() > 0){
+            return AjaxResult.error("当前项目申报项目类型已占用,不能删除");
+        }
+        if (xmlxFjlx.size() > 0){
+            return AjaxResult.error("当前项目申报项目类型含有附件类型,不能删除");
+        }
         return toAjax(zwywXmsbXmlxService.deleteZwywXmsbXmlxByIds(ids));
     }
 }