Explorar el Código

农村三资数据填报

wwh hace 2 semanas
padre
commit
1a36f1d866

+ 89 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/controller/BizRuralThreeAssetsController.java

@@ -0,0 +1,89 @@
1
+package com.ruoyi.web.modules.industryservice.controller;
2
+
3
+import java.util.List;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+import org.springframework.security.access.prepost.PreAuthorize;
6
+import org.springframework.validation.annotation.Validated;
7
+import org.springframework.web.bind.annotation.DeleteMapping;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.PathVariable;
10
+import org.springframework.web.bind.annotation.PostMapping;
11
+import org.springframework.web.bind.annotation.PutMapping;
12
+import org.springframework.web.bind.annotation.RequestBody;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.RestController;
15
+import com.ruoyi.common.annotation.Log;
16
+import com.ruoyi.common.core.controller.BaseController;
17
+import com.ruoyi.common.core.domain.AjaxResult;
18
+import com.ruoyi.common.core.page.TableDataInfo;
19
+import com.ruoyi.common.enums.BusinessType;
20
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
21
+import com.ruoyi.web.modules.industryservice.service.IBizRuralThreeAssetsService;
22
+
23
+/**
24
+ * 农村三资数据填报 REST。
25
+ * <p>Base:{@code /dataModel/ruralThreeAssets};权限 {@code dataModel:ruralThreeAssets:*};无导入导出。</p>
26
+ */
27
+@RestController
28
+@RequestMapping("/dataModel/ruralThreeAssets")
29
+public class BizRuralThreeAssetsController extends BaseController
30
+{
31
+    @Autowired
32
+    private IBizRuralThreeAssetsService service;
33
+
34
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:list')")
35
+    @GetMapping("/list")
36
+    public TableDataInfo list(BizRuralThreeAssets query)
37
+    {
38
+        startPage();
39
+        List<BizRuralThreeAssets> list = service.selectBizRuralThreeAssetsList(query);
40
+        return getDataTable(list);
41
+    }
42
+
43
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:query')")
44
+    @GetMapping("/{id}")
45
+    public AjaxResult getInfo(@PathVariable("id") Long id)
46
+    {
47
+        return success(service.selectBizRuralThreeAssetsById(id));
48
+    }
49
+
50
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:add')")
51
+    @Log(title = "农村三资数据填报", businessType = BusinessType.INSERT)
52
+    @PostMapping
53
+    public AjaxResult add(@Validated @RequestBody BizRuralThreeAssets row)
54
+    {
55
+        row.setCreateBy(getUsername());
56
+        return toAjax(service.insertBizRuralThreeAssets(row));
57
+    }
58
+
59
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:edit')")
60
+    @Log(title = "农村三资数据填报", businessType = BusinessType.UPDATE)
61
+    @PutMapping
62
+    public AjaxResult edit(@Validated @RequestBody BizRuralThreeAssets row)
63
+    {
64
+        row.setUpdateBy(getUsername());
65
+        return toAjax(service.updateBizRuralThreeAssets(row));
66
+    }
67
+
68
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:remove')")
69
+    @Log(title = "农村三资数据填报", businessType = BusinessType.DELETE)
70
+    @DeleteMapping("/{ids}")
71
+    public AjaxResult remove(@PathVariable Long[] ids)
72
+    {
73
+        return toAjax(service.deleteBizRuralThreeAssetsByIds(ids, getUsername()));
74
+    }
75
+
76
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:list')")
77
+    @GetMapping("/townOptions")
78
+    public AjaxResult townOptions()
79
+    {
80
+        return success(service.listTownOptions());
81
+    }
82
+
83
+    @PreAuthorize("@ss.hasPermi('dataModel:ruralThreeAssets:list')")
84
+    @GetMapping("/villageTree")
85
+    public AjaxResult villageTree()
86
+    {
87
+        return success(service.listVillageTree());
88
+    }
89
+}

+ 114 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/domain/BizRuralThreeAssets.java

