11个文件已修改
193 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaUserMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/LoginVo.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application-self.yml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaUserMapper.java
@@ -134,6 +134,8 @@
     */
    List<Map<String, Object>> getRoleNamesByUserId(@Param("userId") Long userId);
    Long countPhone(@Param("phone") String phone) ;
    /**
     * 得到所有手机号(登录账号)
     * @return
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
@@ -205,4 +205,20 @@
     * @return
     */
    List<VoIntakeSimple> getNotLinkVcIntakes();
    /**
     * 为wechat,根据指定取水口名称模糊(后端)查询水口记录数
     * @param params
     * @return
     */
    Long getSomeIntakesCount4Wx(Map<?, ?> params);
    /**
     * 为wechat,根据指定取水口名称模糊(后端)查询水口
     * @param params
     * @return
     */
    List<VoOnLineIntake> getSomeIntakes4Wx(Map<?, ?> params);
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -367,6 +367,20 @@
        where id = #{id,jdbcType=BIGINT}
    </select>
    <!--根据指定的条件获取用户记录数-->
    <select id="countPhone" resultType="java.lang.Long">
        SELECT
        COUNT(*) AS recordCount
        FROM ba_user user
        <where>
            user.supperAdmin != 1
            AND user.deleted = 0
            <if test = "phone != null and phone !=''">
                AND user.phone= #{phone}
            </if>
        </where>
    </select>
    <select id="getPhones" resultType="java.lang.String">
        SELECT phone FROM ba_user WHERE deleted = 0 and disabled = 0
    </select>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -765,4 +765,37 @@
                WHERE iv.intake_id = inta.id
            ) AND inta.deleted = 0
    </select>
    <!-- 为wechat,根据指定取水口名称模糊(后端)查询水口记录数 -->
    <select id="getSomeIntakesCount4Wx" parameterType="java.util.Map" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM pr_intake tb
        <where>
            tb.deleted = 0
            <if test="intakeNum != null and intakeNum != ''">
                AND tb.name LIKE CONCAT('%', #{intakeNum})
            </if>
        </where>
    </select>
    <!-- 为wechat,根据指定取水口名称模糊(后端)查询水口记录 -->
    <select id="getSomeIntakes4Wx" parameterType="java.util.Map" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
        SELECT
        inta.id AS intakeId,
        con.rtuAddr,
        inta.name AS intakeNum
        FROM pr_intake inta
        INNER JOIN pr_controller con ON con.intakeId = inta.id
        <where>
            inta.deleted = 0
            <if test="intakeNum != null and intakeNum != ''">
                AND inta.name LIKE CONCAT('%', #{intakeNum})
            </if>
        </where>
        ORDER BY inta.id DESC
    </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/LoginVo.java
@@ -37,11 +37,11 @@
    /**
     * 图形验证码token,即session的key
     */
    private String token;
    public String token;
    /**
     * 图形验证码结果
     */
    private String code;
    public String code;
}
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -113,42 +113,35 @@
        if(vo.orgTag == null || vo.orgTag.trim().length() == 0){
            return BaseResponseUtils.buildErrorMsg("未选择组织单位");
        }
        if(vo.token == null || vo.token.trim().length() == 0){
            return BaseResponseUtils.buildErrorMsg("无token");
        }
        if(vo.code == null || vo.code.trim().length() == 0){
            return BaseResponseUtils.buildErrorMsg("请输入验证码");
        }
        //把组织单位标签作为数据源名称
        DataSourceContext.set(vo.orgTag);
        String token = Optional.ofNullable(vo.getToken()).orElse("");
        String code = Optional.ofNullable(vo.getCode()).orElse("");
        if(token.length() > 0 && code.length() > 0) {
            // 从session中获取验证码
            //HttpSession session = (HttpSession) request.getSession();
            //String localCode = session.getAttribute(token).toString();
            Map map = sv.getCodeByToken(token);
            Long expiration = Long.parseLong(map.get("expiration").toString());
            Long currentTimestamp = System.currentTimeMillis();
            if(currentTimestamp > expiration) {
                return BaseResponseUtils.buildErrorMsg("验证码已超时");
            }
            // 从数据库获取验证码
            String localCode = map.get("code").toString();
            if(!code.equals(localCode)) {
                return BaseResponseUtils.buildErrorMsg("验证码错误");
            }
        // 从数据库获取验证码
        Map map = sv.getCodeByToken(vo.token);
        Long expiration = Long.parseLong(map.get("expiration").toString());
        Long currentTimestamp = System.currentTimeMillis();
        if(currentTimestamp > expiration) {
            return BaseResponseUtils.buildErrorMsg("验证码已超时");
        }
        String localCode = map.get("code").toString();
        if(!vo.code.equals(localCode)) {
            return BaseResponseUtils.buildErrorMsg("验证码错误");
        }
        //得到所有用户账号
        List<String> phones = sv.getPhones();
        if(!phones.contains(vo.phone)){
        if(!sv.existPhone(vo.phone)){
            return BaseResponseUtils.buildErrorMsg("账号不存在");
        }
        String uuid ;
        BaUser userPo ;
        String uuid4Token = null;
        BaUser userPo = null ;
        try {
            //Boolean flag = cacheManager.getCacheNames().isEmpty() ;
            uuid = UUID.randomUUID().toString();
            uuid4Token = UUID.randomUUID().toString();
            if(!StringUtils.isNullOrEmpty(vo.password)){
                /*
                如果前端进行了base64加密
@@ -156,7 +149,7 @@
                */
                vo.password = MD5.encrypt(vo.password) ;
            }
            userPo = this.sv.loginWithMapperXml(uuid, vo.phone, vo.password);
            userPo = this.sv.loginWithMapperXml(uuid4Token, vo.phone, vo.password);
        } catch (Exception e) {
            log.error("用户登录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -164,10 +157,10 @@
        if(userPo != null){
            UserVo uVo = UserVoMapper.INSTANCT.po2vo(userPo);
            uVo.token = uuid ;
            uVo.token = uuid4Token ;
            return BaseResponseUtils.buildSuccess(uVo);
        }else{
            return BaseResponseUtils.buildErrorMsg("密码错误");
            return BaseResponseUtils.buildErrorMsg("登录失败");
        }
    }
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoSv.java
@@ -73,6 +73,18 @@
    }
    /**
     * 判断手机号是否存在
     * @return
     */
    public boolean existPhone(String phone){
        Long count = baUserMapper.countPhone(phone) ;
        if(count == null || count == 0){
            return false ;
        }
        return true ;
    }
    /**
     * 得到所有用户手机号
     * @return
     */
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java
@@ -40,6 +40,22 @@
     * @return
     */
    @GetMapping(path = "all_intakes")
    public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getSomeIntakes(OnLineIntakesQO qo) {
        try {
            return BaseResponseUtils.buildSuccess(intakeSv.selectSomeIntakes(qo));
        } catch (Exception e) {
            log.error("查询取水口异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
    /**
     * 根据取水口编号获取取水口对象
     * @param qo
     * @return
     */
    @GetMapping(path = "all_intakes1")
    public BaseResponse<QueryResultVo<VoOnLineIntake>> getOneIntake(OnLineIntakesQO qo) {
        try {
            return BaseResponseUtils.buildSuccess(intakeSv.selectOneIntake(qo));
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java
@@ -65,6 +65,30 @@
        this.env = env;
    }
    /**
     * 获取取水口列表
     * @return
     */
    public QueryResultVo<List<VoOnLineIntake>> selectSomeIntakes(OnLineIntakesQO qo) {
        // 如果 intakeNum 不为空,则转为小写再写入qo对象
        String intakeNum = qo.getIntakeNum();
        if(intakeNum != null) {
            qo.setIntakeNum(intakeNum.toLowerCase());
        }
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
        Long itemTotal = prIntakeMapper.getSomeIntakesCount4Wx(params);
        QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = prIntakeMapper.getSomeIntakes4Wx(params);
        return rsVo;
    }
    /**
     * 根据取水口编号获取取水口对象
     * @return
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
@@ -18,6 +18,7 @@
import org.apache.dubbo.common.utils.PojoUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -67,6 +68,11 @@
    @Autowired
    private CommandSv commandSv;
    @Value("${webchat.irr.plan.delay}")
    private Integer irrPlanDelay ;//轮灌中计划开阀的延迟时长
    private static final Integer irrPlanDelayDefault = 5 ;//轮灌中计划开阀的默认延迟时长
    /**
     * 添加灌溉计划
@@ -179,8 +185,12 @@
        LocalDateTime startTime = planStartTime.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();
        if(startupMode == 1){
            // 测试阶段延后2分钟,正式发布为5分钟
            startTime = startTime.plusMinutes(2);
            //startTime = startTime.plusMinutes(2);
            //startTime = startTime.plusMinutes(5);
            if(irrPlanDelay == null || irrPlanDelay <= 0) {
                irrPlanDelay = irrPlanDelayDefault ;
            }
            startTime = startTime.plusMinutes(irrPlanDelay);
        }
        planStartTime = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant());
        LocalDateTime stopTime = startTime.plusMinutes(duration);
@@ -527,7 +537,7 @@
    }
    @Transactional(rollbackFor = Exception.class)
    private Integer updatePlanTimes(Date planStartTime, Date planEndTime,  Long planId){
    Integer updatePlanTimes(Date planStartTime, Date planEndTime, Long planId){
        return irrigatePlanMapper.updatePlanTimes(planStartTime, planEndTime, planId);
    }
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application-self.yml
@@ -12,6 +12,11 @@
        context-parameters:
            #GenerateIdSetSuffixListener中应用,取值范围是0-99
            idSuffix: ${pipIrr.wechat.idSuffix}
webchat:
    irr:
        plan:
            delay: 5 #轮灌中计划开阀的延迟时长
#阿里短信服务
aliyun: