feat (farm): 业务功能

- 字典表,收纳所有的字典内容
- 管理中心 (农事类型,农事名称)维护到字典表中
- 种植中心 (生产计划,农事记录)业务逻辑接口实现
This commit is contained in:
达富斌
2025-08-20 15:32:00 +08:00
parent 615a804c61
commit 0f48b11330
45 changed files with 1841 additions and 480 deletions

View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<sql id="all_fields">
id,
dict_type_code,
dict_type_name,
field1_code,
field1_name,
field2_code,
field2_name,
field3_code,
field3_name,
status,
deleted,
creator,
create_time,
updater,
update_time
</sql>
<select id="selectDictByOne"
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.sys.SysDictReqVO"
resultType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
SELECT
<include refid="all_fields"/>
FROM farm_sys_dict
<include refid="where_2"/>
</select>
<sql id="where_2">
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="dictTypeCode != null and dictTypeCode != ''">
AND dict_type_code = #{dictTypeCode}
</if>
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</where>
</sql>
<select id="selectDictByGroup"
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.sys.SysDictReqVO"
resultType="string">
SELECT field1_name
FROM farm_sys_dict
<where>
<if test="dictTypeCode != null and dictTypeCode != ''">
AND dict_type_code = #{dictTypeCode}
</if>
<if test="field1Code != null and field1Code != ''">
AND field1_code = #{field1Code}
</if>
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</where>
GROUP BY field1_name
</select>
<!-- 分页查询 -->
<select id="selectDictByPage"
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.sys.SysDictPageReqVO"
resultType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
SELECT
<include refid="all_fields"/>
FROM farm_sys_dict
<include refid="where_1"/>
ORDER BY dict_type_code, field1_code, field2_code, field3_code
LIMIT #{offset}, #{pageSize}
</select>
<!-- 统计总数 -->
<select id="countDictByCondition" resultType="java.lang.Long">
SELECT COUNT(*)
FROM farm_sys_dict
<include refid="where_1"/>
</select>
<sql id="where_1">
<where>
<if test="dictTypeCode != null and dictTypeCode != ''">
AND dict_type_code = #{dictTypeCode}
</if>
<if test="field1Code != null and field1Code != ''">
AND field1_code = #{field1Code}
</if>
<if test="field1Name != null and field1Name != ''">
AND field1_name LIKE CONCAT('%', #{field1Name}, '%')
</if>
<if test="field2Code != null and field2Code != ''">
AND field2_code = #{field2Code}
</if>
<if test="field2Name != null and field2Name != ''">
AND field2_name LIKE CONCAT('%', #{field2Name}, '%')
</if>
<if test="field3Code != null and field3Code != ''">
AND field3_code = #{field3Code}
</if>
<if test="field3Name != null and field3Name != ''">
AND field3_name LIKE CONCAT('%', #{field3Name}, '%')
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</where>
</sql>
<select id="getByTypeCode"
parameterType="cn.iocoder.yudao.module.farm.controller.admin.dict.vo.sys.SysDictPageReqVO"
resultType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
SELECT
<include refid="all_fields"/>
FROM farm_sys_dict t
WHERE
t.deleted = 0
AND t.dict_type_code = #{dictTypeCode}
</select>
<select id="groupByTypeCode" resultType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
SELECT dict_type_code,
dict_type_name
FROM farm_sys_dict
GROUP by dict_type_code, dict_type_name
</select>
<insert id="insertOne" parameterType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
INSERT INTO farm_sys_dict
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictTypeCode != null and dictTypeCode != ''">dict_type_code,</if>
<if test="dictTypeName != null and dictTypeName != ''">dict_type_name,</if>
<if test="field1Code != null">field1_code,</if>
<if test="field1Name != null">field1_name,</if>
<if test="field2Code != null">field2_code,</if>
<if test="field2Name != null">field2_name,</if>
<if test="field3Code != null">field3_code,</if>
<if test="field3Name != null">field3_name,</if>
<if test="status != null">status,</if>
<if test="deleted != null">deleted,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="updater != null and updater != ''">updater,</if>
create_time,
update_time
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="dictTypeCode != null and dictTypeCode != ''">#{dictTypeCode},</if>
<if test="dictTypeName != null and dictTypeName != ''">#{dictTypeName},</if>
<if test="field1Code != null">#{field1Code},</if>
<if test="field1Name != null">#{field1Name},</if>
<if test="field2Code != null">#{field2Code},</if>
<if test="field2Name != null">#{field2Name},</if>
<if test="field3Code != null">#{field3Code},</if>
<if test="field3Name != null">#{field3Name},</if>
<if test="status != null">#{status},</if>
<if test="deleted != null">#{deleted},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="updater != null and updater != ''">#{updater},</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateById" parameterType="cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO">
UPDATE farm_sys_dict
<set>
<if test="dictTypeCode != null and dictTypeCode != ''">dict_type_code = #{dictTypeCode},</if>
<if test="dictTypeName != null and dictTypeName != ''">dict_type_name = #{dictTypeName},</if>
<if test="field1Code != null">field1_code = #{field1Code},</if>
<if test="field1Name != null">field1_name = #{field1Name},</if>
<if test="field2Code != null">field2_code = #{field2Code},</if>
<if test="field2Name != null">field2_name = #{field2Name},</if>
<if test="field3Code != null">field3_code = #{field3Code},</if>
<if test="field3Name != null">field3_name = #{field3Name},</if>
<if test="status != null">status = #{status},</if>
<if test="deleted != null">deleted = #{deleted},</if>
<if test="updater != null and updater != ''">updater = #{updater},</if>
update_time = NOW()
</set>
WHERE id = #{id}
</update>
</mapper>

View File

@@ -9,4 +9,61 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="DisasterDataResultMap" type="cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO">
<!-- 基础字段 -->
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="category" property="category"/>
<result column="type" property="type"/>
<result column="disaster_description" property="disasterDescription"/>
<result column="treatment_suggestion" property="treatmentSuggestion"/>
<result column="img_url" property="imgUrl"/>
<result column="disaster_count" property="disasterCount"/>
<result column="disaster_time" property="disasterTime"/>
<result column="creator" property="creator"/>
<result column="create_time" property="createTime"/>
<!-- 其他字段 -->
<result column="foundation_id" property="foundationId"/>
<result column="base_id" property="baseId"/>
<result column="base_name" property="baseName"/>
<result column="plot_id" property="plotId"/>
<result column="plot_name" property="plotName"/>
<result column="tenant_id" property="tenantId"/>
<!-- 表中存在但DO中没有的字段 -->
<result column="updater" property="updater"/>
<result column="update_time" property="updateTime"/>
<result column="deleted" property="deleted"/>
</resultMap>
<select id="selectDisasterDataPage" resultMap="DisasterDataResultMap">
SELECT *
FROM farm_disaster_data
WHERE deleted = 0
<if test="req.name != null and req.name != ''">
AND name LIKE CONCAT('%', #{req.name}, '%')
</if>
<if test="req.category != null">
AND category = #{req.category}
</if>
<if test="req.type != null">
AND type = #{req.type}
</if>
LIMIT #{req.pageSize} OFFSET #{req.pageNo}
</select>
<select id="selectDisasterDataCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM farm_disaster_data
WHERE deleted = 0
<if test="req.name != null and req.name != ''">
AND name LIKE CONCAT('%', #{req.name}, '%')
</if>
<if test="req.category != null">
AND category = #{req.category}
</if>
<if test="req.type != null">
AND type = #{req.type}
</if>
</select>
</mapper>

View File

@@ -50,4 +50,27 @@
</where>
</select>
<update id="update" parameterType="cn.iocoder.yudao.module.farm.dal.dataobject.farmingtypemaintenance.FarmingTypeMaintenanceDO">
UPDATE farm_farming_type_maintenance t
<set>
<if test="req.farmingCode != null and req.farmingCode != ''">
t.farming_code = #{farmingCode},
</if>
<if test="req.farmingName != null and req.farmingName != ''">
t.farming_name = #{farmingName},
</if>
<if test="req.useStatus != null">
t.use_status = #{useStatus},
</if>
<if test="req.deleted != null">
t.deleted = #{deleted},
</if>
<if test="req.updater != null and req.updater != ''">
t.updater = #{updater},
</if>
t.update_time = NOW()
</set>
where t.id = #{req.id}
</update>
</mapper>

View File

@@ -10,16 +10,16 @@
-->
<sql id="all_fields">
id,
primary_class_code,
primary_class_name,
secondary_class_code,
secondary_class_name,
use_status,
creator,
create_time,
updater,
update_time
t.id,
t.primary_class_code,
t.primary_class_name,
t.secondary_class_code,
t.secondary_class_name,
t.use_status,
t.creator,
t.create_time,
t.updater,
t.update_time
</sql>
<select id="getSpeciesClassifyLibraryList"
@@ -29,39 +29,24 @@
SELECT <include refid="all_fields"/> FROM farm_species_classify_library t
<where>
<if test="req.id != null">
AND id = #{req.id}
AND t.id = #{req.id}
</if>
<if test="req.primaryClassCode != null and req.primaryClassCode != ''">
AND primary_class_code = #{req.primaryClassCode}
AND t.tprimary_class_code = #{req.primaryClassCode}
</if>
<if test="req.primaryClassName != null and req.primaryClassName != ''">
AND primary_class_name LIKE CONCAT('%', #{req.primaryClassName}, '%')
AND t.primary_class_name LIKE CONCAT('%', #{req.primaryClassName}, '%')
</if>
<if test="req.secondaryClassCode != null and req.secondaryClassCode != ''">
AND secondary_class_code = #{req.secondaryClassCode}
AND t.secondary_class_code = #{req.secondaryClassCode}
</if>
<if test="req.secondaryClassName != null and req.secondaryClassName != ''">
AND secondary_class_name LIKE CONCAT('%', #{req.secondaryClassName}, '%')
AND t.secondary_class_name LIKE CONCAT('%', #{req.secondaryClassName}, '%')
</if>
<if test="req.useStatus != null">
AND use_status = #{req.useStatus}
</if>
<if test="req.creator != null and req.creator != ''">
AND creator = #{req.creator}
</if>
<if test="req.createTime != null">
AND create_time >= #{req.createTime}
</if>
<if test="req.updater != null and req.updater != ''">
AND updater = #{req.updater}
</if>
<if test="req.updateTime != null">
AND update_time >= #{req.updateTime}
AND t.use_status = #{req.useStatus}
</if>
</where>
ORDER BY t.id DESC
</select>
</mapper>