@@ -0,0 +1,114 @@
1
+package com.ruoyi.web.modules.industryservice.domain;
2
+
3
+import java.math.BigDecimal;
4
+import javax.validation.constraints.NotNull;
5
+import com.ruoyi.common.core.domain.BaseEntity;
6
+
7
+/**
8
+ * 农村三资数据填报,对应表 {@code biz_rural_three_assets}。
9
+ * <p>粒度:村级唯一;固定资产 = 经营性固定资产 + 非经营性固定资产(保存时派生落库)。</p>
10
+ */
11
+public class BizRuralThreeAssets extends BaseEntity
12
+{
13
+    private static final long serialVersionUID = 1L;
14
+
15
+    private Long id;
16
+
17
+    private Long townDeptId;
18
+
19
+    private String townName;
20
+
21
+    @NotNull(message = "所属村不能为空")
22
+    private Long villageDeptId;
23
+
24
+    private String villageName;
25
+
26
+    /** 经营性固定资产(万元) */
27
+    private BigDecimal operatingFixedAssets;
28
+
29
+    /** 非经营性固定资产(万元) */
30
+    private BigDecimal nonOperatingFixedAssets;
31
+
32
+    /** 固定资产(万元),派生 */
33
+    private BigDecimal fixedAssets;
34
+
35
+    public Long getId()
36
+    {
37
+        return id;
38
+    }
39
+
40
+    public void setId(Long id)
41
+    {
42
+        this.id = id;
43
+    }
44
+
45
+    public Long getTownDeptId()
46
+    {
47
+        return townDeptId;
48
+    }
49
+
50
+    public void setTownDeptId(Long townDeptId)
51
+    {
52
+        this.townDeptId = townDeptId;
53
+    }
54
+
55
+    public String getTownName()
56
+    {
57
+        return townName;
58
+    }
59
+
60
+    public void setTownName(String townName)
61
+    {
62
+        this.townName = townName;
63
+    }
64
+
65
+    public Long getVillageDeptId()
66
+    {
67
+        return villageDeptId;
68
+    }
69
+
70
+    public void setVillageDeptId(Long villageDeptId)
71
+    {
72
+        this.villageDeptId = villageDeptId;
73
+    }
74
+
75
+    public String getVillageName()
76
+    {
77
+        return villageName;
78
+    }
79
+
80
+    public void setVillageName(String villageName)
81
+    {
82
+        this.villageName = villageName;
83
+    }
84
+
85
+    public BigDecimal getOperatingFixedAssets()
86
+    {
87
+        return operatingFixedAssets;
88
+    }
89
+
90
+    public void setOperatingFixedAssets(BigDecimal operatingFixedAssets)
91
+    {
92
+        this.operatingFixedAssets = operatingFixedAssets;
93
+    }
94
+
95
+    public BigDecimal getNonOperatingFixedAssets()
96
+    {
97
+        return nonOperatingFixedAssets;
98
+    }
99
+
100
+    public void setNonOperatingFixedAssets(BigDecimal nonOperatingFixedAssets)
101
+    {
102
+        this.nonOperatingFixedAssets = nonOperatingFixedAssets;
103
+    }
104
+
105
+    public BigDecimal getFixedAssets()
106
+    {
107
+        return fixedAssets;
108
+    }
109
+
110
+    public void setFixedAssets(BigDecimal fixedAssets)
111
+    {
112
+        this.fixedAssets = fixedAssets;
113
+    }
114
+}

+ 23 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/mapper/BizRuralThreeAssetsMapper.java

@@ -0,0 +1,23 @@
1
+package com.ruoyi.web.modules.industryservice.mapper;
2
+
3
+import java.util.List;
4
+import org.apache.ibatis.annotations.Param;
5
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
6
+
7
+/**
8
+ * 农村三资数据填报 Mapper。
9
+ */
10
+public interface BizRuralThreeAssetsMapper
11
+{
12
+    BizRuralThreeAssets selectBizRuralThreeAssetsById(Long id);
13
+
14
+    int countByVillageExcludeId(@Param("villageDeptId") Long villageDeptId, @Param("excludeId") Long excludeId);
15
+
16
+    List<BizRuralThreeAssets> selectBizRuralThreeAssetsList(BizRuralThreeAssets query);
17
+
18
+    int insertBizRuralThreeAssets(BizRuralThreeAssets row);
19
+
20
+    int updateBizRuralThreeAssets(BizRuralThreeAssets row);
21
+
22
+    int deleteBizRuralThreeAssetsByIds(@Param("ids") Long[] ids);
23
+}

+ 25 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/service/IBizRuralThreeAssetsService.java

@@ -0,0 +1,25 @@
1
+package com.ruoyi.web.modules.industryservice.service;
2
+
3
+import java.util.List;
4
+import com.ruoyi.common.core.domain.TreeSelect;
5
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
6
+
7
+/**
8
+ * 农村三资数据填报服务(仅 CRUD,无导入导出)。
9
+ */
10
+public interface IBizRuralThreeAssetsService
11
+{
12
+    BizRuralThreeAssets selectBizRuralThreeAssetsById(Long id);
13
+
14
+    List<BizRuralThreeAssets> selectBizRuralThreeAssetsList(BizRuralThreeAssets query);
15
+
16
+    int insertBizRuralThreeAssets(BizRuralThreeAssets row);
17
+
18
+    int updateBizRuralThreeAssets(BizRuralThreeAssets row);
19
+
20
+    int deleteBizRuralThreeAssetsByIds(Long[] ids, String updateBy);
21
+
22
+    List<java.util.Map<String, Object>> listTownOptions();
23
+
24
+    List<TreeSelect> listVillageTree();
25
+}

+ 115 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/service/impl/BizRuralThreeAssetsServiceImpl.java

@@ -0,0 +1,115 @@
1
+package com.ruoyi.web.modules.industryservice.service.impl;
2
+
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.stereotype.Service;
7
+import org.springframework.transaction.annotation.Transactional;
8
+import com.ruoyi.common.exception.ServiceException;
9
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
10
+import com.ruoyi.web.modules.industryservice.mapper.BizRuralThreeAssetsMapper;
11
+import com.ruoyi.web.modules.industryservice.service.IBizRuralThreeAssetsService;
12
+import com.ruoyi.web.modules.industryservice.support.RuralThreeAssetsValidation;
13
+import com.ruoyi.web.modules.industryservice.support.TownDeptSupport;
14
+
15
+/**
16
+ * 农村三资数据填报服务实现。
17
+ * <p>唯一键:村;固定资产保存时派生。</p>
18
+ */
19
+@Service
20
+public class BizRuralThreeAssetsServiceImpl implements IBizRuralThreeAssetsService
21
+{
22
+    @Autowired
23
+    private BizRuralThreeAssetsMapper mapper;
24
+
25
+    @Autowired
26
+    private TownDeptSupport townDeptSupport;
27
+
28
+    @Override
29
+    public BizRuralThreeAssets selectBizRuralThreeAssetsById(Long id)
30
+    {
31
+        return mapper.selectBizRuralThreeAssetsById(id);
32
+    }
33
+
34
+    @Override
35
+    public List<BizRuralThreeAssets> selectBizRuralThreeAssetsList(BizRuralThreeAssets query)
36
+    {
37
+        return mapper.selectBizRuralThreeAssetsList(query);
38
+    }
39
+
40
+    @Override
41
+    @Transactional(rollbackFor = Exception.class)
42
+    public int insertBizRuralThreeAssets(BizRuralThreeAssets row)
43
+    {
44
+        RuralThreeAssetsValidation.validateRowForSave(row, townDeptSupport);
45
+        assertUniqueVillage(row.getVillageDeptId(), null);
46
+        return mapper.insertBizRuralThreeAssets(row);
47
+    }
48
+
49
+    @Override
50
+    @Transactional(rollbackFor = Exception.class)
51
+    public int updateBizRuralThreeAssets(BizRuralThreeAssets row)
52
+    {
53
+        if (row.getId() == null)
54
+        {
55
+            throw new ServiceException("主键不能为空");
56
+        }
57
+        RuralThreeAssetsValidation.validateRowForSave(row, townDeptSupport);
58
+        requireExistingRow(row.getId());
59
+        assertUniqueVillage(row.getVillageDeptId(), row.getId());
60
+        return mapper.updateBizRuralThreeAssets(row);
61
+    }
62
+
63
+    @Override
64
+    @Transactional(rollbackFor = Exception.class)
65
+    public int deleteBizRuralThreeAssetsByIds(Long[] ids, String updateBy)
66
+    {
67
+        if (ids == null || ids.length == 0)
68
+        {
69
+            return 0;
70
+        }
71
+        List<Long> cleaned = new ArrayList<>();
72
+        for (Long id : ids)
73
+        {
74
+            if (id != null)
75
+            {
76
+                cleaned.add(id);
77
+            }
78
+        }
79
+        if (cleaned.isEmpty())
80
+        {
81
+            return 0;
82
+        }
83
+        return mapper.deleteBizRuralThreeAssetsByIds(cleaned.toArray(new Long[0]));
84
+    }
85
+
86
+    @Override
87
+    public List<java.util.Map<String, Object>> listTownOptions()
88
+    {
89
+        return townDeptSupport.toOptionList();
90
+    }
91
+
92
+    @Override
93
+    public List<com.ruoyi.common.core.domain.TreeSelect> listVillageTree()
94
+    {
95
+        return townDeptSupport.buildVillageTree();
96
+    }
97
+
98
+    private void assertUniqueVillage(Long villageDeptId, Long excludeId)
99
+    {
100
+        if (mapper.countByVillageExcludeId(villageDeptId, excludeId) > 0)
101
+        {
102
+            throw new ServiceException("该村已填报");
103
+        }
104
+    }
105
+
106
+    private BizRuralThreeAssets requireExistingRow(Long id)
107
+    {
108
+        BizRuralThreeAssets row = mapper.selectBizRuralThreeAssetsById(id);
109
+        if (row == null)
110
+        {
111
+            throw new ServiceException("记录不存在");
112
+        }
113
+        return row;
114
+    }
115
+}

