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>