更改设计,暂不支持自定义作物阶段,改成通用阶段,即使用作物id为0的预定义阶段。
重新使用单表生成作物功能,已可用。
This commit is contained in:
@ -2,6 +2,8 @@ package com.jlt.csa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -25,7 +27,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
* 作物档案Controller
|
||||
*
|
||||
* @author 郏磊涛
|
||||
* @date 2022-03-30
|
||||
* @date 2022-03-31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csa/cropfile")
|
||||
@ -37,7 +39,7 @@ public class CropFileController extends BaseController
|
||||
/**
|
||||
* 查询作物档案列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:query')")
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CropFile cropFile)
|
||||
{
|
||||
@ -72,29 +74,33 @@ public class CropFileController extends BaseController
|
||||
/**
|
||||
* 新增作物档案
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:update')")
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:add')")
|
||||
@Log(title = "作物档案", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CropFile cropFile)
|
||||
{
|
||||
cropFile.setCreateBy(getUsername());
|
||||
cropFile.setCreateTime(DateUtils.getNowDate());
|
||||
return toAjax(cropFileService.insertCropFile(cropFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改作物档案
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:update')")
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:edit')")
|
||||
@Log(title = "作物档案", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CropFile cropFile)
|
||||
{
|
||||
cropFile.setUpdateBy(getUsername());
|
||||
cropFile.setUpdateTime(DateUtils.getNowDate());
|
||||
return toAjax(cropFileService.updateCropFile(cropFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除作物档案
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:update')")
|
||||
@PreAuthorize("@ss.hasPermi('csa:cropfile:remove')")
|
||||
@Log(title = "作物档案", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{cropIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] cropIds)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.jlt.csa.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
@ -10,7 +9,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
* 作物档案对象 csa_crop_file
|
||||
*
|
||||
* @author 郏磊涛
|
||||
* @date 2022-03-30
|
||||
* @date 2022-03-31
|
||||
*/
|
||||
public class CropFile extends BaseEntity
|
||||
{
|
||||
@ -26,24 +25,24 @@ public class CropFile extends BaseEntity
|
||||
/** 种植指南 */
|
||||
private String plantGuide;
|
||||
|
||||
/** 代表图片 */
|
||||
@Excel(name = "代表图片")
|
||||
/** 配图 */
|
||||
@Excel(name = "配图")
|
||||
private String picture;
|
||||
|
||||
/** 云配图 */
|
||||
private String pictureOss;
|
||||
|
||||
/** 作物描述 */
|
||||
@Excel(name = "作物描述")
|
||||
private String description;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
/** 可种状态 */
|
||||
@Excel(name = "可种状态")
|
||||
private String status;
|
||||
|
||||
/** 删除标志 */
|
||||
private String delFlag;
|
||||
|
||||
/** 作物生长阶段信息 */
|
||||
private List<CropPhase> cropPhaseList;
|
||||
|
||||
public void setCropId(Long cropId)
|
||||
{
|
||||
this.cropId = cropId;
|
||||
@ -80,6 +79,15 @@ public class CropFile extends BaseEntity
|
||||
{
|
||||
return picture;
|
||||
}
|
||||
public void setPictureOss(String pictureOss)
|
||||
{
|
||||
this.pictureOss = pictureOss;
|
||||
}
|
||||
|
||||
public String getPictureOss()
|
||||
{
|
||||
return pictureOss;
|
||||
}
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
@ -108,16 +116,6 @@ public class CropFile extends BaseEntity
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public List<CropPhase> getCropPhaseList()
|
||||
{
|
||||
return cropPhaseList;
|
||||
}
|
||||
|
||||
public void setCropPhaseList(List<CropPhase> cropPhaseList)
|
||||
{
|
||||
this.cropPhaseList = cropPhaseList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -125,6 +123,7 @@ public class CropFile extends BaseEntity
|
||||
.append("cropName", getCropName())
|
||||
.append("plantGuide", getPlantGuide())
|
||||
.append("picture", getPicture())
|
||||
.append("pictureOss", getPictureOss())
|
||||
.append("description", getDescription())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
@ -133,7 +132,6 @@ public class CropFile extends BaseEntity
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("cropPhaseList", getCropPhaseList())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,12 @@ package com.jlt.csa.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.jlt.csa.domain.CropFile;
|
||||
import com.jlt.csa.domain.CropPhase;
|
||||
|
||||
/**
|
||||
* 作物档案Mapper接口
|
||||
*
|
||||
* @author 郏磊涛
|
||||
* @date 2022-03-30
|
||||
* @date 2022-03-31
|
||||
*/
|
||||
public interface CropFileMapper
|
||||
{
|
||||
@ -59,29 +58,4 @@ public interface CropFileMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCropFileByCropIds(Long[] cropIds);
|
||||
|
||||
/**
|
||||
* 批量删除作物生长阶段
|
||||
*
|
||||
* @param cropIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCropPhaseByCropIds(Long[] cropIds);
|
||||
|
||||
/**
|
||||
* 批量新增作物生长阶段
|
||||
*
|
||||
* @param cropPhaseList 作物生长阶段列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchCropPhase(List<CropPhase> cropPhaseList);
|
||||
|
||||
|
||||
/**
|
||||
* 通过作物档案主键删除作物生长阶段信息
|
||||
*
|
||||
* @param cropId 作物档案ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCropPhaseByCropId(Long cropId);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.jlt.csa.domain.CropFile;
|
||||
* 作物档案Service接口
|
||||
*
|
||||
* @author 郏磊涛
|
||||
* @date 2022-03-30
|
||||
* @date 2022-03-31
|
||||
*/
|
||||
public interface ICropFileService
|
||||
{
|
||||
|
@ -4,10 +4,6 @@ import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jlt.csa.domain.CropPhase;
|
||||
import com.jlt.csa.mapper.CropFileMapper;
|
||||
import com.jlt.csa.domain.CropFile;
|
||||
import com.jlt.csa.service.ICropFileService;
|
||||
@ -16,7 +12,7 @@ import com.jlt.csa.service.ICropFileService;
|
||||
* 作物档案Service业务层处理
|
||||
*
|
||||
* @author 郏磊涛
|
||||
* @date 2022-03-30
|
||||
* @date 2022-03-31
|
||||
*/
|
||||
@Service
|
||||
public class CropFileServiceImpl implements ICropFileService
|
||||
@ -54,14 +50,10 @@ public class CropFileServiceImpl implements ICropFileService
|
||||
* @param cropFile 作物档案
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int insertCropFile(CropFile cropFile)
|
||||
{
|
||||
cropFile.setCreateTime(DateUtils.getNowDate());
|
||||
int rows = cropFileMapper.insertCropFile(cropFile);
|
||||
insertCropPhase(cropFile);
|
||||
return rows;
|
||||
return cropFileMapper.insertCropFile(cropFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,13 +62,9 @@ public class CropFileServiceImpl implements ICropFileService
|
||||
* @param cropFile 作物档案
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateCropFile(CropFile cropFile)
|
||||
{
|
||||
cropFile.setUpdateTime(DateUtils.getNowDate());
|
||||
cropFileMapper.deleteCropPhaseByCropId(cropFile.getCropId());
|
||||
insertCropPhase(cropFile);
|
||||
return cropFileMapper.updateCropFile(cropFile);
|
||||
}
|
||||
|
||||
@ -86,11 +74,9 @@ public class CropFileServiceImpl implements ICropFileService
|
||||
* @param cropIds 需要删除的作物档案主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteCropFileByCropIds(Long[] cropIds)
|
||||
{
|
||||
cropFileMapper.deleteCropPhaseByCropIds(cropIds);
|
||||
return cropFileMapper.deleteCropFileByCropIds(cropIds);
|
||||
}
|
||||
|
||||
@ -100,35 +86,9 @@ public class CropFileServiceImpl implements ICropFileService
|
||||
* @param cropId 作物档案主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteCropFileByCropId(Long cropId)
|
||||
{
|
||||
cropFileMapper.deleteCropPhaseByCropId(cropId);
|
||||
return cropFileMapper.deleteCropFileByCropId(cropId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增作物生长阶段信息
|
||||
*
|
||||
* @param cropFile 作物档案对象
|
||||
*/
|
||||
public void insertCropPhase(CropFile cropFile)
|
||||
{
|
||||
List<CropPhase> cropPhaseList = cropFile.getCropPhaseList();
|
||||
Long cropId = cropFile.getCropId();
|
||||
if (StringUtils.isNotNull(cropPhaseList))
|
||||
{
|
||||
List<CropPhase> list = new ArrayList<CropPhase>();
|
||||
for (CropPhase cropPhase : cropPhaseList)
|
||||
{
|
||||
cropPhase.setCropId(cropId);
|
||||
list.add(cropPhase);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
cropFileMapper.batchCropPhase(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="cropName" column="crop_name" />
|
||||
<result property="plantGuide" column="plant_guide" />
|
||||
<result property="picture" column="picture" />
|
||||
<result property="pictureOss" column="picture_oss" />
|
||||
<result property="description" column="description" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
@ -19,43 +20,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="CropFileCropPhaseResult" type="CropFile" extends="CropFileResult">
|
||||
<collection property="cropPhaseList" notNullColumn="sub_phase_id" javaType="java.util.List" resultMap="CropPhaseResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="CropPhase" id="CropPhaseResult">
|
||||
<result property="phaseId" column="sub_phase_id" />
|
||||
<result property="cropId" column="sub_crop_id" />
|
||||
<result property="phaseName" column="sub_phase_name" />
|
||||
<result property="production" column="sub_production" />
|
||||
<result property="picture" column="sub_picture" />
|
||||
<result property="status" column="sub_status" />
|
||||
<result property="delFlag" column="sub_del_flag" />
|
||||
<result property="createBy" column="sub_create_by" />
|
||||
<result property="createTime" column="sub_create_time" />
|
||||
<result property="updateBy" column="sub_update_by" />
|
||||
<result property="updateTime" column="sub_update_time" />
|
||||
<result property="remark" column="sub_remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCropFileVo">
|
||||
select crop_id, crop_name, plant_guide, picture, description, status, del_flag, create_by, create_time, update_by, update_time, remark from csa_crop_file
|
||||
select crop_id, crop_name, plant_guide, picture, picture_oss, description, status, del_flag, create_by, create_time, update_by, update_time, remark from csa_crop_file
|
||||
</sql>
|
||||
|
||||
<select id="selectCropFileList" parameterType="CropFile" resultMap="CropFileResult">
|
||||
<include refid="selectCropFileVo"/>
|
||||
<where>
|
||||
<if test="cropName != null and cropName != ''"> and crop_name like concat('%', #{cropName}, '%')</if>
|
||||
<if test="picture != null and picture != ''"> and picture = #{picture}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCropFileByCropId" parameterType="Long" resultMap="CropFileCropPhaseResult">
|
||||
select a.crop_id, a.crop_name, a.plant_guide, a.picture, a.description, a.status, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
|
||||
b.phase_id as sub_phase_id, b.crop_id as sub_crop_id, b.phase_name as sub_phase_name, b.production as sub_production, b.picture as sub_picture, b.status as sub_status, b.del_flag as sub_del_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
|
||||
from csa_crop_file a
|
||||
left join csa_crop_phase b on b.crop_id = a.crop_id
|
||||
where a.crop_id = #{cropId}
|
||||
<select id="selectCropFileByCropId" parameterType="Long" resultMap="CropFileResult">
|
||||
<include refid="selectCropFileVo"/>
|
||||
where crop_id = #{cropId}
|
||||
</select>
|
||||
|
||||
<insert id="insertCropFile" parameterType="CropFile" useGeneratedKeys="true" keyProperty="cropId">
|
||||
@ -64,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cropName != null and cropName != ''">crop_name,</if>
|
||||
<if test="plantGuide != null">plant_guide,</if>
|
||||
<if test="picture != null">picture,</if>
|
||||
<if test="pictureOss != null">picture_oss,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
@ -77,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cropName != null and cropName != ''">#{cropName},</if>
|
||||
<if test="plantGuide != null">#{plantGuide},</if>
|
||||
<if test="picture != null">#{picture},</if>
|
||||
<if test="pictureOss != null">#{pictureOss},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
@ -94,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cropName != null and cropName != ''">crop_name = #{cropName},</if>
|
||||
<if test="plantGuide != null">plant_guide = #{plantGuide},</if>
|
||||
<if test="picture != null">picture = #{picture},</if>
|
||||
<if test="pictureOss != null">picture_oss = #{pictureOss},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
@ -116,22 +99,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{cropId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCropPhaseByCropIds" parameterType="String">
|
||||
delete from csa_crop_phase where crop_id in
|
||||
<foreach item="cropId" collection="array" open="(" separator="," close=")">
|
||||
#{cropId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCropPhaseByCropId" parameterType="Long">
|
||||
delete from csa_crop_phase where crop_id = #{cropId}
|
||||
</delete>
|
||||
|
||||
<insert id="batchCropPhase">
|
||||
insert into csa_crop_phase( phase_id, crop_id, phase_name, production, picture, status, del_flag, create_by, create_time, update_by, update_time, remark) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.phaseId}, #{item.cropId}, #{item.phaseName}, #{item.production}, #{item.picture}, #{item.status}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
Reference in New Issue
Block a user