+ 41 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/support/RuralThreeAssetsDerivedSupport.java

@@ -0,0 +1,41 @@
1
+package com.ruoyi.web.modules.industryservice.support;
2
+
3
+import java.math.BigDecimal;
4
+import java.math.RoundingMode;
5
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
6
+
7
+/**
8
+ * 农村三资派生字段。
9
+ * <p>固定资产 = 经营性固定资产 + 非经营性固定资产,保留 2 位小数;两者皆空则固定资产为空。</p>
10
+ */
11
+public final class RuralThreeAssetsDerivedSupport
12
+{
13
+    private RuralThreeAssetsDerivedSupport()
14
+    {
15
+    }
16
+
17
+    public static void applyDerived(BizRuralThreeAssets row)
18
+    {
19
+        if (row == null)
20
+        {
21
+            return;
22
+        }
23
+        BigDecimal operating = row.getOperatingFixedAssets();
24
+        BigDecimal nonOperating = row.getNonOperatingFixedAssets();
25
+        if (operating == null && nonOperating == null)
26
+        {
27
+            row.setFixedAssets(null);
28
+            return;
29
+        }
30
+        BigDecimal sum = BigDecimal.ZERO;
31
+        if (operating != null)
32
+        {
33
+            sum = sum.add(operating);
34
+        }
35
+        if (nonOperating != null)
36
+        {
37
+            sum = sum.add(nonOperating);
38
+        }
39
+        row.setFixedAssets(sum.setScale(2, RoundingMode.HALF_UP));
40
+    }
41
+}

+ 57 - 0
baqing-admin/src/main/java/com/ruoyi/web/modules/industryservice/support/RuralThreeAssetsValidation.java

@@ -0,0 +1,57 @@
1
+package com.ruoyi.web.modules.industryservice.support;
2
+
3
+import java.math.BigDecimal;
4
+import com.ruoyi.common.core.domain.entity.SysDept;
5
+import com.ruoyi.common.exception.ServiceException;
6
+import com.ruoyi.common.utils.StringUtils;
7
+import com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets;
8
+
9
+/**
10
+ * 农村三资数据填报校验:村反推乡镇、金额非负、派生固定资产。
11
+ */
12
+public final class RuralThreeAssetsValidation
13
+{
14
+    private RuralThreeAssetsValidation()
15
+    {
16
+    }
17
+
18
+    public static void validateRowForSave(BizRuralThreeAssets row, TownDeptSupport townDeptSupport)
19
+    {
20
+        if (row == null)
21
+        {
22
+            throw new ServiceException("参数不能为空");
23
+        }
24
+        if (row.getVillageDeptId() == null)
25
+        {
26
+            throw new ServiceException("所属村不能为空");
27
+        }
28
+        SysDept village = townDeptSupport.requireReportVillage(row.getVillageDeptId());
29
+        if (village == null)
30
+        {
31
+            throw new ServiceException("所属村不合法");
32
+        }
33
+        SysDept town = townDeptSupport.requireReportTown(village.getParentId());
34
+        if (town == null)
35
+        {
36
+            throw new ServiceException("所属村的上级乡镇不合法");
37
+        }
38
+        row.setVillageName(village.getDeptName());
39
+        row.setTownDeptId(town.getDeptId());
40
+        row.setTownName(town.getDeptName());
41
+        validateNonNegative(row.getOperatingFixedAssets(), "经营性固定资产");
42
+        validateNonNegative(row.getNonOperatingFixedAssets(), "非经营性固定资产");
43
+        if (StringUtils.isNotEmpty(row.getRemark()) && row.getRemark().length() > 500)
44
+        {
45
+            throw new ServiceException("备注不能超过500字");
46
+        }
47
+        RuralThreeAssetsDerivedSupport.applyDerived(row);
48
+    }
49
+
50
+    private static void validateNonNegative(BigDecimal value, String label)
51
+    {
52
+        if (value != null && value.compareTo(BigDecimal.ZERO) < 0)
53
+        {
54
+            throw new ServiceException(label + "不能为负数");
55
+        }
56
+    }
57
+}

+ 96 - 0
baqing-admin/src/main/resources/mapper/industryservice/BizRuralThreeAssetsMapper.xml

@@ -0,0 +1,96 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<!-- 农村三资数据填报 biz_rural_three_assets -->
4
+<mapper namespace="com.ruoyi.web.modules.industryservice.mapper.BizRuralThreeAssetsMapper">
5
+
6
+    <resultMap type="com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets"
7
+               id="BizRuralThreeAssetsResult">
8
+        <id     property="id"                         column="id"/>
9
+        <result property="townDeptId"                 column="town_dept_id"/>
10
+        <result property="townName"                   column="town_name"/>
11
+        <result property="villageDeptId"              column="village_dept_id"/>
12
+        <result property="villageName"                column="village_name"/>
13
+        <result property="operatingFixedAssets"       column="operating_fixed_assets"/>
14
+        <result property="nonOperatingFixedAssets"    column="non_operating_fixed_assets"/>
15
+        <result property="fixedAssets"                column="fixed_assets"/>
16
+        <result property="createBy"                   column="create_by"/>
17
+        <result property="createTime"                 column="create_time"/>
18
+        <result property="updateBy"                   column="update_by"/>
19
+        <result property="updateTime"                 column="update_time"/>
20
+        <result property="remark"                     column="remark"/>
21
+    </resultMap>
22
+
23
+    <sql id="selectVo">
24
+        select r.id, r.town_dept_id, r.town_name, r.village_dept_id, r.village_name,
25
+               r.operating_fixed_assets, r.non_operating_fixed_assets, r.fixed_assets,
26
+               r.create_by, r.create_time, r.update_by, r.update_time, r.remark
27
+        from biz_rural_three_assets r
28
+    </sql>
29
+
30
+    <select id="selectBizRuralThreeAssetsById" parameterType="long" resultMap="BizRuralThreeAssetsResult">
31
+        <include refid="selectVo"/>
32
+        where r.id = #{id}
33
+    </select>
34
+
35
+    <select id="countByVillageExcludeId" resultType="int">
36
+        select count(1)
37
+        from biz_rural_three_assets
38
+        where village_dept_id = #{villageDeptId}
39
+        <if test="excludeId != null">
40
+            and id != #{excludeId}
41
+        </if>
42
+    </select>
43
+
44
+    <select id="selectBizRuralThreeAssetsList"
45
+            parameterType="com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets"
46
+            resultMap="BizRuralThreeAssetsResult">
47
+        <include refid="selectVo"/>
48
+        left join sys_dept d on r.town_dept_id = d.dept_id
49
+        <where>
50
+            <if test="townDeptId != null">
51
+                and r.town_dept_id = #{townDeptId}
52
+            </if>
53
+            <if test="villageDeptId != null">
54
+                and r.village_dept_id = #{villageDeptId}
55
+            </if>
56
+        </where>
57
+        order by d.order_num asc, r.village_dept_id asc, r.id desc
58
+    </select>
59
+
60
+    <insert id="insertBizRuralThreeAssets"
61
+            parameterType="com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets"
62
+            useGeneratedKeys="true" keyProperty="id">
63
+        insert into biz_rural_three_assets (
64
+            town_dept_id, town_name, village_dept_id, village_name,
65
+            operating_fixed_assets, non_operating_fixed_assets, fixed_assets,
66
+            create_by, create_time, remark
67
+        ) values (
68
+            #{townDeptId}, #{townName}, #{villageDeptId}, #{villageName},
69
+            #{operatingFixedAssets}, #{nonOperatingFixedAssets}, #{fixedAssets},
70
+            #{createBy}, sysdate(), #{remark}
71
+        )
72
+    </insert>
73
+
74
+    <update id="updateBizRuralThreeAssets"
75
+            parameterType="com.ruoyi.web.modules.industryservice.domain.BizRuralThreeAssets">
76
+        update biz_rural_three_assets set
77
+            town_dept_id = #{townDeptId},
78
+            town_name = #{townName},
79
+            village_dept_id = #{villageDeptId},
80
+            village_name = #{villageName},
81
+            operating_fixed_assets = #{operatingFixedAssets},
82
+            non_operating_fixed_assets = #{nonOperatingFixedAssets},
83
+            fixed_assets = #{fixedAssets},
84
+            update_by = #{updateBy},
85
+            update_time = sysdate(),
86
+            remark = #{remark}
87
+        where id = #{id}
88
+    </update>
89
+
90
+    <delete id="deleteBizRuralThreeAssetsByIds">
91
+        delete from biz_rural_three_assets where id in
92
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
93
+            #{id}
94
+        </foreach>
95
+    </delete>
96
+</mapper>

+ 44 - 0
doc/产业数据模型及服务/农村三资数据填报/农村三资数据填报功能需求.md

@@ -0,0 +1,44 @@
1
+# 农村三资数据填报 — 功能需求
2
+
3
+## 1. 文档说明
4
+
5
+| 项 | 说明 |
6
+| --- | --- |
7
+| 模块名称 | 农村三资数据填报 |
8
+| 粒度 | 村级(一村一条) |
9
+| 范围 | 普通增删改查;**无需**导入/导出 |
10
+
11
+---
12
+
13
+## 2. 字段
14
+
15
+| 字段 | 单位 | 说明 |
16
+| --- | --- | --- |
17
+| 所属村 | — | 必填;搜索、列表 |
18
+| 所属乡镇 | — | 由村反推;搜索、列表 |
19
+| 经营性固定资产 | 万元 | 可空,≥0 |
20
+| 非经营性固定资产 | 万元 | 可空,≥0 |
21
+| 固定资产 | 万元 | 派生:经营性 + 非经营性 |
22
+
23
+---
24
+
25
+## 3. 业务规则
26
+
27
+1. 唯一键:`village_dept_id`(同一村不可重复填报)。
28
+2. 保存时服务端计算并落库固定资产;前端表单只读预览。
29
+3. 金额非负;备注 ≤500 字。
30
+
31
+---
32
+
33
+## 4. 权限与菜单
34
+
35
+- 权限:`dataModel:ruralThreeAssets:list|query|add|edit|remove`
36
+- 组件:`dataModel/ruralThreeAssets/index`
37
+
38
+---
39
+
40
+## 5. 修订记录
41
+
42
+| 版本 | 说明 |
43
+| --- | --- |
44
+| 1.0 | 初版:村级 CRUD + 固定资产派生 |

+ 42 - 0
doc/产业数据模型及服务/农村三资数据填报/农村三资数据填报技术方案.md

