| | |
| | | public R save(@Valid @RequestBody Farm farm) { |
| | | farm.setCreateTime(new Date()); |
| | | farm.setUpdateTime(new Date()); |
| | | return R.status(farmService.save(farm)); |
| | | //坐标转换 |
| | | if (null != farm.getPosition() && !farm.getPosition().equals("")) { |
| | | //替换逗号为空格 |
| | | String sNull = farm.getPosition().replaceAll(",", " "); |
| | | //替换分号为逗号 |
| | | String replaceAll = sNull.replaceAll(";", ","); |
| | | farm.setPosition("'POLYGON((" + replaceAll + "))'"); |
| | | } |
| | | return R.status(farmService.saveFarmInfo(farm)); |
| | | } |
| | | |
| | | /** |
| | |
| | | private String type; |
| | | |
| | | /** |
| | | * 农场id |
| | | * 公司id |
| | | */ |
| | | private String deptId; |
| | | |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 农场id |
| | | */ |
| | | private Integer farmId; |
| | | |
| | | } |
| | |
| | | Farm getFarmInfo(@Param("farm") FarmVO farm); |
| | | Integer selectCountFarm(); |
| | | Integer selectCountUser(); |
| | | |
| | | /** |
| | | * 自定义新增农场信息 |
| | | * @param farm |
| | | * @return |
| | | */ |
| | | int saveFarmInfo(@Param("farm") Farm farm); |
| | | } |
| | |
| | | slogan, |
| | | introduce, |
| | | picture, |
| | | ST_ASTEXT(position) as position,user_id |
| | | ST_ASTEXT(position) as position |
| | | from |
| | | sys_farm |
| | | where 1=1 |
| | | <if test="farm.farmName!=null and farm.farmName!=''"> |
| | | and farm_name like concat('%',#{farm.farmName},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | <!--自定义修改电子围栏数据--> |
| | | <!--自定义修改农场围栏数据--> |
| | | <update id="updateFarmById"> |
| | | update sys_farm set farm_name = #{farm.farmName}, |
| | | farm_address = #{farm.farmAddress}, |
| | |
| | | where id = #{farm.id} |
| | | </update> |
| | | |
| | | <!--自定义新增农场围栏数据--> |
| | | <insert id="saveFarmInfo"> |
| | | insert into sys_farm (farm_name,farm_address,farm_area,slogan,introduce,picture,position,create_time,update_time,dept_id) |
| | | values |
| | | (#{farm.farmName},#{farm.farmAddress},#{farm.farmArea},#{farm.slogan},#{farm.introduce},#{farm.picture}, |
| | | <choose> |
| | | <when test="farm.position!=null and farm.position!=''"> |
| | | ST_GeomFromText(${farm.position}), |
| | | </when> |
| | | <otherwise> |
| | | '', |
| | | </otherwise> |
| | | </choose> |
| | | #{farm.createTime},#{farm.updateTime},#{farm.deptId}) |
| | | </insert> |
| | | |
| | | <!--详情信息(自定义查询)--> |
| | | <select id="getFarmInfo" resultType="org.springblade.modules.farm.vo.FarmVO"> |
| | | select id, |
| | |
| | | from |
| | | sys_farm |
| | | where 1=1 |
| | | and dept_id = #{farm.deptId} |
| | | and id = #{farm.id} |
| | | </select> |
| | | |
| | | <!--农场数量--> |
| | |
| | | Farm getFarmInfo(FarmVO farm); |
| | | Integer selectCountFarm(); |
| | | Integer selectCountUser(); |
| | | |
| | | /** |
| | | * 自定义新增农场信息 |
| | | * @param farm |
| | | * @return |
| | | */ |
| | | boolean saveFarmInfo(Farm farm); |
| | | } |
| | |
| | | public Integer selectCountUser() { |
| | | return baseMapper.selectCountUser(); |
| | | } |
| | | |
| | | /** |
| | | * 自定义新增农场信息 |
| | | * @param farm |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveFarmInfo(Farm farm) { |
| | | //新增 |
| | | int i = baseMapper.saveFarmInfo(farm); |
| | | if (i>0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |