liurunyu
2024-11-29 f91feae7adadd6c92dbd49ffcd2358a6b8abfaf4
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
2个文件已修改
5个文件已添加
198 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrGroupClientMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrGroupClientMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/config/DataSourceFilter.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/config/DataSourceFilterConfiguration.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanSv.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrGroupClientMapper.java
@@ -2,7 +2,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrGroupClient;
import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author ZhuBaoMin
@@ -24,4 +27,13 @@
    int updateByPrimaryKeySelective(IrGroupClient record);
    int updateByPrimaryKey(IrGroupClient record);
    /**
     * 根据农户编号获取轮灌组列表
     * @param clientId
     * @return
     */
    List<VoGroupSimple> getGroupsByClientId(Long clientId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java
New file
@@ -0,0 +1,31 @@
package com.dy.pipIrrGlobal.voIr;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.dy.common.po.BaseEntity;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-11-28 17:11
 * @LastEditTime 2024-11-28 17:11
 * @Description 轮灌组简单视图对象
 */
@Data
@JsonPropertyOrder({"groupId", "groupCode"})
public class VoGroupSimple implements BaseEntity {
    public static final long serialVersionUID = 202411281712001L;
    /**
     * 轮灌组ID
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long groupId;
    /**
     * 轮灌组编码
     */
    private String groupCode;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrGroupClientMapper.xml
@@ -99,4 +99,15 @@
      operate_time = #{operateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据农户编号获取轮灌组列表-->
  <select id="getGroupsByClientId" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple">
    SELECT
      grp.id AS groupId,
      grp.group_code AS groupCode
    FROM ir_group_client gc
           INNER JOIN ir_irrigate_group grp ON grp.id = gc.group_id
    WHERE grp.deleted = 0 AND client_id = #{clientId}
    ORDER BY grp.group_code
  </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/config/DataSourceFilter.java
New file
@@ -0,0 +1,41 @@
package com.dy.pipIrrApp.config;
import com.dy.common.multiDataSource.DataSourceContext;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
/**
 * @author ZhuBaoMin
 * @date 2024-11-29 14:24
 * @LastEditTime 2024-11-29 14:24
 * @Description
 */
@Slf4j
public class DataSourceFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException  {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
        HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
        String wxDataSourceName = httpRequest.getHeader("tag");
        if (wxDataSourceName != null && wxDataSourceName.trim().length() > 0) {
            log.info("APP开发,设置数据源名称为:" + wxDataSourceName);
            //把组织单位标签作为数据源名称
            DataSourceContext.set(wxDataSourceName);
        } else {
            log.info("用户未选择数据源");
        }
        filterChain.doFilter(servletRequest, servletResponse);
    }
    @Override
    public void destroy() {
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/config/DataSourceFilterConfiguration.java
New file
@@ -0,0 +1,27 @@
package com.dy.pipIrrApp.config;
import jakarta.servlet.Filter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author ZhuBaoMin
 * @date 2024-11-29 14:29
 * @LastEditTime 2024-11-29 14:29
 * @Description
 */
@Configuration
public class DataSourceFilterConfiguration {
    @Bean
    public FilterRegistrationBean<? extends Filter> DataSourceFilter() {
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new DataSourceFilter());
        filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则
        filterRegistrationBean.setName("DataSourceFilter");//设置过滤器名称
        filterRegistrationBean.setOrder(1);//执行次序
        return filterRegistrationBean;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java
New file
@@ -0,0 +1,44 @@
package com.dy.pipIrrIrrigate.irrigatePlan;
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * @author ZhuBaoMin
 * @date 2024-11-28 17:20
 * @LastEditTime 2024-11-28 17:20
 * @Description 灌溉计划控制类
 */
@Slf4j
@RestController
@RequestMapping(path = "irrigatePlan")
@RequiredArgsConstructor
public class IrrigatePlanCtrl {
    private final IrrigatePlanSv irrigatePlanSv;
    /**
     * 根据农户编号获取轮灌组列表
     * @return
     */
    @GetMapping(path = "/getGroups")
    @SsoAop()
    public BaseResponse<List<VoGroupSimple>> getGroups(@RequestParam("clientId") Long clientId) {
        try {
            return BaseResponseUtils.buildSuccess(irrigatePlanSv.getGroups(clientId));
        } catch (Exception e) {
            log.error("获取任务类型异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanSv.java
New file
@@ -0,0 +1,32 @@
package com.dy.pipIrrIrrigate.irrigatePlan;
import com.dy.pipIrrGlobal.daoIr.IrGroupClientMapper;
import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * @author ZhuBaoMin
 * @date 2024-11-28 17:20
 * @LastEditTime 2024-11-28 17:20
 * @Description 灌溉计划服务类
 */
@Slf4j
@Service
public class IrrigatePlanSv {
    @Autowired
    private IrGroupClientMapper irGroupClientMapper;
    /**
     * 根据农户编号获取轮灌组列表
     * @param clientId
     * @return
     */
    public List<VoGroupSimple> getGroups(Long clientId) {
        return irGroupClientMapper.getGroupsByClientId(clientId);
    }
}