@@ -0,0 +1,42 @@
1
+# 农村三资数据填报 — 技术方案
2
+
3
+> 依据:同目录功能需求。普通 CRUD,无导入导出。
4
+
5
+## 1. 架构
6
+
7
+Controller `/dataModel/ruralThreeAssets` → Service → Mapper;校验 `RuralThreeAssetsValidation`;派生 `RuralThreeAssetsDerivedSupport`。
8
+
9
+## 2. 表 `biz_rural_three_assets`
10
+
11
+DDL:`sql/biz_rural_three_assets.sql`
12
+
13
+| 字段 | 类型 | 说明 |
14
+| --- | --- | --- |
15
+| `village_dept_id` | bigint | 唯一键 `uk_village` |
16
+| `town_dept_id` / `town_name` | — | 村反推冗余 |
17
+| `operating_fixed_assets` | decimal(18,2) | 经营性固定资产(万元) |
18
+| `non_operating_fixed_assets` | decimal(18,2) | 非经营性固定资产(万元) |
19
+| `fixed_assets` | decimal(18,2) | 固定资产 = 两者之和,保留 2 位 |
20
+
21
+## 3. 接口
22
+
23
+| 方法 | 路径 | 权限 |
24
+| --- | --- | --- |
25
+| GET | `/list` | list |
26
+| GET | `/{id}` | query |
27
+| POST | `/` | add |
28
+| PUT | `/` | edit |
29
+| DELETE | `/{ids}` | remove |
30
+| GET | `/townOptions` `/villageTree` | list |
31
+
32
+## 4. 前端
33
+
34
+- 页面:`ruoyi-ui/src/views/dataModel/ruralThreeAssets/index.vue`
35
+- API:`ruoyi-ui/src/api/dataModel/ruralThreeAssets.js`
36
+- 表单只选村;固定资产只读预览;列表筛乡镇/村
37
+
38
+## 5. 修订记录
39
+
40
+| 版本 | 说明 |
41
+| --- | --- |
42
+| 1.0 | 初版 |

+ 25 - 0
doc/产业数据模型及服务/农村三资数据填报/农村三资数据填报测试用例.md

@@ -0,0 +1,25 @@
1
+# 农村三资数据填报 — 测试用例
2
+
3
+> **接口 Base Path**:`/dataModel/ruralThreeAssets`  
4
+> **建表**:执行 `sql/biz_rural_three_assets.sql`  
5
+> **说明**:无导入导出
6
+
7
+| 编号 | 场景 | 期望 |
8
+| --- | --- | --- |
9
+| UT-001 | 两项均有值 | 固定资产 = 经营性 + 非经营性,保留 2 位 |
10
+| UT-002 | 仅一项有值 | 固定资产 = 该项值 |
11
+| UT-003 | 两项皆空 | 固定资产为空 |
12
+| API-001 | 新增 | 选村成功;乡镇回填;固定资产落库 |
13
+| API-002 | 唯一键 | 同村再增失败「该村已填报」 |
14
+| API-003 | 修改 | 改金额后固定资产重算 |
15
+| API-004 | 删除 | 物理删除成功 |
16
+| API-005 | 负数 | 经营性/非经营性为负 → 失败 |
17
+| UI-001 | 列表筛选 | 乡镇、村 |
18
+| UI-002 | 表单预览 | 固定资产只读随两项变化 |
19
+| UI-003 | 查看详情 | 单位「万元」展示 |
20
+
21
+## 修订记录
22
+
23
+| 版本 | 说明 |
24
+| --- | --- |
25
+| 1.0 | 初稿 |

+ 20 - 0
sql/biz_rural_three_assets.sql

@@ -0,0 +1,20 @@
1
+-- 农村三资数据填报(物理删除;村级唯一;固定资产=经营性+非经营性)
2
+DROP TABLE IF EXISTS `biz_rural_three_assets`;
3
+CREATE TABLE `biz_rural_three_assets` (
4
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
5
+  `town_dept_id` bigint(20) NOT NULL COMMENT '所属乡镇dept_id',
6
+  `town_name` varchar(64) NOT NULL COMMENT '乡镇名称',
7
+  `village_dept_id` bigint(20) NOT NULL COMMENT '所属村dept_id',
8
+  `village_name` varchar(128) NOT NULL COMMENT '所属村名称',
9
+  `operating_fixed_assets` decimal(18,2) DEFAULT NULL COMMENT '经营性固定资产(万元)',
10
+  `non_operating_fixed_assets` decimal(18,2) DEFAULT NULL COMMENT '非经营性固定资产(万元)',
11
+  `fixed_assets` decimal(18,2) DEFAULT NULL COMMENT '固定资产(万元)=经营性+非经营性',
12
+  `create_by` varchar(64) DEFAULT '' COMMENT '创建者',
13
+  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
14
+  `update_by` varchar(64) DEFAULT '' COMMENT '更新者',
15
+  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
16
+  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
17
+  PRIMARY KEY (`id`),
18
+  UNIQUE KEY `uk_village` (`village_dept_id`),
19
+  KEY `idx_town_dept_id` (`town_dept_id`)
20
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='农村三资数据填报';